MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_susp_list_enqueue

Function rt_susp_list_enqueue

src/ipc.c:241–285  ·  view source on GitHub ↗

* @brief Add a thread to the suspend list * * @note Caller must hold the scheduler lock * * @param susp_list the list thread enqueued to * @param thread the suspended thread * @param ipc_flags the pattern of suspend list * @return RT_EOK on succeed, otherwise a failure */

Source from the content-addressed store, hash-verified

239 * @return RT_EOK on succeed, otherwise a failure
240 */
241rt_err_t rt_susp_list_enqueue(rt_list_t *susp_list, rt_thread_t thread, int ipc_flags)
242{
243 RT_SCHED_DEBUG_IS_LOCKED;
244
245 switch (ipc_flags)
246 {
247 case RT_IPC_FLAG_FIFO:
248 rt_list_insert_before(susp_list, &RT_THREAD_LIST_NODE(thread));
249 break; /* RT_IPC_FLAG_FIFO */
250
251 case RT_IPC_FLAG_PRIO:
252 {
253 struct rt_list_node *n;
254 struct rt_thread *sthread;
255
256 /* find a suitable position */
257 for (n = susp_list->next; n != susp_list; n = n->next)
258 {
259 sthread = RT_THREAD_LIST_NODE_ENTRY(n);
260
261 /* find out */
262 if (rt_sched_thread_get_curr_prio(thread) < rt_sched_thread_get_curr_prio(sthread))
263 {
264 /* insert this thread before the sthread */
265 rt_list_insert_before(&RT_THREAD_LIST_NODE(sthread), &RT_THREAD_LIST_NODE(thread));
266 break;
267 }
268 }
269
270 /*
271 * not found a suitable position,
272 * append to the end of suspend_thread list
273 */
274 if (n == susp_list)
275 rt_list_insert_before(susp_list, &RT_THREAD_LIST_NODE(thread));
276 }
277 break;/* RT_IPC_FLAG_PRIO */
278
279 default:
280 RT_ASSERT(0);
281 break;
282 }
283
284 return RT_EOK;
285}
286
287/**
288 * @brief Print thread on suspend list to system console

Callers 2

_thread_update_priorityFunction · 0.85

Calls 2

rt_list_insert_beforeFunction · 0.85

Tested by

no test coverage detected