Operating Systems
Dashboard Download PDF

tags: - cocubes - technical - operating-systems


Operating Systems

Process versus thread

Process Thread
independent executing program lightweight execution unit within a process
separate address space shares process memory/resources
context switch usually heavier context switch usually lighter
communication needs IPC threads communicate through shared memory

CPU scheduling

Algorithm Idea Main issue
FCFS first come, first served convoy effect
SJF shortest burst first requires burst estimate; long jobs may starve
SRTF preemptive SJF more context switches
Round Robin fixed time quantum very small quantum means overhead; huge quantum resembles FCFS
Priority highest priority first starvation; aging reduces it
  • Turnaround time = completion time โˆ’ arrival time.
  • Waiting time = turnaround time โˆ’ CPU burst time.
  • Response time = first CPU start time โˆ’ arrival time.

Synchronisation

A critical section accesses shared data. Problems include race conditions and lost updates.

  • Mutex: mutual exclusion lock, normally one owner.
  • Semaphore: integer synchronisation primitive; binary semaphore can act like a lock, counting semaphore tracks several resources.
  • Deadlock: processes wait forever for resources.

Four necessary deadlock conditions:

  1. mutual exclusion;
  2. hold and wait;
  3. no preemption;
  4. circular wait.

Breaking one condition can prevent deadlock.

Memory management

Term Meaning
Paging fixed-size pages and frames
Segmentation variable-size logical sections such as code/data/stack
Virtual memory uses disk to extend apparent memory
Page fault requested page is not currently in main memory
TLB cache for recent page-table translations
Internal fragmentation unused space within allocated block
External fragmentation free space split into small scattered blocks

Demand paging loads a page when needed. A page fault is normal in demand paging; it is not "a corrupted page."

File systems and I/O

  • File descriptor: integer handle used by a process to access a file/stream.
  • Buffering reduces expensive I/O operations.
  • Spooling queues jobs for a device, such as a printer.
  • DMA lets an I/O device transfer data to memory with minimal CPU involvement.

Operating-system quick comparisons

  • Kernel mode can execute privileged instructions; user mode cannot.
  • An interrupt is usually hardware/external event; a system call is a controlled request from user program to OS.
  • A context switch saves one execution state and loads another.

[[03_Technical/Technical_Drills|Technical drills]] ยท [[03_Technical/Networking|Networking]]