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

Function _futex_wake

components/lwp/lwp_futex.c:616–647  ·  view source on GitHub ↗

* @brief Wake up suspended threads from futex waiting list * * @param[in] futex The futex containing waiting threads * @param[in] lwp Lightweight process structure * @param[in] number Maximum number of threads to wake up * @param[in] op_flags Operation flags (e.g. FUTEX_PRIVATE) * * @return long Number of threads actually woken up * * @note The actual number of woken threads may be less t

Source from the content-addressed store, hash-verified

614 * It performs a schedule after waking threads.
615 */
616static long _futex_wake(rt_futex_t futex, struct rt_lwp *lwp, int number,
617 int op_flags)
618{
619 long woken_cnt = 0;
620 int is_empty = 0;
621
622 /**
623 * Brief: Wakeup a suspended thread on the futex waiting thread list
624 *
625 * Note: Critical Section
626 * - the futex waiting_thread list (RW)
627 */
628 while (number && !is_empty)
629 {
630 _futex_lock(lwp, op_flags);
631 if (rt_susp_list_dequeue(&futex->waiting_thread, RT_EOK))
632 {
633 number--;
634 woken_cnt++;
635 is_empty = RT_FALSE;
636 }
637 else
638 {
639 is_empty = RT_TRUE;
640 }
641 _futex_unlock(lwp, op_flags);
642 }
643
644 /* do schedule */
645 rt_schedule();
646 return woken_cnt;
647}
648
649/**
650 * @brief Requeue threads from one futex waiting list to another

Callers 2

lwp_futexFunction · 0.85
_handle_futex_deathFunction · 0.85

Calls 4

_futex_lockFunction · 0.85
rt_susp_list_dequeueFunction · 0.85
_futex_unlockFunction · 0.85
rt_scheduleFunction · 0.50

Tested by

no test coverage detected