Struct spawn::BootstrapTaskRef

source ·
pub struct BootstrapTaskRef { /* private fields */ }
Expand description

A wrapper around a TaskRef for bootstrapped tasks, which are the tasks that represent the first thread of execution on each CPU when it first boots.

When a bootstrap task has done everything it needs to do, it should invoke BootstrapTaskRef::finish() to indicate that it’s finished, which will then mark itself as exited and remove itself from runqueues.

See init() and [task::bootstrap_task()].

Implementations§

This function represents the final step of each CPU’s initialization procedure.

This function does the following:

  1. Consumes this bootstrap task such that it can no longer be accessed.
  2. Marks this bootstrap task as exited.
  3. Removes this bootstrap task from this CPU’s runqueue.

Methods from Deref<Target = TaskRef>§

Creates a new weak reference to this Task, similar to Weak.

Returns true if this task is joinable, false if not.

  • If true, another task holds the [JoinableTaskRef] object that was created by [TaskRef::create()], which indicates that that other task is able to wait for this task to exit and thus be able to obtain this task’s exit value.
  • If false, the [JoinableTaskRef] object was dropped, and therefore no other task can join this task or obtain its exit value.

When a task is not joinable, it is considered to be an orphan and will thus be automatically reaped and cleaned up once it exits because no other task is waiting on it to exit.

Kills this Task (not a clean exit) without allowing it to run to completion. The provided KillReason indicates why it was killed.

** Currently this immediately kills the task without performing any unwinding cleanup. In the near future, the task will be unwound such that its resources are freed/dropped to ensure proper cleanup before the task is actually fully killed. **

Locking / Deadlock

This method obtains a writable lock on the underlying Task’s inner state.

Return
  • Returns Ok if the exit status was successfully set to the given KillReason.
  • Returns Err if this Task was already exited, and does not overwrite the existing exit status.
Note

The Task will not be halted immediately – it will finish running its current timeslice, and then never be run again.

Methods from Deref<Target = Task>§

Sets the Environment of this Task.

Locking / Deadlock

Obtains the lock on this Task’s inner state in order to mutate it.

Gets a reference to this task’s Environment.

Locking / Deadlock

Obtains the lock on this Task’s inner state in order to access it.

Returns true if this Task is currently running.

Returns the ID of the CPU this Task is currently running on.

Returns the ID of the CPU this Task is pinned on, or None if it is not pinned.

Returns the current [RunState] of this Task.

Returns whether this Task is runnable, i.e., able to be scheduled in.

For this to return true, this Task’s runstate must be Runnable and it must not be suspended.

Note

This does NOT mean that this Task is actually currently running, just that it is able to be run.

Returns the namespace that this Task is loaded/linked into and runs within.

Exposes read-only access to this Task’s [Stack] by invoking the given func with a reference to its kernel stack.

Locking / Deadlock

Obtains the lock on this Task’s inner state for the duration of func in order to access its stack. The given func must not attempt to obtain that same inner lock.

Invokes func with immutable access to this Task’s [RestartInfo].

Locking / Deadlock

Obtains the lock on this Task’s inner state for the duration of func in order to access its stack. The given func must not attempt to obtain that same inner lock.

Returns true if this Task has been exited, i.e., if its RunState is either Exited or Reaped.

Returns true if this is an application Task.

This will also return true if this task was spawned by an application task, since a task inherits the “application crate” field from its “parent” that spawned it.

Returns true if this Task was spawned as a restartable task.

Locking / Deadlock

Obtains the lock on this Task’s inner state in order to access it.

Blocks this Task by setting its runstate to [RunState::Blocked].

Returns the previous runstate on success, and the current runstate on error. This will only succeed if the task is runnable or already blocked.

Blocks this Task if it is a newly-spawned task currently being initialized.

This is a special case only to be used when spawning a new task that should not be immediately scheduled in; it will fail for all other cases.

Returns the previous runstate (i.e. RunState::Initing) on success, or the current runstate on error.

Unblocks this Task by setting its runstate to [RunState::Runnable].

Returns the previous runstate on success, and the current runstate on error. Will only succed if the task is blocked or already runnable.

Makes this Task Runnable if it is a newly-spawned and fully initialized task.

This is a special case only to be used when spawning a new task that is ready to be scheduled in; it will fail for all other cases.

Returns the previous runstate (i.e. RunState::Initing) on success, and the current runstate on error.

Suspends this Task.

Unsuspends this Task.

Returns true if this Task is suspended.

Note that a task being suspended is independent from its [RunState].

Trait Implementations§

Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.