ariel_os

Crate thread

Available on crate feature threading only.
Expand description

Multi-threading for Ariel OS.

Implements a scheduler based on fixed priorities and preemption. Within one priority level, threads are scheduled cooperatively. This means that there is no time slicing that would equally distribute CPU time among same-priority threads. Instead, you need to use yield_same() to explicitly yield to another thread with the same priority. If no thread is ready, the core is prompted to enter deep sleep until a next thread is ready.

Threads should be implemented using the ariel_os_macros::thread proc macro, which takes care of calling the necessary initialization methods and linking the thread function element it into the binary. A ThreadId between 0 and THREAD_COUNT is assigned to each thread in the order in which the threads are declared.

Optionally, the stacksize and a priority between 1 and SCHED_PRIO_LEVELS can be configured. By default, the stack size is 2048 bytes and priority is 1.

§Synchronization

The threading module supports three basic synchronization primitives:

  • Channel: synchronous (blocking) channel for sending data between threads
  • Lock: basic locking object
  • thread_flags: thread-flag implementation for signaling between threads

Modules§

Structs§

Constants§

Traits§

  • Trait for types that fit into a single register.

Functions§

  • Returns the id of the CPU that this thread is running on.
  • Low-level function to create a thread that runs func with arg.
  • Low-level function to create a thread without argument
  • Returns the ThreadId of the currently active thread.
  • Returns the priority of a thread.
  • Checks if a given ThreadId is valid.
  • Suspends/ pauses the current thread’s execution.
  • Changes the priority of a thread.
  • Wakes up a thread and adds it to the runqueue.
  • “Yields” to another thread with the same priority.