1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-14 17:13:50 +01:00
Mikolai Gütschow 223031e0d6
treewide: update riot-wrappers and riot-sys
diff generated with `find -name Cargo.toml -exec cargo update --manifest-path "{}" --package riot-wrappers --package riot-sys ";"` according to https://github.com/RIOT-OS/RIOT/blob/master/doc/guides/managing-a-release/README.md?plain=1#L31

upcoming release version bump similar to https://github.com/RIOT-OS/RIOT/pull/21133
2025-04-08 14:29:46 +02:00
..
2025-02-21 09:55:24 +01:00
2025-02-21 23:52:11 +01:00
2025-02-21 09:55:24 +01:00

Rust: Asynchronous programming

This is an example of how asynchronous Rust applications can be written on RIOT OS.

The application starts an embassy based executor, and then spawn several tasks on the main thread. Unlike RIOT OS threads, these tasks can not preempt each other; they relinquish control of the main thread when performing an asynchronous operation that would block, and are paused by anything that preempts the main thread.

Behind the scenes, the Rust compiler turns the asynchronous methods into state machines, and the executor polls the state machines to make progress whenever an event wakes them up.

Upsides of this style of programming are that there is less need for synchronization (for individual tasks or their parts can rely on the work they do synchronously not to be executed concurrently with other tasks if so configured), and that they can share a single stack space. State that is persisted across await points is not stored on the stack, but in adequately sized static memory for each task that can run.