Operating Systems (Midterm) Flashcards
What are a computer’s two modes of operation?
- User mode (application)
- Kernel mode (OS kernel)
What are the transitions between user/kernel mode?
- Hardware interrupt: HW device requests OS services (asynchronous, event-triggered)
- System call (aka trap): User program requests OS services (synchronous, program-triggered)
- Exception: Error handling (Invalid memory access, invalid permission, etc.)
Describe a monolithic kernel
Monolithic kernel: A large process running entirely in a single address space (single binary file)
- All kernel services execute in kernel address space
What are the pros and cons of a monolithic kernel?
Pros:
- Fast
Cons:
- Huge kernel, harder to maintain
- No protection between kernel components
- Complex dependencies, not easily extensible
Describe a microkernel
Microkernel: Kernel broken down to separate processes (aka servers)
- Servers kept separate and run in different address spaces
- Communication is done via message passing (servers communicate through IPC)
What are the pros and cons of a microkernel?
Pros:
- Modular design, easily extensible
- Easy to maintain
- More reliable + secure
Cons:
- Performance loss
- Complicated process management
On a magnetic disk, read/write data is a 3-stage process. What are the three steps and which is the longest?
- Seek time: Position the arm over the proper track (longest time)
- Rotational latency: Wait for the desired sector to rotate under the read/write head
- Transfer time: Transfer a block of bits (sector) under the read/write head
How do you make information generated by HW device events available to running applications?
- Polling
- (HW) Interrupt
- DMA
Explain polling
Polling (busy waiting):
- I/O device puts information in a status register.
- OS periodically checks the status register
(SIMPLE, WASTES CPU CYCLES, LATENCY)
Explain HW interrupt
Interrupt:
- Whenever an I/O device needs attention form the processor, it interrupts the processor from what its currently doing
- Types on interrupts: I/O, Timer
(MORE RESPONSIVE, COMPLEX, BETTER PROCESSING EFFICIENCY)
Briefly explain DMA
Direct memory access, delegate I/O responsibility from CPU
What is a process?
An instance of a program running on a computer.
An abstraction that supports running programs.
What is the difference between a program and a process?
- Program is static code + data
- Process is a dynamic instantiation of code + data + files
- No 1:1 mapping
- A program can run invoke many processes (Running a program twice, or a program contains fork())
What does the fork() function do?
The Fork system call creates an exact copy of the calling process.
- After fork, caller is parent, newly creates process is child
- Returns new PID to parent, and 0 to child
- Same memory image, environment settings, and opened files
- Child program calls execve to change its memory image + run a new program
What makes output deterministic?
Deterministic: Output stays the same no matter no matter how many times it’s run
What are 5 process management system calls?
- fork: Creates a new process
- exec: Execute a new process image
- exit: voluntary process termination
- wait: parent wait for child to finish
- kill: send a signal to process (or group), can cause involuntary process termination
What is the 5-state process model?
- New: New process is first accepted into the queue
- Ready: Process is waiting to be selected to run
- Blocked: Process is waiting for some event
- Running: Process current being executed by CPU
- Terminated: Process released due to completion or by some issue
What is a thread?
A program in execution w/out dedicated address space: threads of the same process share address space
Processes vs threads, describe some characteristics of threads.
Threads:
- No data segment or heap
- Multiple can coexist in a process
- Share code, data, heap, I/O
- Have own stack and registers
- Inexpensive to create
- Inexpensive context switching
- Efficient communication
Processes vs threads, describe some characteristics of processes.
Processes:
- Have data/code/heap
- Include at least one thread
- Have own address space, isolated from other processes
- Expensive to create
- Expensive context switching
- IPC can be expensive
What are the pros and cons of user-level threads?
Pros:
- No OS support needed
- Lightweight (thread switching)
- Local procedure
- Customized scheduling algorithm
Cons:
- Blocking system
- Page fault
- Do not have access to the system clock interrupt system
What are the pros and cons of kernel-level threads?
Pros:
- Threads known to OS, can be scheduled by OS, which improves performance for multiple threads
- Less likely for a single thread to affect others
Cons:
- Slow (context switch overhead)
- Expensive to create and switch
What are the different types of CPU scheduling?
- First-come-first-serve (FCFS)
- Shortest job first (SJF)
- Round Robin (RR)
What is mutual exclusion and critical regions?
Mutual exclusion: If one process is using a shared variable or file, other processes will be excluded from doing the same thing
Critical region(s): part(s) of a program where the shared resource is accessed.