[−][src]Struct r3::kernel::Task
Represents a single task in a system.
This type is ABI-compatible with Id
.
Relation to Other Specifications: Present in almost every real-time operating system.
Task States
A task may be in one of the following states:
-
Dormant — The task is not executing, doesn't have an associated execution thread, and can be activated.
-
Ready — The task has an associated execution thread, which is ready to be scheduled to the CPU
-
Running — The task has an associated execution thread, which is currently scheduled to the CPU
-
Waiting — The task has an associated execution thread, which is currently blocked by a blocking operation
Implementations
impl<System: Port> Task<System>
[src]
pub const fn build() -> CfgTaskBuilder<System>
[src]
Construct a CfgTaskBuilder
to define a task in a configuration
function.
impl<System> Task<System>
[src]
pub const unsafe fn from_id(id: Id) -> Self
[src]
Construct a Task
from Id
.
Safety
The kernel can handle invalid IDs without a problem. However, the
constructed Task
may point to an object that is not intended to be
manipulated except by its creator. This is usually prevented by making
Task
an opaque handle, but this safeguard can be circumvented by
this method.
Constructing a Task
for a current task is allowed. This can be safely
done by Task::current
.
pub const fn id(self) -> Id
[src]
Get the raw Id
value representing this task.
impl<System: Kernel> Task<System>
[src]
pub fn current() -> Result<Option<Self>, GetCurrentTaskError>
[src]
Get the current task (i.e., the task in the Running state).
In a task context, this method returns the currently running task.
In an interrupt context, the result is unreliable because scheduling is deferred until the control returns to a task, but the current interrupt handler could be interrupted by another interrrupt, which might do scheduling on return (whether this happens or not is unspecified).
pub fn activate(self) -> Result<(), ActivateTaskError>
[src]
Start the execution of the task.
pub fn interrupt(self) -> Result<(), InterruptTaskError>
[src]
Interrupt any ongoing wait operations undertaken by the task.
This method interrupt any ongoing system call that is blocking the task.
The interrupted system call will return WaitError::Interrupted
or
WaitTimeoutError::Interrupted
.
pub fn unpark(self) -> Result<(), UnparkError>
[src]
Make the task's token available, unblocking Kernel::park
now or in
the future.
If the token is already available, this method will return without doing
anything. Use Task::unpark_exact
if you need to detect this
condition.
If the task is currently being blocked by Kernel::park
, the token will
be immediately consumed. Otherwise, it will be consumed on a next call
to Kernel::park
.
pub fn unpark_exact(self) -> Result<(), UnparkExactError>
[src]
Make exactly one new token available for the task, unblocking
Kernel::park
now or in the future.
If the token is already available, this method will return
UnparkExactError::QueueOverflow
. Thus, this method will succeed
only if it made exactly one token available.
If the task is currently being blocked by Kernel::park
, the token will
be immediately consumed. Otherwise, it will be consumed on a next call
to Kernel::park
.
pub fn set_priority(self, priority: usize) -> Result<(), SetTaskPriorityError>
[src]
Set the task's base priority.
A task's base priority is used to calculate its effective priority.
Tasks with lower effective priorities execute first. The base priority
is reset to the initial value specified by CfgTaskBuilder::priority
upon activation.
The value must be in range 0..
num_task_priority_levels
. Otherwise,
this method will return SetTaskPriorityError::BadParam
.
The task shouldn't be in the Dormant state. Otherwise, this method will
return SetTaskPriorityError::BadObjectState
.
pub fn priority(self) -> Result<usize, GetTaskPriorityError>
[src]
Get the task's base priority.
The task shouldn't be in the Dormant state. Otherwise, this method will
return GetTaskPriorityError::BadObjectState
.
pub fn effective_priority(self) -> Result<usize, GetTaskPriorityError>
[src]
Get the task's effective priority.
The effective priority is calculated based on the task's base priority and can be temporarily raised by a mutex locking protocol.
The task shouldn't be in the Dormant state. Otherwise, this method will
return GetTaskPriorityError::BadObjectState
.
Trait Implementations
impl<System> Clone for Task<System>
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<System> Copy for Task<System>
[src]
impl<System> Debug for Task<System>
[src]
impl<System> Eq for Task<System>
[src]
impl<System> Hash for Task<System>
[src]
pub fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<System> PartialEq<Task<System>> for Task<System>
[src]
Auto Trait Implementations
impl<System> Send for Task<System> where
System: Send,
[src]
System: Send,
impl<System> Sync for Task<System> where
System: Sync,
[src]
System: Sync,
impl<System> Unpin for Task<System> where
System: Unpin,
[src]
System: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,