Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pbio/sys: Refactor status events to be handled synchronously #299

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

laurensvalk
Copy link
Member

@laurensvalk laurensvalk commented Mar 19, 2025

We never quite adopted events extensively across pbio. We only have a status set/clear handler in pbsys, with only one top level event listener at pbsys_hmi_handle_status_change. We can call it directly without casting the event data value to void * onto an event queue, and then back again. Given the limited case we had, this was harder to follow than we ultimately needed, and risked overflowing the event queue as stated in an old REVISIT that we can now address.

Doing this simplifies the introduction of #298 by ensuring we don't need any event queue at all.

@coveralls
Copy link

coveralls commented Mar 19, 2025

Coverage Status

coverage: 56.882% (+0.4%) from 56.477%
when pulling 6102eef on status
into 962e44b on master.

This refactors a few names without changing any code, setting the stage for the next commit where we update the sys background process.

We never quite adopted events across pbio, but only had a status set/clear handler in pbsys, with only one top level handler at pbsys_hmi_handle_status_change. Later, we can call it directly without casting the event data value to void * and back.
This was using broadcast, but there was ultimately only one receiver for this data. We can simplify this and avoid the risk of overrunning the event queue by calling it synchronously, which is safe for this event.

After the refactoring in the previous commit, this is now a trivial change.
@dlech
Copy link
Member

dlech commented Mar 23, 2025

I think this will be OK, but it likely needs more work. I'm pretty sure that we have some processes that are depending on these broadcast events to "wake up" the process when the status changes even if they aren't explicitly checking the event. The main one that comes to mind is Bluetooth/USB, e.g. when the user program stops or when we get a hub shutdown request. Basically, we need to audit everywhere pbsys_status_test() is called an make sure we still have something that is polling that process when the status changes.

@laurensvalk
Copy link
Member Author

Thanks for the review!

I think this will be OK, but it likely needs more work. I'm pretty sure that we have some processes that are depending on these broadcast events to "wake up" the process when the status changes even if they aren't explicitly checking the event.

This is one of those cases where #298 should really simplify things.

Where this code used to broadcast, it can call pbio_os_request_poll to achieve the same.

We can wait with this one until #298 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants