Skip to content
Snippets Groups Projects
Commit e0dd35f0 authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo
Browse files

Use threadCreate to start task_manager threads.

This fixes the issue where running without sudo would cause threads to not start.
parent c68ab1be
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !3025. Comments created here will be created in the context of that merge request.
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <unistd.h> #include <unistd.h>
#include <ctype.h> // toupper #include <ctype.h> // toupper
#include "system.h"
// #define POLL_AND_SLEEP // #define POLL_AND_SLEEP
...@@ -511,30 +512,9 @@ void init_ws_task_manager(ws_task_manager_t* man, int* core_id, size_t num_threa ...@@ -511,30 +512,9 @@ void init_ws_task_manager(ws_task_manager_t* man, int* core_id, size_t num_threa
args->idx = i; args->idx = i;
args->man = man; args->man = man;
args->core_id = core_id[i]; args->core_id = core_id[i];
pthread_attr_t attr = {0};
int ret = pthread_attr_init(&attr);
DevAssert(ret == 0);
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
DevAssert(ret == 0);
ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
DevAssert(ret == 0);
struct sched_param sparam = {0};
sparam.sched_priority = 97;
ret = pthread_attr_setschedparam(&attr, &sparam);
int rc = pthread_create(&man->t_arr[i], &attr, worker_thread, args);
if (rc != 0) {
printf("[TASK_MAN]: %s \n", strerror(rc));
printf("[TASK_MAN]: Could not create the pthread with attributtes, trying without attributes\n");
rc = pthread_create(&man->t_arr[i], NULL, worker_thread, args);
AssertFatal(rc == 0, "Error creating a thread");
}
char name[64]; char name[64];
sprintf(name, "Tpool%ld_%d", i, core_id[i]); sprintf(name, "Tpool%ld_%d", i, core_id[i]);
pthread_setname_np(man->t_arr[i], name); threadCreate(&man->t_arr[i], worker_thread, args, name, args->core_id, OAI_PRIORITY_RT_MAX);
} }
// Syncronize thread pool threads. All the threads started // Syncronize thread pool threads. All the threads started
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment