1/28
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Why do we need an OS?
Portability and resource sharing
What are the 3 main functions of an OS?
Abstraction, Virtualization, Access Control
What is the Sleeping Beauty Model?
User code runs directly on CPU with limited privileges. OS sleeps until events wake it up.
Which ring does user code run in? Kernel?
User: Ring 3, Kernel: Ring 0
What are privileged operations? (3 examples)
Direct I/O access, manipulating page tables/TLB, manipulating protected control registers
How does CPU prevent user apps from doing privileged operations?
User apps run in Ring 3. Attempting privileged ops raises a fault that traps to kernel.
What are the 3 types of events that wake up the OS?
Faults, System Calls, Interrupts
Is a fault synchronous or asynchronous? Give 2 examples.
Synchronous. Examples: page fault, divide-by-zero, NULL dereference
Is a system call synchronous or asynchronous? Give 2 examples.
Synchronous. Examples: open(), read(), write(), sleep()
Is an interrupt synchronous or asynchronous? Give 2 examples.
Asynchronous. Examples: timer, keystroke, network packet, I/O completion
What are the 7 steps of a system call?
1) Execute syscall instruction with number 2) Mode switch Ring 3→0 3) Save state 4) Lookup syscall table 5) Execute kernel function 6) Restore state 7) Return to Ring 3
How does user program specify which syscall to invoke?
Set register (%eax/%rax) with syscall number before issuing syscall instruction
How are kernel objects referenced in syscalls?
Integer handles/descriptors (e.g., file descriptors)
Can user programs call arbitrary kernel functions?
No. Only specific syscalls via syscall number that OS validates.
Why does OS need to handle timer interrupts?
To reclaim control for context switching and timesharing. Also for sleep().
What is a context switch?
Switching execution from one process to another by saving/restoring state
How does context switching happen?
Timer interrupts force switch from user program to OS scheduler
How to go from Ring 0 to Ring 3?
Directly modify mode register to drop privilege
How to go from Ring 3 to Ring 0?
Only via special instructions (syscall) or events (interrupts/faults)
What happens when protected instruction executes in Ring 3?
Hardware raises fault that traps to kernel
How are recoverable faults handled?
OS fixes condition and returns to faulting context. Example: load missing page for page fault
How are unrecoverable user faults handled?
Kill process: halt, dump state, destroy
What happens when kernel faults?
Fatal crash - panic/BSOD, dump core, lock up
How are interrupts used for I/O?
OS initiates I/O, device works independently, sends interrupt when done
What is the interrupt vector table?
Table of kernel routine addresses indexed by interrupt number
Why do interrupts cause synchronization problems?
Can occur anytime and handler can interfere with interrupted code
Two methods for atomic execution?
1) Disable interrupts 2) Atomic instructions (e.g., XCHG)
How does OS provide memory isolation?
Memory Management Unit (MMU) with virtual memory/segmentation (privileged ops)
Two ways to initiate I/O?
1) Special I/O instructions 2) Memory-mapped I/O