Expand description
Task management implementation
Everything about task management, like starting and switching tasks is implemented here.
A single global instance of TaskManager
called TASK_MANAGER
controls
all the tasks in the whole operating system.
A single global instance of Processor
called PROCESSOR
monitors running
task(s) for each core.
A single global instance of PID_ALLOCATOR
allocates pid for user apps.
Be careful when you see __switch
ASM function in switch.S
. 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
Processor management structure
task context structure containing some registers
Task control block structure
A array of TaskControlBlock
that is thread-safe
Enums
task status: UnInit, Ready, Running, Exited
Constants
pid of usertests app in make run TEST=1
Functions
Add init process to the manager
Add process to ready queue
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.
Take a process out of the ready queue
allocate a new kernel stack
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
Suspend the current ‘Running’ task and run the next task in task list.
Get current task through take, leaving a None in its place