/** * @brief Initializes a thread structure. * @note This is an internal functions, do not use it in application code. * * @param[in] tp pointer to the thread * @param[in] name thread name * @param[in] prio the priority level for the new thread * @return The same thread pointer passed as parameter. * * @notapi */ thread_t *_thread_init(thread_t *tp, const char *name, tprio_t prio) { tp->prio = prio; #if CH_CFG_TIME_QUANTUM > 0 tp->preempt = (tslices_t)CH_CFG_TIME_QUANTUM; #endif #if CH_CFG_USE_MUTEXES == TRUE tp->realprio = prio; tp->mtxlist = NULL; #endif #if CH_CFG_USE_EVENTS == TRUE tp->epending = (eventmask_t)0; #endif #if CH_DBG_THREADS_PROFILING == TRUE tp->time = (systime_t)0; #endif #if CH_CFG_USE_REGISTRY == TRUE tp->name = name; REG_INSERT(tp); #endif #if CH_CFG_USE_WAITEXIT == TRUE list_init(&tp->waiting); #endif #if CH_CFG_USE_MESSAGES == TRUE queue_init(&tp->msgqueue); #endif #if CH_DBG_STATISTICS == TRUE chTMObjectInit(&tp->stats); #endif CH_CFG_THREAD_INIT_HOOK(tp); return tp; }
/** * @brief Initializes a thread structure. * @note This is an internal functions, do not use it in application code. * * @param[in] tp pointer to the thread * @param[in] prio the priority level for the new thread * @return The same thread pointer passed as parameter. * * @notapi */ Thread *_thread_init(Thread *tp, tprio_t prio) { tp->p_prio = prio; tp->p_state = THD_STATE_SUSPENDED; tp->p_flags = THD_MEM_MODE_STATIC; #if CH_USE_MUTEXES tp->p_realprio = prio; tp->p_mtxlist = NULL; #endif #if CH_USE_EVENTS tp->p_epending = 0; #endif #if CH_USE_NESTED_LOCKS tp->p_locks = 0; #endif #if CH_DBG_THREADS_PROFILING tp->p_time = 0; #endif #if CH_USE_DYNAMIC tp->p_refs = 1; #endif #if CH_USE_WAITEXIT list_init(&tp->p_waiting); #endif #if CH_USE_MESSAGES queue_init(&tp->p_msgqueue); #endif #if CH_USE_REGISTRY REG_INSERT(tp); #endif #if defined(THREAD_EXT_INIT_HOOK) THREAD_EXT_INIT_HOOK(tp); #endif return tp; }
/** * @brief Initializes a thread structure. * @note This is an internal functions, do not use it in application code. * * @param[in] tp pointer to the thread * @param[in] prio the priority level for the new thread * @return The same thread pointer passed as parameter. * * @notapi */ thread_t *_thread_init(thread_t *tp, tprio_t prio) { tp->p_prio = prio; tp->p_state = CH_STATE_WTSTART; tp->p_flags = CH_FLAG_MODE_STATIC; #if CH_CFG_TIME_QUANTUM > 0 tp->p_preempt = CH_CFG_TIME_QUANTUM; #endif #if CH_CFG_USE_MUTEXES tp->p_realprio = prio; tp->p_mtxlist = NULL; #endif #if CH_CFG_USE_EVENTS tp->p_epending = 0; #endif #if CH_DBG_THREADS_PROFILING tp->p_time = 0; #endif #if CH_CFG_USE_DYNAMIC tp->p_refs = 1; #endif #if CH_CFG_USE_REGISTRY tp->p_name = NULL; REG_INSERT(tp); #endif #if CH_CFG_USE_WAITEXIT list_init(&tp->p_waiting); #endif #if CH_CFG_USE_MESSAGES queue_init(&tp->p_msgqueue); #endif #if CH_DBG_ENABLE_STACK_CHECK tp->p_stklimit = (stkalign_t *)(tp + 1); #endif #if CH_DBG_STATISTICS || defined(__DOXYGEN__) chTMObjectInit(&tp->p_stats); chTMStartMeasurementX(&tp->p_stats); #endif #if defined(CH_CFG_THREAD_INIT_HOOK) CH_CFG_THREAD_INIT_HOOK(tp); #endif return tp; }
/** * @brief Initializes a thread structure. * @note This is an internal functions, do not use it in application code. * * @param[in] tp pointer to the thread * @param[in] prio the priority level for the new thread * @return The same thread pointer passed as parameter. * * @notapi */ Thread *_thread_init(Thread *tp, tprio_t prio) { tp->p_prio = prio; tp->p_state = THD_STATE_SUSPENDED; tp->p_flags = THD_MEM_MODE_STATIC; #if CH_TIME_QUANTUM > 0 tp->p_preempt = CH_TIME_QUANTUM; #endif #if CH_USE_MUTEXES tp->p_realprio = prio; tp->p_mtxlist = NULL; #endif #if CH_USE_EVENTS tp->p_epending = 0; #endif #if CH_DBG_THREADS_PROFILING tp->p_time = 0; #endif #if CH_USE_DYNAMIC tp->p_refs = 1; #endif #if CH_USE_REGISTRY tp->p_name = NULL; REG_INSERT(tp); #endif #if CH_USE_WAITEXIT list_init(&tp->p_waiting); #endif #if CH_USE_MESSAGES queue_init(&tp->p_msgqueue); #endif #if CH_DBG_ENABLE_STACK_CHECK tp->p_stklimit = (stkalign_t *)(tp + 1); #endif #if defined(THREAD_EXT_INIT_HOOK) THREAD_EXT_INIT_HOOK(tp); #endif return tp; }