Skip to content

Commit

Permalink
Comment APIs for current task.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyma98 committed Aug 26, 2024
1 parent f0cfb4b commit 794f45e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/task/current.rs
Original file line number Diff line number Diff line change
@@ -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(());
Expand All @@ -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())
}

0 comments on commit 794f45e

Please sign in to comment.