8000 zephyr: Convert port to use new event waiting functions. by dpgeorge · Pull Request #18685 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@dpgeorge
Copy link
Member

Summary

This PR converts the zephyr port to use the new event waiting mechanism, with the MICROPY_INTERNAL_WFE macro.

As part of this, the mp_hal_wait_sem() function is updated so it can exit early when an event occurs. That allows it to be used by MICROPY_INTERNAL_WFE to implement efficient waiting, so calls like mp_event_wait_indefinite() will actually suspend the thread until an event wakes it.

Testing

Tested on frdm_k64f, running the full test suite. There were no regressions. Note that the new event logic in machine_uart.c is tested by tests/extmod/machine_uart_tx.py (by using a custom target_wiring.py file).

Trade-offs and Alternatives

When threading is enabled mp_hal_wait_sem() does not work correctly due to global state. But that's the topic of a separate PR #17866.

A new argument is added to this function to select whether it exits early
when signalled via `mp_hal_signal_event()`, so it can be used to wait for
general events (rather than just a specific semaphore).

And rename this function to `mp_hal_wait_event()` to better match its new
semantics.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge
Copy link
Member Author

Converting to draft until I can fix the CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0