diff options
| author | ari.liu <[email protected]> | 2026-08-21 11:16:10 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2026-08-21 16:52:01 +0800 |
| commit | ba79f69477686196da1aa1aca3792e8f6c4e3085 (patch) | |
| tree | 4f1de264b2f2a123013cc757bd6bcad139158680 /src/ipc.c | |
| parent | 5ae08713c8b409aef8ba1d887c3f228566537909 (diff) | |
[kernel][ipc] Fix timeout wakeup ownership race
Keep thread timer ownership when timer stop races with an in-flight timeout callback, and consume IPC resources only after a waiter is resumed successfully.
Complete ownership cleanup in the generic and RT-Smart channel timeout callbacks. Add deterministic scheduler and LWP regressions for Event, Semaphore, Mailbox, Message Queue, sender, and receiver paths.
Diffstat (limited to 'src/ipc.c')
| -rw-r--r-- | src/ipc.c | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -140,7 +140,10 @@ struct rt_thread *rt_susp_list_dequeue(rt_list_t *susp_list, rt_err_t thread_err } rt_sched_unlock(slvl); - LOG_D("resume thread:%s\n", thread->parent.name); + if (thread) + { + LOG_D("resume thread:%s\n", thread->parent.name); + } return thread; } @@ -713,10 +716,9 @@ rt_err_t rt_sem_release(rt_sem_t sem) sem->parent.parent.name, sem->value); - if (!rt_list_isempty(&sem->parent.suspend_thread)) + if (!rt_list_isempty(&sem->parent.suspend_thread) && + rt_susp_list_dequeue(&(sem->parent.suspend_thread), RT_EOK) != RT_NULL) { - /* resume the suspended thread */ - rt_susp_list_dequeue(&(sem->parent.suspend_thread), RT_EOK); need_schedule = RT_TRUE; } else @@ -2053,16 +2055,20 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set) /* condition is satisfied, resume thread */ if (status == RT_EOK) { - /* clear event */ - if (thread->event_info & RT_EVENT_FLAG_CLEAR) - need_clear_set |= thread->event_set; + status = rt_sched_thread_ready(thread); + if (status == RT_EOK) + { + /* clear event */ + if (thread->event_info & RT_EVENT_FLAG_CLEAR) + { + need_clear_set |= thread->event_set; + } - /* resume thread, and thread list breaks out */ - rt_sched_thread_ready(thread); - thread->error = RT_EOK; + thread->error = RT_EOK; - /* need do a scheduling */ - need_schedule = RT_TRUE; + /* need do a scheduling */ + need_schedule = RT_TRUE; + } } } if (need_clear_set) |
