* @brief This function is the timeout function for thread, normally which is invoked * when thread is timeout to wait some resource. * * @param parameter is the parameter of thread timeout function */
| 144 | * @param parameter is the parameter of thread timeout function |
| 145 | */ |
| 146 | static void _thread_timeout(void *parameter) |
| 147 | { |
| 148 | struct rt_thread *thread; |
| 149 | rt_sched_lock_level_t slvl; |
| 150 | |
| 151 | thread = (struct rt_thread *)parameter; |
| 152 | |
| 153 | /* parameter check */ |
| 154 | RT_ASSERT(thread != RT_NULL); |
| 155 | RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); |
| 156 | |
| 157 | rt_sched_lock(&slvl); |
| 158 | |
| 159 | /** |
| 160 | * resume of the thread and stop of the thread timer should be an atomic |
| 161 | * operation. So we don't expected that thread had resumed. |
| 162 | */ |
| 163 | RT_ASSERT(rt_sched_thread_is_suspended(thread)); |
| 164 | |
| 165 | /* set error number */ |
| 166 | thread->error = -RT_ETIMEOUT; |
| 167 | |
| 168 | /* remove from suspend list */ |
| 169 | rt_list_remove(&RT_THREAD_LIST_NODE(thread)); |
| 170 | /* insert to schedule ready list */ |
| 171 | rt_sched_insert_thread(thread); |
| 172 | /* do schedule and release the scheduler lock */ |
| 173 | rt_sched_unlock_n_resched(slvl); |
| 174 | } |
| 175 | |
| 176 | static rt_err_t _thread_init(struct rt_thread *thread, |
| 177 | const char *name, |
nothing calls this directly
no test coverage detected