* @brief This function will resume a thread and put it to system ready queue. * * @param thread Handle of the thread to be resumed. * * @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. */
| 1087 | * If the return value is any other values, it means this operation failed. |
| 1088 | */ |
| 1089 | rt_err_t rt_thread_resume(rt_thread_t thread) |
| 1090 | { |
| 1091 | rt_sched_lock_level_t slvl; |
| 1092 | rt_err_t error; |
| 1093 | |
| 1094 | /* parameter check */ |
| 1095 | RT_ASSERT(thread != RT_NULL); |
| 1096 | RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); |
| 1097 | |
| 1098 | LOG_D("thread resume: %s", thread->parent.name); |
| 1099 | |
| 1100 | rt_sched_lock(&slvl); |
| 1101 | |
| 1102 | error = rt_sched_thread_ready(thread); |
| 1103 | |
| 1104 | if (!error) |
| 1105 | { |
| 1106 | error = rt_sched_unlock_n_resched(slvl); |
| 1107 | |
| 1108 | /** |
| 1109 | * RT_ESCHEDLOCKED indicates that the current thread is in a critical section, |
| 1110 | * rather than 'thread' can't be resumed. Therefore, we can ignore this error. |
| 1111 | */ |
| 1112 | if (error == -RT_ESCHEDLOCKED) |
| 1113 | { |
| 1114 | error = RT_EOK; |
| 1115 | } |
| 1116 | } |
| 1117 | else |
| 1118 | { |
| 1119 | rt_sched_unlock(slvl); |
| 1120 | } |
| 1121 | |
| 1122 | RT_OBJECT_HOOK_CALL(rt_thread_resume_hook, (thread)); |
| 1123 | |
| 1124 | return error; |
| 1125 | } |
| 1126 | RTM_EXPORT(rt_thread_resume); |
| 1127 | |
| 1128 | #ifdef RT_USING_SMART |