[−][src]Struct sunrise_kernel::process::ProcessStruct
The struct representing a process. There's one for every process.
It contains many information about the process :
- Its type (regular userspace process, or kworker)
- Its state
- Its memory pages
- Its kernel stack, for syscalls and interrupts
- Its hardware context, to be restored on rescheduling
Fields
pid: usize
The unique id of this process.
name: String
A name for this process.
pmemory: Mutex<ProcessMemory>
The memory view of this process. Shared among the threads.
phandles: SpinLockIRQ<HandleTable>
The handles of this process. Shared among the threads.
threads: SpinLockIRQ<Vec<Weak<ThreadStruct>>>
The threads of this process. A ProcessStruct with no thread left will eventually be dropped.
entrypoint: VirtualAddress
The entrypoint of the main thread.
capabilities: ProcessCapabilities
Permissions of this process.
state: Mutex<ProcessStateData>
The state the process is currently in.
tls_manager: Mutex<TLSManager>
Tracks used and free allocated Thread Local Storage regions of this process.
Implementations
impl ProcessStruct
[src]
pub fn new(
procinfo: &ProcInfo,
kacs: Option<&[u8]>
) -> Result<Arc<ProcessStruct>, KernelError>
[src]
procinfo: &ProcInfo,
kacs: Option<&[u8]>
) -> Result<Arc<ProcessStruct>, KernelError>
Creates a new process.
The created process will have no threads.
Panics
Panics if max PID has been reached, which it shouldn't have since we're the first process.
pub fn start(
this: &Arc<Self>,
_main_thread_priority: u32,
stack_size: usize
) -> Result<(), UserspaceError>
[src]
this: &Arc<Self>,
_main_thread_priority: u32,
stack_size: usize
) -> Result<(), UserspaceError>
Creates the initial thread, allocates the stack, and starts the process.
Errors
ThreadAlreadyStarted
- Process is already started.
ProcessKilled
if the process struct was taggedkilled
before we had time to start it.MemoryExhausted
- Failed to allocate stack or thread TLS.
pub fn state(&self) -> ProcessState
[src]
Gets the state of this process.
pub fn clear_signal(&self) -> Result<(), KernelError>
[src]
Clears the signaled state of this process.
If the state is Exited, this function will return an error and the process will remain signaled.
Errors
InvalidState
- Process is not currently signaled.
- Process is in Exited state.
unsafe fn create_first_process() -> ProcessStruct
[src]
Creates the very first process at boot. Called internally by create_first_thread.
The created process will have no threads.
Safety
Use only for creating the very first process. Should never be used again after that. Must be using a valid KernelStack, a valid ActivePageTables.
Panics
Panics if max PID has been reached, which it shouldn't have since we're the first process.
pub fn kill_current_process()
[src]
Kills the current process by killing all of its threads.
When a thread is about to return to userspace, it checks if its state is Killed. In this case it unschedules itself instead, and its ThreadStruct is dropped.
When our last thread is dropped, our process struct is dropped with it.
We also mark the process struct as killed to prevent race condition with another thread that would want to spawn a thread after we killed all ours.
fn kill_subthreads(&self, statelock: MutexGuard<ProcessStateData>)
[src]
Kill all the subthreads of this process, and set the state to exited.
pub fn terminate(&self) -> Result<(), KernelError>
[src]
Kills the given process, terminating the execution of all of its thread and putting its state to Exiting/Exited.
Returns an error if used on a process that wasn't started.
Errors
InvalidState
- The process wasn't started (it is in Created or CreatedAttached state).
Trait Implementations
impl Debug for ProcessStruct
[src]
impl Drop for ProcessStruct
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ProcessStruct
impl Send for ProcessStruct
impl Sync for ProcessStruct
impl Unpin for ProcessStruct
impl !UnwindSafe for ProcessStruct
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,
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.
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>,