Looks like no one added any tags here yet for you.
context switching; savings, loading, updating data
What does an OS do when it switches processes?
Running
Ready Blocked
What are the states and state transitions for a process, and can you draw a diagram depicting them?
kernel mode - privledged
user mode - unprivledged
What are the two processor modes of an OS that we discussed?
Switching from Kernel to User, vice verse:
A trap instruction is executed that jumps to the kernel and raises the processor mode.
A return-from-trap instruction lowers the processor mode and jumps back to the calling code in the application.
How does an OS switch between processor modes?
fork(): Creates a new child process as an exact copy of the parent.
exec(): Replaces the current process image with a new program.
What is fork()? What is exec()? What’s the difference?
Interrupt timer - interrupt the processor, forcing it to give
control back to the OS
Interrupt handler - executed when interrupt is triggered, yielding control back to OS
How does the OS switch processes?
Turnaround Time = Completion Time − Arrival Time
What is turnaround time?
Ensures no process is starved, getting a fair share of CPU time
What is fairness?
FIFO - If a long job arrives first, all shorter jobs must wait
SJF - A long job may never execute if short jobs keep arriving
Can you give examples that make FIFO and SJF unideal?
overlapping I/O and CPU execution
What is overlap in terms of job scheduling?
Lottery scheduling assigns random tickets to processes, and a ticket is drawn randomly to decide execution.
Issue: It lacks deterministic guarantees; a process might get unlucky and starve.
Can you describe a lottery scheduler, and can you identify where it might falter?
Isolation (processes don’t interfere)
Security (no direct memory access)
Efficient memory management
Why do we virtualize memory?
ease of use
isolation
protection
What are the goals of memory virtualization, and why are they important?
The range of memory addresses a process can use.
What is an address space?
Code: Program instructions 00
Stack: Function calls and local variables 11
Heap: Dynamically allocated memory 01
What are the three main memory components of a running process?
We want to implement virtualizing memory in a transparent way.
• Invisible to running programs.
We want the system to be as efficient as possible.
• Don’t slow the programs down.
• Don’t use up more memory than necessary (data structures).
We want to protect processes from one another.
• Also want to protect the OS
What are the goals of memory abstraction, and why are they important?
Stack: Managed automatically, grows downward, used for function calls and local variables.
Heap: Dynamically allocated memory, grows upward, managed manually.
What is different (functionally) between a stack and a heap?
conversion of virtual into physical addresses
What is address translation?
Utilization of a base and bounds system.
In this system, there are two hardware registers, one called the base register and another called the bounds register. Every program is written and compiled as if to be loaded at address 0x0. The OS sets the base register to where it wants the process to be in
physical memory. The processor then translates:
physical = virtual + base
How does the early incarnation of dynamic relocation for address translation work?
Uses interrupts and system calls to transition from user mode to kernel mode.
How does an OS switch between processor modes?
A register that stores the upper memory limit for a process to prevent it from accessing out-of-bounds memory.
What is the bounds register?
Unused memory inside an allocated block due to fixed-size allocation
What is internal fragmentation?
Divides memory into logical segments, using a base bounds register of address space (code, stack, heap)
What is segmentation, and why did we implement it?
Explicit - which system an address refers too - top two bits refer to the segment, the rest offset. 00 code, 01 heap, stack 11.
Implicit - how the address was formed - instruction ptr → code, stack ptr → stack, any other is heap
What are the two approaches to address translation for segmentation?
Shared page mappings
What do we need to share certain memory segments between address spaces?
Wasted memory between allocated blocks due to variable-sized allocation.
What is external fragmentation?