lilos: A minimal async RTOS
This is a wee RTOS written to support the async style of programming in Rust.
It's a research project, a playground, and a proof of concept.
(lilos 1 was a wee RTOS written to
support multithreaded message-passing programs on AVR; this is technically
lilos 2 but who's counting.)
About
lilos is unusual for an RTOS:
async-based cooperative multitasking- No dynamic memory allocation
- Low memory consumption
- Applications can be written entirely in safe code
Concrete example: code to blink an LED on the STM32F407's pin D13. (Note that a
real application also needs a main, this just shows the one task.)
use Duration;
use sleep_for;
use GPIOD;
async !
For complete worked examples, see the examples directory, particularly:
examples/stm32f4/minimalis the simplest LED blinky program.examples/stm32f4/blinkyis a fancier blinky program.examples/stm32f4/uart_echodoes UART I/O across tasks with a queue.
If you'd like to read about this at length, see the technical report.
Features
By default, lilos includes the core OS and some useful data structures for
inter-task communication. You can turn those off with --no-default-features
and go a la carte:
mutexenables thelilos::mutexmodule.spscenables thelilos::spscmodule.
Toolchain version
As of 0.3.0, lilos builds on stable Rust. Previously, lilos required the
nightly toolchain to get access to the never
type, which is necessary
to write the type of a future that loops forever, Future<Output = !>. When I
initially published lilos in 2019 this looked like it would stabilize in the
near future; however, true to its name, it's never made it.
And so in the interest of compatibility with stable, lilos uses
core::convert::Infallible in place of !. So, your task functions need to be
written as
async
...instead of -> !.
Contact and License
If you have questions, or you use it for something, I'd love to find out! Send me an email.
I'm experimenting with using the MPL-2 for subversive reasons. I'm open to relicensing this code if MPL-2 doesn't work for your organization, we'll just need to discuss your labor practices. ;-)