axtask/
lib.rs

1//! [ArceOS](https://github.com/arceos-org/arceos) task management module.
2//!
3//! This module provides primitives for task management, including task
4//! creation, scheduling, sleeping, termination, etc. The scheduler algorithm
5//! is configurable by cargo features.
6//!
7//! # Cargo Features
8//!
9//! - `multitask`: Enable multi-task support. If it's enabled, complex task
10//!   management and scheduling is used, as well as more task-related APIs.
11//!   Otherwise, only a few APIs with naive implementation is available.
12//! - `irq`: Interrupts are enabled. If this feature is enabled, timer-based
13//!   APIs can be used, such as [`sleep`], [`sleep_until`], and
14//!   [`WaitQueue::wait_timeout`].
15//! - `preempt`: Enable preemptive scheduling.
16//! - `sched_fifo`: Use the [FIFO cooperative scheduler][1]. It also enables the
17//!   `multitask` feature if it is enabled. This feature is enabled by default,
18//!   and it can be overriden by other scheduler features.
19//! - `sched_rr`: Use the [Round-robin preemptive scheduler][2]. It also enables
20//!   the `multitask` and `preempt` features if it is enabled.
21//! - `sched_cfs`: Use the [Completely Fair Scheduler][3]. It also enables the
22//!   the `multitask` and `preempt` features if it is enabled.
23//!
24//! [1]: scheduler::FifoScheduler
25//! [2]: scheduler::RRScheduler
26//! [3]: scheduler::CFScheduler
27
28#![cfg_attr(not(test), no_std)]
29#![feature(doc_cfg)]
30#![feature(doc_auto_cfg)]
31#![feature(linkage)]
32
33#[cfg(test)]
34mod tests;
35
36cfg_if::cfg_if! {
37    if #[cfg(feature = "multitask")] {
38        #[macro_use]
39        extern crate log;
40        extern crate alloc;
41
42        #[macro_use]
43        mod run_queue;
44        mod task;
45        mod task_ext;
46        mod api;
47        mod wait_queue;
48
49        #[cfg(feature = "irq")]
50        mod timers;
51
52        #[doc(cfg(feature = "multitask"))]
53        pub use self::api::*;
54        pub use self::api::{sleep, sleep_until, yield_now};
55    } else {
56        mod api_s;
57        pub use self::api_s::{sleep, sleep_until, yield_now};
58    }
59}