diff options
| author | ChenRuiwei <[email protected]> | 2025-07-07 14:35:05 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2025-07-25 15:35:39 +0800 |
| commit | f9564d4ee0d9105ca52245d38e6a7ffaea4d7fb9 (patch) | |
| tree | 45f051d87e1b127b7b373b10b3c838bee9527d65 /components | |
| parent | d23006ea4ff0c5d2619775221d7bf9630b3d19e1 (diff) | |
[pthreads] Fix pthread_cond_timedwait lacks timeout wakeup
Diffstat (limited to 'components')
| -rw-r--r-- | components/libc/posix/pthreads/pthread_cond.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/components/libc/posix/pthreads/pthread_cond.c b/components/libc/posix/pthreads/pthread_cond.c index 1241ef835d..caedec7601 100644 --- a/components/libc/posix/pthreads/pthread_cond.c +++ b/components/libc/posix/pthreads/pthread_cond.c @@ -367,30 +367,27 @@ rt_err_t _pthread_cond_timedwait(pthread_cond_t *cond, } { - register rt_base_t temp; struct rt_thread *thread; /* parameter check */ RT_ASSERT(sem != RT_NULL); RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore); - /* disable interrupt */ - temp = rt_hw_interrupt_disable(); + rt_enter_critical(); if (sem->value > 0) { /* semaphore is available */ sem->value--; - /* enable interrupt */ - rt_hw_interrupt_enable(temp); + rt_exit_critical(); } else { /* no waiting, return with timeout */ if (time == 0) { - rt_hw_interrupt_enable(temp); + rt_exit_critical(); return -RT_ETIMEOUT; } @@ -434,11 +431,8 @@ rt_err_t _pthread_cond_timedwait(pthread_cond_t *cond, return -RT_ERROR; } - /* enable interrupt */ - rt_hw_interrupt_enable(temp); - - /* do schedule */ - rt_schedule(); + /* exit critical and do schedule */ + rt_exit_critical(); result = thread->error; |
