46#if defined (__FreeRTOS__)
49 TaskHandle_t freeRTOSTask;
55void os_thread_start_entry_hook(
void)
59 PthreadObj *thread_handle =
static_cast<PthreadObj*
>(pthread_self());
60 HASSERT(thread_handle->freeRTOSTask == xTaskGetCurrentTaskHandle());
66void os_thread_start_exit_hook(
void *context)
68 pthread_exit(context);
78static void *os_thread_start_posix(
void *arg)
88int os_thread_create_helper(os_thread_t *thread,
const char *name,
int priority,
89 size_t stack_size,
void *priv)
94 int result = pthread_attr_init(&attr);
99 result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
105 result = pthread_attr_setstacksize(&attr, stack_size);
111 struct sched_param sched_param;
112 sched_param.sched_priority = priority;
113 result = pthread_attr_setschedparam(&attr, &sched_param);
120 result = pthread_create(&pthread, &attr, os_thread_start_posix, priv);
126#if defined (__FreeRTOS__)
129 *thread =
static_cast<PthreadObj*
>(pthread)->freeRTOSTask;
133 char *task_name =
static_cast<char*
>(pcTaskGetName(*thread));
134 strncpy(task_name, name, configMAX_TASK_NAME_LEN - 1);
135 task_name[configMAX_TASK_NAME_LEN - 1] =
'\0';
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.