* @brief Suspend a thread with timeout and add it to futex waiting list * * @param[in] thread Thread to suspend * @param[in] futex Futex to add thread to waiting list * @param[in] timeout Timeout value in ticks * * @return RT_EOK on success, error code on failure * * @note This function: * - Adds thread to futex's waiting_thread list (FIFO order) * - Sets thread timer with sp
| 438 | * - Sets errno to ETIMEDOUT on success |
| 439 | */ |
| 440 | static rt_err_t _suspend_thread_timeout_locked(rt_thread_t thread, |
| 441 | rt_futex_t futex, |
| 442 | rt_tick_t timeout) |
| 443 | { |
| 444 | rt_err_t rc; |
| 445 | |
| 446 | /** |
| 447 | * Brief: Add current thread into futex waiting thread list |
| 448 | * |
| 449 | * Note: Critical Section |
| 450 | * - the futex waiting_thread list (RW) |
| 451 | */ |
| 452 | rc = rt_thread_suspend_to_list(thread, &futex->waiting_thread, |
| 453 | RT_IPC_FLAG_FIFO, RT_INTERRUPTIBLE); |
| 454 | |
| 455 | if (rc == RT_EOK) |
| 456 | { |
| 457 | /* start the timer of thread */ |
| 458 | rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, |
| 459 | &timeout); |
| 460 | rt_timer_start(&(thread->thread_timer)); |
| 461 | rt_set_errno(ETIMEDOUT); |
| 462 | } |
| 463 | |
| 464 | return rc; |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * @brief Add current thread into futex waiting thread list |
no test coverage detected