ECSE 427 Operating Systems Final Exam Cheat Sheet

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.38 KB

ECSE 427 Final Exam Cheat Sheet

Process Management

  • Fork: Each fork() creates a new process (2^n processes after n forks).
  • Fork Output: for(i=0; i<3; i++) fork(); printf("hello\n"); prints "hello" 8 times (2^3).
  • Child/Parent Sharing: Only code, static data, and disk content are shared; heap, stack, and registers are copied.
  • Process vs. Thread Switch: Process switching is more expensive due to address space switches, TLB flushes, and cache pollution.
  • Multithreading Benefits: Even on single-core CPUs, threads are useful for blocking I/O operations.
  • Trap Steps:
    • Hardware: Save state → Change to kernel mode → Jump to trap handler.
    • OS: Identify cause → Handle trap → Return to user mode.

Memory & Paging

  • Address Translation (Virtual → Physical): Segment Number + Offset → (Segment Table) → Base Address + Offset.
  • Page Table Entries: Calculate with (address space size / page size) × sparsity factor.
  • Optimal Page Replacement: Replace the page that won't be used for the longest time.
  • Page Table Structure: Multi-level tables reduce memory waste for sparse address spaces.
  • TLB Hit: Virtual address → TLB → Physical address.
  • TLB Miss: Virtual address → Page table → Update TLB → Physical address.

Synchronization

  • Safety Properties: Something bad never happens (e.g., mutual exclusion).
  • Liveness Properties: Something good eventually happens (e.g., progress, bounded waiting).
  • Semaphore Bug: Non-atomic wait() allows multiple processes to pass, violating mutual exclusion.
  • Deadlock Avoidance: Break the circular wait condition (e.g., Dining Philosophers: limit philosophers at the table).
  • Escape Room Strategy: One person counts all visitors (turns switch ON when they first visit; every other visitor turns it OFF once).

File Systems

  • Hard Links: Point to the same inode; survive original file deletion.
  • Soft Links: Point to a file path; break if the original file is deleted.
  • Max File Size: Direct blocks + Indirect blocks + Double indirect + Triple indirect.
  • Formula: PD×S + PI×P×S + PDI×P²×S (PD=direct, PI=indirect, S=block size, P=pointers per block).
  • File I/O Operations:
    • Linked Allocation: Begin(1), Mid(n/2), End(n)
    • FAT: Begin(1), Mid(1), End(1)
    • Indexed: Begin(6), Mid(6), End(4)
  • Caching: Write-through (immediate write, consistency) vs. Write-behind (batched writes, performance).
  • Log-Structured FS: Checkpointing reduces recovery time but impacts performance.

Scheduling

  • SJF Advantage: Minimizes average waiting time.
  • SJF Disadvantage: Potential starvation of long jobs.
  • SRTF: Like SJF but preempts when a shorter job arrives.
  • Starvation: When a process is indefinitely delayed due to scheduler preference for others.
  • Aging: Increase the priority of waiting processes over time to prevent starvation.
  • Preemption Advantage: Better response time for short processes.
  • Preemption Disadvantage: Longer turnaround for CPU-bound processes and context switching overhead.
 

Related entries: