pub enum State {
Running,
Yielded,
StoppedRunning,
StoppedYielded,
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
,
StoppedRunning
, and StoppedYielded
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.
StoppedRunning
The process is stopped, and its previous state was Running. This is used
if the kernel forcibly stops a process when it is in the Running
state. 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 the
running state so it will execute correctly.
StoppedYielded
The process is stopped, and it was stopped while it was yielded. If this
process needs to be resumed it should be put back in the Yield
state.
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.