* @brief Waits on a condition variable. * * This function blocks the calling thread on the condition variable `cond` and releases * the associated mutex `mutex`. The thread remains blocked until it is signaled or * broadcast using `pthread_cond_signal` or `pthread_cond_broadcast`. When the thread * is awakened, it re-acquires the mutex and resumes execution. * * @param cond A pointer to the
| 475 | * @see pthread_cond_signal, pthread_cond_broadcast, pthread_cond_timedwait, pthread_mutex_lock |
| 476 | */ |
| 477 | int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) |
| 478 | { |
| 479 | rt_err_t result; |
| 480 | |
| 481 | __retry: |
| 482 | result = _pthread_cond_timedwait(cond, mutex, RT_WAITING_FOREVER); |
| 483 | if (result == RT_EOK) |
| 484 | { |
| 485 | return 0; |
| 486 | } |
| 487 | else if (result == -RT_EINTR) |
| 488 | { |
| 489 | /* https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_wait.html |
| 490 | * These functions shall not return an error code of [EINTR]. |
| 491 | */ |
| 492 | goto __retry; |
| 493 | } |
| 494 | |
| 495 | return EINVAL; |
| 496 | } |
| 497 | RTM_EXPORT(pthread_cond_wait); |
| 498 | |
| 499 | /** |
no test coverage detected