Terminology
Multi Level Feedback Queues
- Used for optimizing CPU Criteria
- Several queues available and CPU Scheduler pick job from the highest priority queue
- Jobs may move between queues based on mathematically defined metrics automatically.
- Priority is inferred not user defined.
Multi Level Queues
- has Multiple Queues, but one process will only live in one queue for the whole execution timeline.
- low priority queues may suffer from starvation if the high priority queues are busy for longer periods
- not as good as MLFQs
- Require prior knowledge to place the job in correct queue. usually OS or user does it
Scheduling Algorithms
-
Round Robin Gives constant CPU burst time (Quantum) for all processes in the ready queue one after other in a loop. If the process exits before RR Quantum finishes, Next ready process is executed with new Quantum begin.
-
FCFS (First Come, First Served) Can starve later processes if first one takes longer
-
SJF (Shortest Job First) Need to guess the execution time required by each job Uses a Burst Prediction model called **exponential averaging (EWMA)
\tau_{n+1} = \alpha t_n + (1−\alpha)\tau_n $$ - tₙ = the actual length of the most recent (n-th) CPU burst — a measured fact - τₙ = the predicted length of the n-th burst — our guess - τₙ₊₁ = prediction for the next burst — what we're computing - α = weight, 0 ≤ α ≤ 1 (usually ½) 4. SRTF (Shortest Remaining time First) Also uses Burst Prediction. Remaining time need to be calculated for all processes after each cycle.
Process-contention scope (PCS)
a thread scheduling model where user-level threads compete against other threads within the same process for CPU or lightweight process (LWP) resource.
| Feature | Process Contention Scope (PCS) | System Contention Scope (SCS) |
|---|---|---|
| Contention Level | Within a single process only | Across the entire operating system |
| Thread Mapping | Many-to-one or many-to-many (N:1 or N:M) | One-to-one (1:1) with a kernel thread |
| Scheduler | User-level thread library | OS kernel scheduler |
| Context Switch | Fast (no kernel intervention) | Slower (requires kernel calls) |
| Multicore Use | Limited to the assigned LWP/core | True system-wide multicore use |
Symmetric multiprocessing scheduling
A computer architecture where multiple identical processors are interconnected to a single shared main memory, with full accessibility to all the I/O devices, unlike asymmetric MP. In other words, all the processors have common shared(common) memory and same data path or I/O bus as shown in the figure.
Affinity
This lets a Process to run on an specific CPU Core rather than randomly gets one.
| Type | Behavior |
|---|---|
| Soft affinity | The OS prefers to keep a task on the same core, but may migrate it if needed (this is the default behavior). |
| Hard affinity | The task is restricted to an explicit set of cores and will never run elsewhere (set explicitly by the user/app). |
NUMA (Non-Uniform Memory Access)
In a NUMA system, memory is split into nodes. Each CPU (or group of cores) has its own memory controller and its own bank of RAM directly attached to it:
- Accessing your own node's RAM = fast (local access).
- Accessing the other node's RAM = slower (remote access), because it has to travel over the inter-socket interconnect (e.g., Intel's UPI, AMD's Infinity Fabric).
This is why it is "Non Uniform", the time it takes to access memory depends on where it is
In a NUMA system, you usually want affinity too. This is because the process must be running in the same CPU Node as the Memory is allocated to it. This makes it faster.
Memory Fragmentation
Internal Fragmentation
wasted space inside the block that was given to a process. The memory is allocated but unused, and no one else can use it.
- Memory is handed into processes in fixed chunks so some can be not fully used by program
External Fragmentation
wasted space outside any allocation: free memory exists in total, but is scattered in non-adjacent pieces, so it can't satisfy a request that needs a contiguous chunk.
- Happens with variable-size allocations in contiguous memory: every process gets exactly what it asks for, but departures leave irregular holes.
PTBR and PTLR
Page Table Base Register - physical base address of the page table Page Table Length Register - number of valid entries in it (addresses valid until base+length)
Effective Access Time (ETA) - Memory
This is the average time for memory access in a processor with virtualization enabled.
- - Hit Ratio
- - Time for the cache hit
- - Time for memory read
Thrashing
when a system spends more time swapping pages in and out than executing useful work. Processes keep faulting because they don't have enough frames for the pages they actively use. The CPU sits mostly idle, waiting for the disk.

Why thrashing occurs
Data vs Task Parallelism
ways to speed things up by parallelizing through multiple cores
| Data parallelism | Task parallelism | |
|---|---|---|
| What is divided | The data | The tasks/functions |
| Operation per core | Same | Different |
| Scales with | Amount of data, which is often very large | Number of independent tasks, which is often limited |
| Example | Each core sums part of an array | Each core computes a different statistic |
PCB - Process Control Block
Contains these:
- process state
- program counter
- CPU registers
- CPU-scheduling information
- memory-management information
- accounting information
- I/O status information
