8000 Process-friendly sync primitives · Issue #45 · riot-ml/riot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Process-friendly sync primitives #45
Open
@leostera

Description

@leostera

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0