* @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
| 614 | * It performs a schedule after waking threads. |
| 615 | */ |
| 616 | static 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 |
no test coverage detected