diff --git a/src/task/current.rs b/src/task/current.rs index 22dedb4..5783a31 100644 --- a/src/task/current.rs +++ b/src/task/current.rs @@ -1,9 +1,18 @@ use crate::{config, interrupt::svc, schedule::current}; +/// Switch the current task out of the CPU and let the scheduler pick the next +/// task to run. pub fn yield_current() { svc::svc_yield_current_task(); } +/// Change the priority of the currently running task. Return `Ok(())` if the +/// priority is successfully changed. Return `Err(())` if the given new +/// priority is not allowed by the configuration settings. +/// +/// If successful, the new priority will have taken effect when the function +/// returns. If the priority is reduced, any ready task that becomes having a +/// higher priority than the current task will have preempted the current task. pub fn change_current_priority(prio: u8) -> Result<(), ()> { if prio >= config::TASK_PRIORITY_LEVELS - 1 { return Err(()); @@ -13,6 +22,8 @@ pub fn change_current_priority(prio: u8) -> Result<(), ()> { Ok(()) } +/// Return the ID of the current task. The ID is only for diagnostic purpose +/// and does not have any functional purpose. pub fn get_current_id() -> u8 { current::with_current_task(|cur_task| cur_task.get_id()) }