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

Process-friendly sync primitives #45

Open
leostera opened this issue Jan 21, 2024 · 2 comments
Open

Process-friendly sync primitives #45

leostera opened this issue Jan 21, 2024 · 2 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@leostera
Copy link
Collaborator

leostera commented Jan 21, 2024

At the moment we use Atomic, Mutex, and Weak throughout the Riot runtime to do synchronization of work across the schedulers.

This style of programming doesn't play very well with Riot's process model, but it can be more straightforward to code in than synchronizing things via message-passing directly.

For example, in building a Hashmap that needs to lock, but should only really lock the current process, we can't use Mutex.protect – this would potentially lock the entire scheduler.

Shadowing Mutex with a version that is process-based would be ideal, to allow for a similar programming model and at the same time making it harder to accidentally lock an entire scheduler.

Implementation Notes

I'd probably start with making a Mutex be a small process, so creating a Mutex spawn_links it. Operations on top then are implemented as messages to/from that process. This ensures that a call to Mutex.lock actually becomes an interrupt point for the process.

Another good option here is a 'value Rw_lock.t type for making it possible to have multiple readers or a single writer to a value.

@julien-leclercq
Copy link
Contributor

Hello @leostera, may I give this one a try ?
I drafted a small genserver based implementation, I would need to round some corners but I think it matches quite nicely the description you made in the issue.

@leostera
Copy link
Collaborator Author

leostera commented Feb 5, 2024

Hi @julien-leclercq! Excited to see what you come up with ✨ Feel free to PR early and leave comments if you want my thoughts on anything :)

@leostera leostera added this to the riot/phase-2 milestone Mar 2, 2024
@leostera leostera removed this from the riot/phase-2 milestone Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants