b9b615b425
pthread_cond_wait() should be an atomic operation in the mutex lock/unlock. Since the sched_lock() has been wrongly deleted in the previous commit, the context switch will occurred after the mutex was unlocked: -------------------------------------------------------------------- Task1(Priority 100) | Task2(Priority 101) | pthread_mutex_lock(mutex); | | | pthread_cond_wait(cond, mutex) | | | | | | | | ->enter_critical_section() | | ->pthread_mutex_give(mutex) | ----> pthread_mutex_lock(mutex); // contex switch to high priority task | | pthread_cond_signal(cond); // signal before wait | | <---- pthread_mutex_unlock(mutex); // switch back to original task | ->pthread_sem_take(cond->sem)| // try to wait the signal, Deadlock. | ->leave_critical_section() | | | ->pthread_mutex_take(mutex) | | | pthread_mutex_lock(mutex); | --------------------------------------------------------------------- This PR will bring back sched_lock()/sched_unlock() to avoid context switch to ensure atomicity Signed-off-by: chao an <anchao@xiaomi.com> |
||
---|---|---|
.. | ||
Make.defs | ||
pthread_barrierwait.c | ||
pthread_cancel.c | ||
pthread_completejoin.c | ||
pthread_condbroadcast.c | ||
pthread_condclockwait.c | ||
pthread_condsignal.c | ||
pthread_condwait.c | ||
pthread_create.c | ||
pthread_detach.c | ||
pthread_exit.c | ||
pthread_findjoininfo.c | ||
pthread_getaffinity.c | ||
pthread_getschedparam.c | ||
pthread_initialize.c | ||
pthread_join.c | ||
pthread_mutex.c | ||
pthread_mutexconsistent.c | ||
pthread_mutexdestroy.c | ||
pthread_mutexinconsistent.c | ||
pthread_mutexinit.c | ||
pthread_mutextimedlock.c | ||
pthread_mutextrylock.c | ||
pthread_mutexunlock.c | ||
pthread_release.c | ||
pthread_setaffinity.c | ||
pthread_setschedparam.c | ||
pthread_setschedprio.c | ||
pthread_sigmask.c | ||
pthread.h |