mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
On the Linux port, tasks are pthreads that cannot be forcibly paused; the scheduler "unschedules" a task only by selecting a different next task, and the outgoing task keeps running until it next blocks itself in event_wait (e.g. via vPortYield). If the scheduler later switches back into such a task (event_signal) before it ever parked in event_wait, that wake is never consumed and event_triggered stays latched. The task's next voluntary block then returns immediately instead of blocking (e.g. vTaskDelay(100ms) returning in 0ms), which desynchronizes kernel and port scheduling state. Clear the outgoing task's pending event when switching to a different task, under s_port_mutex and atomically with the scheduling decision. Any latched-but-unconsumed wake is stale at that point; a legitimate wake can only be delivered later, once the scheduler selects the task again as next_thread. Add event_clear() to the wait_for_event helper to support this. Verified: minimal repros (busy-wait with another ready task, and pthread-blocked task) now measure 92-101 ms for vTaskDelay(100ms) instead of 0 ms; linux_freertos kernel test app 18/18 pass; the previously failing esp_linenoise host test suite passes 34/34.