walnux/sched/pthread
Ville Juven bb85ad849e pthread_cond_wait: Use atomic_t to protect the waiter count
The load/compare and RMW to wait_count need protection. Using atomic
operations should resolve both issues.

NOTE:
The assumption that the user will call pthread_cond_signal /
pthread_cond_broadcast with the mutex given to pthread_cond_wait held is
simply not true. It MAY hold it, but it is not forced. Thus, using the
user space lock for protecting the wait counter as well is not valid!

The pthread_cond_signal() or pthread_cond_broadcast() functions may be called by a thread whether or not it currently owns the mutex that threads calling pthread_cond_wait() or pthread_cond_timedwait() have associated with the condition variable during their waits; however, if predictable scheduling behaviour is required, then that mutex is locked by the thread calling pthread_cond_signal() or pthread_cond_broadcast().

[1] https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_cond_signal.html
2025-01-20 23:55:26 +08:00
..
CMakeLists.txt pthread: remove enter_critical_section in pthread_mutex 2025-01-12 22:30:35 +08:00
Make.defs pthread: remove enter_critical_section in pthread_mutex 2025-01-12 22:30:35 +08:00
pthread.h pthread_cond_wait: Use atomic_t to protect the waiter count 2025-01-20 23:55:26 +08:00
pthread_cancel.c pthread_cleanup: move clenup down to tls 2024-09-14 20:15:12 +08:00
pthread_completejoin.c group: use tg_mutex to replace tg_joinlock 2025-01-19 17:08:32 +08:00
pthread_condbroadcast.c pthread_cond_wait: Use atomic_t to protect the waiter count 2025-01-20 23:55:26 +08:00
pthread_condclockwait.c pthread_cond_wait: Use atomic_t to protect the waiter count 2025-01-20 23:55:26 +08:00
pthread_condsignal.c pthread_cond_wait: Use atomic_t to protect the waiter count 2025-01-20 23:55:26 +08:00
pthread_condwait.c pthread_cond_wait: Use atomic_t to protect the waiter count 2025-01-20 23:55:26 +08:00
pthread_create.c pthread: remove enter_critical_section in pthread_mutex 2025-01-12 22:30:35 +08:00
pthread_detach.c group: use tg_mutex to replace tg_joinlock 2025-01-19 17:08:32 +08:00
pthread_exit.c sched: replace sync pause with async pause for nxtask_terminate 2024-10-06 09:26:56 +08:00
pthread_findjoininfo.c group: use tg_mutex to replace tg_joinlock 2025-01-19 17:08:32 +08:00
pthread_getaffinity.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
pthread_getschedparam.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
pthread_join.c group: use tg_mutex to replace tg_joinlock 2025-01-19 17:08:32 +08:00
pthread_mutex.c pthread: remove enter_critical_section in pthread_mutex 2025-01-12 22:30:35 +08:00
pthread_mutexconsistent.c sched/pthread: There is no need to use sched_[un]lock 2024-10-12 13:28:23 +08:00
pthread_mutexdestroy.c sched/pthread: There is no need to use sched_[un]lock 2024-10-12 13:28:23 +08:00
pthread_mutexinit.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
pthread_mutextimedlock.c pthread_mutx: remove unused critical_secton lock 2024-09-15 17:32:33 +08:00
pthread_mutextrylock.c sched/pthread: There is no need to use sched_[un]lock 2024-10-12 13:28:23 +08:00
pthread_mutexunlock.c pthread_mutx: remove unused critical_secton lock 2024-09-15 17:32:33 +08:00
pthread_release.c group: use tg_mutex to replace tg_joinlock 2025-01-19 17:08:32 +08:00
pthread_setaffinity.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
pthread_setschedparam.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
pthread_setschedprio.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
pthread_sigmask.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00