Skip to main content

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