Skip to content

Commit 1af34cd

Browse files
committed
doc(kernel): use the definite article when referring to a specific task state
1 parent d7d8dd5 commit 1af34cd

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

src/constance/src/kernel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub trait Kernel: Port + KernelCfg2 + Sized + 'static {
8585
/// [Priority Boost]: crate#system-states
8686
fn is_priority_boost_active() -> bool;
8787

88-
/// Terminate the current task, putting it into a Dormant state.
88+
/// Terminate the current task, putting it into the Dormant state.
8989
///
9090
/// The kernel (to be precise, the port) makes an implicit call to this
9191
/// function when a task entry point function returns.
@@ -100,9 +100,9 @@ pub trait Kernel: Port + KernelCfg2 + Sized + 'static {
100100
///
101101
unsafe fn exit_task() -> Result<!, ExitTaskError>;
102102

103-
/// Put the current task into a Waiting state until the task's token is made
104-
/// available by [`Task::unpark`]. The token is initially absent when the
105-
/// task is activated.
103+
/// Put the current task into the Waiting state until the task's token is
104+
/// made available by [`Task::unpark`]. The token is initially absent when
105+
/// the task is activated.
106106
///
107107
/// The token will be consumed when this method returns successfully.
108108
///

src/constance/src/kernel/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ define_error! {
158158
BadId,
159159
/// CPU Lock is active.
160160
BadContext,
161-
/// The task is already active (not in a Dormant state).
161+
/// The task is already active (not in the Dormant state).
162162
///
163163
/// This error code originates from `E_QOVR` defined in the μITRON 4.0
164164
/// specification. In this specification, the `act_tsk` (activate task)
@@ -190,7 +190,7 @@ define_error! {
190190
BadId,
191191
/// CPU Lock is active.
192192
BadContext,
193-
/// The task is not in a Waiting state.
193+
/// The task is not in the Waiting state.
194194
BadObjectState,
195195
}
196196
}
@@ -261,7 +261,7 @@ define_error! {
261261
BadContext,
262262
/// The task ID is out of range.
263263
BadId,
264-
/// The task is in a Dormant state.
264+
/// The task is in the Dormant state.
265265
BadObjectState,
266266
}
267267
}
@@ -277,7 +277,7 @@ define_error! {
277277
BadId,
278278
/// The task already has a token.
279279
QueueOverflow,
280-
/// The task is in a Dormant state.
280+
/// The task is in the Dormant state.
281281
BadObjectState,
282282
}
283283
}

src/constance/src/kernel/task.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ use crate::utils::{
2020
///
2121
/// > **Relation to Other Specifications:** Present in almost every real-time
2222
/// > operating system.
23+
///
24+
/// # Task States
25+
///
26+
/// A task may be in one of the following states:
27+
///
28+
/// - **Dormant**
29+
/// - **Ready**
30+
/// - **Running**
31+
/// - **Waiting**
32+
///
2333
#[doc(include = "../common.md")]
2434
#[repr(transparent)]
2535
pub struct Task<System>(Id, PhantomData<System>);
@@ -82,7 +92,7 @@ impl<System: Kernel> Task<System> {
8292
/// Get the current task.
8393
///
8494
/// In a task context, this method returns the currently running task. In an
85-
/// interrupt handler, this method returns the interrupted task (if any).
95+
/// interrupt context, this method returns the interrupted task (if any).
8696
pub fn current() -> Result<Option<Self>, GetCurrentTaskError> {
8797
let _lock = utils::lock_cpu::<System>()?;
8898
let task_cb = if let Some(cb) = System::state().running_task() {
@@ -391,7 +401,7 @@ pub(super) fn init_task<System: Kernel>(
391401
// `PendingActivation` is equivalent to `Dormant` but serves as a marker
392402
// indicating tasks that should be activated by `init_task`.
393403

394-
// Safety: CPU Lock active, the task is (essentially) in a Dormant state
404+
// Safety: CPU Lock active, the task is (essentially) in the Dormant state
395405
unsafe { System::initialize_task_state(task_cb) };
396406

397407
// Safety: The previous state is PendingActivation (which is equivalent
@@ -447,7 +457,7 @@ fn activate<System: Kernel>(
447457
// Discard a park token if the task has one
448458
task_cb.park_token.replace(&mut *lock, false);
449459

450-
// Safety: CPU Lock active, the task is in a Dormant state
460+
// Safety: CPU Lock active, the task is in the Dormant state
451461
unsafe { System::initialize_task_state(task_cb) };
452462

453463
// Safety: The previous state is Dormant, and we just initialized the task
@@ -486,7 +496,7 @@ pub(super) unsafe fn make_ready<System: Kernel>(
486496
/// Relinquish CPU Lock. After that, if there's a higher-priority task than
487497
/// `running_task`, call `Port::yield_cpu`.
488498
///
489-
/// System services that transition a task into a Ready state should call
499+
/// System services that transition a task into the Ready state should call
490500
/// this before returning to the caller.
491501
pub(super) fn unlock_cpu_and_check_preemption<System: Kernel>(lock: utils::CpuLockGuard<System>) {
492502
// If Priority Boost is active, treat the currently running task as the
@@ -585,7 +595,7 @@ pub(super) fn choose_next_running_task<System: Kernel>(
585595
None
586596
};
587597

588-
// If `prev_running_task` is in a Running state, transition it into Ready
598+
// If `prev_running_task` is in the Running state, transition it into Ready
589599
if let Some(running_task) = prev_running_task {
590600
match running_task.st.read(&*lock) {
591601
TaskSt::Running => {
@@ -672,7 +682,7 @@ fn unpark_exact<System: Kernel>(
672682
};
673683

674684
if is_parked {
675-
// Unblock the task. We confirmed that the task is in a Waiting state,
685+
// Unblock the task. We confirmed that the task is in the Waiting state,
676686
// so `interrupt_task` should succeed.
677687
wait::interrupt_task(lock.borrow_mut(), task_cb, Ok(())).unwrap();
678688

src/constance/src/kernel/wait.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub enum QueueOrder {
156156
/// The wait state of a task.
157157
pub(crate) struct TaskWait<System: Port> {
158158
/// The wait object describing the ongoing Waiting state of the task. Should
159-
/// be `None` iff the task is not in a Waiting state.
159+
/// be `None` iff the task is not in the Waiting state.
160160
///
161161
/// The pointee must be valid.
162162
current_wait: CpuLockCell<System, Option<WaitRef<System>>>,
@@ -185,7 +185,7 @@ impl<System: Port> WaitQueue<System> {
185185

186186
impl<System: Kernel> WaitQueue<System> {
187187
/// Insert a wait object pertaining to the currently running task to `self`,
188-
/// transitioning the task into a Waiting state.
188+
/// transitioning the task into the Waiting state.
189189
///
190190
/// The current context must be [waitable] (This function doesn't check
191191
/// that). The caller should use `expect_waitable_context` to do that.
@@ -463,7 +463,7 @@ fn complete_wait<System: Kernel>(
463463

464464
// Make the task Ready
465465
//
466-
// Safety: The task is in a Waiting state, meaning the task state is valid
466+
// Safety: The task is in the Waiting state, meaning the task state is valid
467467
// and ready to resume from the point where it was previously interrupted.
468468
// A proper clean up for exiting the Waiting state is already done as well.
469469
unsafe { task::make_ready(lock, task_cb) };
@@ -474,7 +474,7 @@ fn complete_wait<System: Kernel>(
474474
/// This method may make the task Ready, but doesn't yield the processor.
475475
/// Call `unlock_cpu_and_check_preemption` as needed.
476476
///
477-
/// Returns `Err(BadObjectState)` if the task is not in a Waiting state.
477+
/// Returns `Err(BadObjectState)` if the task is not in the Waiting state.
478478
pub(super) fn interrupt_task<System: Kernel>(
479479
mut lock: CpuLockGuardBorrowMut<'_, System>,
480480
task_cb: &'static TaskCb<System>,
@@ -485,7 +485,7 @@ pub(super) fn interrupt_task<System: Kernel>(
485485
// Interrupt the ongoing wait operation.
486486
let wait_ref = task_cb.wait.current_wait.get(&*lock);
487487

488-
// The task is in a Waiting state, so `wait_ref` must be `Some(_)`
488+
// The task is in the Waiting state, so `wait_ref` must be `Some(_)`
489489
let wait_ref = wait_ref.unwrap();
490490

491491
// Safety: ... and `wait_ref` must point to an existing `Wait`

0 commit comments

Comments
 (0)