* @brief This function will start a thread and put it to system ready queue. * * @param thread Handle of the thread to be started. * * @return Return the operation status. If the return value is `RT_EOK`, the * function is successfully executed. * If the return value is any other values, it means this operation failed. */
| 404 | * If the return value is any other values, it means this operation failed. |
| 405 | */ |
| 406 | rt_err_t rt_thread_startup(rt_thread_t thread) |
| 407 | { |
| 408 | /* parameter check */ |
| 409 | RT_ASSERT(thread != RT_NULL); |
| 410 | RT_ASSERT((RT_SCHED_CTX(thread).stat & RT_THREAD_STAT_MASK) == RT_THREAD_INIT); |
| 411 | RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); |
| 412 | |
| 413 | LOG_D("startup a thread:%s with priority:%d", |
| 414 | thread->parent.name, RT_SCHED_PRIV(thread).current_priority); |
| 415 | |
| 416 | /* calculate priority attribute and reset thread stat to suspend */ |
| 417 | rt_sched_thread_startup(thread); |
| 418 | |
| 419 | /* resume and do a schedule if scheduler is available */ |
| 420 | rt_thread_resume(thread); |
| 421 | |
| 422 | return RT_EOK; |
| 423 | } |
| 424 | RTM_EXPORT(rt_thread_startup); |
| 425 | |
| 426 | /** |