Expand description
Implementation of process management mechanism
Here is the entry for process scheduling required by other modules (such as syscall or clock interrupt). By suspending or exiting the current process, you can modify the process state, manage the process queue through TASK_MANAGER, and switch the control flow through PROCESSOR.
Be careful when you see __switch. Control flow around this function
might not be what you expect.
Modules
Implementation of TaskContext
Task pid implementation.
Implementation of TaskManager
Wrap switch.S as a function
Types related to task management & Functions for completely changing TCB
Structs
Creation of initial process
Kernel stack for a process(task)
Abstract structure of PID
Action for a signal
Signal actions
Signal flags
task context structure containing some registers
Task control block structure
Enums
task status: UnInit, Ready, Running, Exited
Constants
Functions
Add init process to the manager
Add process to ready queue
call kernel signal handler
call user signal handler
Check if the current task has any signal to handle
Check if the current task has any signal to handle
Add signal to the current task
Get a copy of the current task
Get the mutable reference to trap context of current task
Get the current user token(addr of page table)
Exit the current ‘Running’ task and run the next task in task list.
Handle signals for the current process
allocate a new kernel stack
Get process by pid
Allocate a new PID
The main part of process execution and scheduling
Loop fetch_task to get the process that needs to run, and switch the process through __switch
Return to idle control flow for new scheduling
Make current task suspended and switch to the next task
Get current task through take, leaving a None in its place