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§
- context 🔒Implementation of
TaskContext - id 🔒Task pid implementation.
- manager 🔒Implementation of
TaskManager - Implementation of
Processorand Intersection of control flow - switch 🔒Wrap
switch.Sas a function - task 🔒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
TaskControlBlockthat 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_taskto 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