pub enum State {
Running,
Yielded,
YieldedFor(UpcallId),
Stopped(StoppedState),
Faulted,
Terminated,
}
Expand description
States a process can be in.
This is public so external implementations of Process
can re-use these
process states.
While a process is running, it transitions between the Running
, Yielded
,
YieldedFor
, and Stopped
states. If an error occurs (e.g., a memory
access error), the kernel faults it and either leaves it in the Faulted
state, restarts it, or takes some other action defined by the kernel fault
policy. If the process issues an exit-terminate
system call, it enters the
Terminated
state. If it issues an exit-restart
system call, it
terminates then tries to back to a runnable state.
When a process faults, it enters the Faulted
state. To be restarted, it
must first transition to the Terminated
state, which means that all of its
state has been cleaned up.
Variants§
Running
Process expects to be running code. The process may not be currently scheduled by the scheduler, but the process has work to do if it is scheduled.
Yielded
Process stopped executing and returned to the kernel because it called
the yield
syscall. This likely means it is waiting for some event to
occur, but it could also mean it has finished and doesn’t need to be
scheduled again.
YieldedFor(UpcallId)
Process stopped executing and returned to the kernel because it called
the WaitFor
variant of the yield
syscall. The process should not be
scheduled until the specified driver attempts to execute the specified
upcall.
Stopped(StoppedState)
The process is stopped and the previous state the process was in when it was stopped. This is used if the kernel forcibly stops a process. This state indicates to the kernel not to schedule the process, but if the process is to be resumed later it should be put back in its previous state so it will execute correctly.
Faulted
The process ran, faulted while running, and is no longer runnable. For a faulted process to be made runnable, it must first be terminated (to clean up its state).
Terminated
The process is not running: it exited with the exit-terminate
system
call or was terminated for some other reason (e.g., by the process
console). Processes in the Terminated
state can be run again.