@@ -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) ]
2535pub 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.
491501pub ( 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
0 commit comments