Skip to main content

ax_task/
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]: ax_sched::FifoScheduler
25//! [2]: ax_sched::RRScheduler
26//! [3]: ax_sched::CFScheduler
27
28#![cfg_attr(not(test), no_std)]
29#![cfg_attr(doc, feature(doc_cfg))]
30
31#[cfg(test)]
32mod tests;
33
34cfg_if::cfg_if! {
35    if #[cfg(feature = "multitask")] {
36        #[macro_use]
37        extern crate log;
38        extern crate alloc;
39
40        #[macro_use]
41        mod run_queue;
42        mod task;
43        mod api;
44        mod wait_queue;
45
46        #[cfg(feature = "irq")]
47        mod timers;
48
49        #[cfg(feature = "multitask")]
50        pub mod future;
51
52        #[cfg_attr(doc, 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}