Skip to content
Commit d83c63ec authored by Marco Widmer's avatar Marco Widmer Committed by Fabio Baltieri
Browse files

pm: runtime: fix race when waiting for suspended event



To wait for the asynchronous suspending work item to complete, a
combination of semaphores and events is used. First, the semaphore is
released, then the events are cleared (through the boolean argument to
k_event_wait), then events are awaited.

However, if the event flag happens to be set by the work handler in the
short time between k_sem_give and k_event_wait, it is then cleared by
k_event_wait and k_event_wait blocks forever waiting for the event.

Make sure that we clear the event flag before releasing the semaphore.

Signed-off-by: default avatarMarco Widmer <marco.widmer@bytesatwork.ch>
parent 3102fdc8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment