@@ -20,6 +20,16 @@ use crate::utils::{
20
20
///
21
21
/// > **Relation to Other Specifications:** Present in almost every real-time
22
22
/// > 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
+ ///
23
33
#[ doc( include = "../common.md" ) ]
24
34
#[ repr( transparent) ]
25
35
pub struct Task < System > ( Id , PhantomData < System > ) ;
@@ -82,7 +92,7 @@ impl<System: Kernel> Task<System> {
82
92
/// Get the current task.
83
93
///
84
94
/// 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).
86
96
pub fn current ( ) -> Result < Option < Self > , GetCurrentTaskError > {
87
97
let _lock = utils:: lock_cpu :: < System > ( ) ?;
88
98
let task_cb = if let Some ( cb) = System :: state ( ) . running_task ( ) {
@@ -391,7 +401,7 @@ pub(super) fn init_task<System: Kernel>(
391
401
// `PendingActivation` is equivalent to `Dormant` but serves as a marker
392
402
// indicating tasks that should be activated by `init_task`.
393
403
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
395
405
unsafe { System :: initialize_task_state ( task_cb) } ;
396
406
397
407
// Safety: The previous state is PendingActivation (which is equivalent
@@ -447,7 +457,7 @@ fn activate<System: Kernel>(
447
457
// Discard a park token if the task has one
448
458
task_cb. park_token . replace ( & mut * lock, false ) ;
449
459
450
- // Safety: CPU Lock active, the task is in a Dormant state
460
+ // Safety: CPU Lock active, the task is in the Dormant state
451
461
unsafe { System :: initialize_task_state ( task_cb) } ;
452
462
453
463
// Safety: The previous state is Dormant, and we just initialized the task
@@ -486,7 +496,7 @@ pub(super) unsafe fn make_ready<System: Kernel>(
486
496
/// Relinquish CPU Lock. After that, if there's a higher-priority task than
487
497
/// `running_task`, call `Port::yield_cpu`.
488
498
///
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
490
500
/// this before returning to the caller.
491
501
pub ( super ) fn unlock_cpu_and_check_preemption < System : Kernel > ( lock : utils:: CpuLockGuard < System > ) {
492
502
// 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>(
585
595
None
586
596
} ;
587
597
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
589
599
if let Some ( running_task) = prev_running_task {
590
600
match running_task. st . read ( & * lock) {
591
601
TaskSt :: Running => {
@@ -672,7 +682,7 @@ fn unpark_exact<System: Kernel>(
672
682
} ;
673
683
674
684
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,
676
686
// so `interrupt_task` should succeed.
677
687
wait:: interrupt_task ( lock. borrow_mut ( ) , task_cb, Ok ( ( ) ) ) . unwrap ( ) ;
678
688
0 commit comments