Processes Pt.2 - Lec.7 Flashcards
Context Switching
Context switching is the CPU switching from one process to another, involves storing and restoring the CPU’s state(context).
Context Switching Triggers MIK
Multitasking(switching between processes/threads), Interrupts( e.g. handling external events), Kernel/User Mode transitions( e.g. accessing system resources).
Hardware vs Software context switching
Some CPUS like Intelx86 support hardware switching, but modern OSes often use software-based switching for portability and performance.
Process Creation[PID, Tree Structures, Resource Sharing, Execution] PTRE
PID- processes are dynamically created and identified by a process id(pid), Tree Structures- processes form a tree structure with parent processes creating child processes, Resource Sharing- Can be shared fully, partially or not at all between parent and child, Execution- Parent and child can run concurrently or the parent can wait until the child has finished.
Process Address Space
Child processes may- 1. Duplicate the parent process(same program/data), or 2. Load a new program(using exec() after fork()).
POSIX Process Creation Commands( fork(), exec(), exit() and wait() )
fork() creates a new process(child), exec() replaces the process memory with a new program, exit() terminates a process, wait() allows parent process to wait for child termination.
Process termination( zombie and orphan processes)
Processes terminate with exit(), releasing resources. Zombie process is a terminated process whose parent hasn’t called wait(). Orphan process is a process whose parent terminates without waiting, reparented to init in Linux.