Docsity

Advanced Operating Systems Study Guide: Kernel Concurrency & Memory Management, Lecture notes of Computer Science

Toggle sidebar
bg1
COURSE: Computer Science / Computer Engineering 401 (Advanced Level)
SUBJECT: Operating Systems Architecture, Low-Level Concurrency, and
Kernel Subsystems
DOCUMENT TYPE: Complete 5-Page Semester Master Syllabus & Code
Blueprint
AUTHOR: Carlwyn Melgarejo
PAGE 1: KERNEL SPACE VS. USER SPACE ARCHITECTURE
An operating system architecture structurally segregates hardware access
into distinct execution layers to maintain system security and fault isolation.
1. Privilege Separation Rings
Modern CPUs enforce execution privileges via hardware-level protection
rings:
Ring 0 (Kernel Space): The core engine of the OS. Has unrestricted,
absolute execution privileges over memory, CPU instructions, and
peripheral hardware I/O devices.
Ring 3 (User Space): The execution environment for standard
applications (e.g., Web Browsers, Word Processors). Code running here
cannot access physical hardware directly; it must request access via
the kernel.
2. System Call Mechanisms (Syscalls)
When a user-space application requires a protected resource (e.g., reading a
file from the SSD via read()), it triggers a software interrupt. The CPU
switches context from Ring 3 to Ring 0, allowing the kernel to validate
permissions, perform the operation safely, and return context back to the
application layout.
PAGE 2: PROCESS SCHEDULING ALGORITHMS & SCHEDULER DESIGN
The CPU scheduler is the component of the operating system that
determines which thread or process is allocated CPU execution cycles.
1. Algorithmic Paradigms
First-Come, First-Served (FCFS): Non-preemptive. Suffers from the
Convoy Effect, where short tasks are blocked behind a massive,
resource-heavy calculation process.
pf3
pf4
pf5

Partial preview of the text

Download Advanced Operating Systems Study Guide: Kernel Concurrency & Memory Management and more Lecture notes Computer Science in PDF only on Docsity!

COURSE: Computer Science / Computer Engineering 401 (Advanced Level)

SUBJECT: Operating Systems Architecture, Low-Level Concurrency, and

Kernel Subsystems

DOCUMENT TYPE: Complete 5-Page Semester Master Syllabus & Code

Blueprint

AUTHOR: Carlwyn Melgarejo

PAGE 1: KERNEL SPACE VS. USER SPACE ARCHITECTURE

An operating system architecture structurally segregates hardware access

into distinct execution layers to maintain system security and fault isolation.

1. Privilege Separation Rings

Modern CPUs enforce execution privileges via hardware-level protection

rings:

 Ring 0 (Kernel Space): The core engine of the OS. Has unrestricted,

absolute execution privileges over memory, CPU instructions, and

peripheral hardware I/O devices.

 Ring 3 (User Space): The execution environment for standard

applications (e.g., Web Browsers, Word Processors). Code running here

cannot access physical hardware directly; it must request access via

the kernel.

2. System Call Mechanisms (Syscalls)

When a user-space application requires a protected resource (e.g., reading a

file from the SSD via read()), it triggers a software interrupt. The CPU

switches context from Ring 3 to Ring 0, allowing the kernel to validate

permissions, perform the operation safely, and return context back to the

application layout.

PAGE 2: PROCESS SCHEDULING ALGORITHMS & SCHEDULER DESIGN

The CPU scheduler is the component of the operating system that

determines which thread or process is allocated CPU execution cycles.

1. Algorithmic Paradigms

 First-Come, First-Served (FCFS): Non-preemptive. Suffers from the

Convoy Effect , where short tasks are blocked behind a massive,

resource-heavy calculation process.

 Shortest Job First (SJF): Mathematically optimal for minimizing

average waiting times, but structurally impossible to perfectly

implement in general computing because future CPU burst times

cannot be predicted with absolute precision.

 Round Robin (RR): Preemptive. Allocates a fixed time slice (Time

Quantum) to each thread sequentially.

2. Scheduler Performance Tracking Formulas

To evaluate system stability, kernel developers compute structural metrics

across specific process workflows:

 Turnaround Time: Completion Time - Arrival Time

 Waiting Time: Turnaround Time - Burst Time

PAGE 3: PHYSICAL MEMORY AND VIRTUALIZATION

Operating systems abstract physical RAM configurations into uniform virtual

addresses spaces using hardware-assisted memory management units

(MMU).

1. Paging and Page Table Architecture

The OS divides virtual memory into fixed blocks called Pages , and physical

RAM into blocks called Frames. A system Page Table maps pages to

frames.

 Translation Lookaside Buffer (TLB): A high-speed hardware cache

built into the CPU that stores recent virtual-to-physical address

mappings, bypassing the slow multi-level page table lookups in RAM.

2. Memory Fault Faults & Page Replacement Strategies

When a process requests an address space whose virtual page is mapped to

disk swap storage rather than physical RAM, the hardware triggers a Page

Fault interrupt. The kernel intercepts this, retrieves the frame from storage,

and updates the table.

 Least Recently Used (LRU): Evicts the page that has not been

accessed for the longest duration of time.

PAGE 4: KERNEL CONCURRENCY & LOCK-FREE STRUCTURES

When building low-level systems, multi-threaded kernels face

synchronization deadlocks. Advanced operating systems utilize atomic

instructions to execute lock-free operations.

 while (q->count == CAPACITY) {  // Queue is completely saturated; block the current calling thread safely  pthread_cond_wait(&q->not_full, &q->lock);  }  q->data[q->rear] = task_id;  q->rear = (q->rear + 1 ) % CAPACITY;  q->count++;   // Broadcast signal waking up thread components waiting to consume data  pthread_cond_signal(&q->not_empty);  pthread_mutex_unlock(&q->lock);  }   int kernel_queue_dequeue(KernelSafeQueue *q) {  pthread_mutex_lock(&q->lock);  while (q->count == 0 ) {  // Queue is completely empty; sleep thread operation to prevent CPU burnout  pthread_cond_wait(&q->not_empty, &q->lock);  }  int fetched_task = q->data[q->front];  q->front = (q->front + 1 ) % CAPACITY;  q->count--;   // Signal tracking structures that room has been vacated for insertion  pthread_cond_signal(&q->not_full);  pthread_mutex_unlock(&q->lock);  return fetched_task;  }   void destroy_kernel_queue(KernelSafeQueue *q) {  pthread_mutex_destroy(&q->lock);  pthread_cond_destroy(&q->not_full);  pthread_cond_destroy(&q->not_empty);  free(q);  }   int main() {  KernelSafeQueue *shared_buffer = initialize_kernel_queue();  printf("Kernel Framework Log: Structural safe queue architecture initialized.\n");  kernel_queue_enqueue(shared_buffer, 2048 );  int task = kernel_queue_dequeue(shared_buffer);  printf("Kernel Framework Log: Successfully processed execution payload token: %d\n", task);  destroy_kernel_queue(shared_buffer);  return 0 ;  }