A program is defined as compiled code with four main components: executable format info, text segment, data segment, and BSS segment.
The executable format info includes lib dependencies, CPE architecture, pointer to entrypoint, and is another file format such as ELF, COFF, or COM.
The text segment contains compiled machine code and unresolved symbols for loader to resolve against shared libraries.
The data segment contains initialized global and static variables.
The BSS segment contains uninitialized global and static variables.
An instance of a program consists of a program, execution context, address space, stack, heap, and additional OS resources.
The process control block (PCB) is a kernel structure used to track all of the process state.
In Linux, the task_struct is used to track process state.
Context switching changes the entire process, is more expensive than mode switching, and can be initiated in three primary types of context switching: batch, cooperative, and pre-emptive multitasking.
Batch context switching only happens when process/job terminates.
Cooperative context switching is when ‘yield’ syscall is made.
Pre-emptive multitasking involves using a timer interrupt to periodically regain control and a scheduler that tracks how much CPU time a thread has used and picks a different one when the current exceeds its ‘quantum’.
All faults, traps, and interrupts trigger context switches.
Three main states for a process & all threads are: Running, Ready, and Blocked.
Blocking is an important concept as the OS knows it can make no useful progress so it is ineligible to run until it can.
The main responsibilities of process management include blocking, creating, and destroying.