Skip to content

Commit

Permalink
Merge pull request #466 from Luos-io/feat/multitreading
Browse files Browse the repository at this point in the history
Enable multithreading, fix #441
  • Loading branch information
nicolas-rabault authored Jan 24, 2024
2 parents d9b6ed5 + fccbabb commit 3bb80a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions engine/IO/src/luos_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,11 @@ static void Phy_Dispatch(void)
phy_job.phy_data = NULL;

// Write the job in the phy queue and get back the pointer to it
MSGALLOC_MUTEX_LOCK
phy_job_t *job_ptr = Phy_AddJob(&phy_ctx.phy[y], &phy_job);
// Notify this phy that a job is available and give it the concerned job on his queue
phy_ctx.phy[y].job_cb(&phy_ctx.phy[y], job_ptr);
MSGALLOC_MUTEX_UNLOCK
}
}
Phy_SetIrqState(false);
Expand Down
2 changes: 2 additions & 0 deletions engine/core/src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,10 @@ error_return_t Service_Deliver(phy_job_t *job)
// This means that this job already contain a service filter.
// We just have to loop in the service list, filter it, call the callback and remove it from the service filter.
error_return_t error = SUCCEED;
MSGALLOC_MUTEX_LOCK
LUOS_ASSERT(job);
service_filter_t *service_filter = (service_filter_t *)job->phy_data;
MSGALLOC_MUTEX_UNLOCK
for (int i = 0; i < service_ctx.number; i++)
{
if (((*service_filter) >> i) & 0x01)
Expand Down
8 changes: 4 additions & 4 deletions examples/projects/native/gate_wscom/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ int main(void)
Pipe_Init();
Gate_Init();
// Create a thread to convert messages into Json and steam them using Websocket
// pthread_t thread_id;
// pthread_create(&thread_id, NULL, Gate_Pipe_LoopThread, NULL);
pthread_t thread_id;
pthread_create(&thread_id, NULL, Gate_Pipe_LoopThread, NULL);
while (1)
{
Luos_Loop();
Expand All @@ -65,7 +65,7 @@ int main(void)
#else
Ws_Loop();
#endif
Pipe_Loop();
Gate_Loop();
// Pipe_Loop();
// Gate_Loop();
}
}

0 comments on commit 3bb80a4

Please sign in to comment.