Operating Systems (Midterm) Flashcards

1
Q

What are a computer’s two modes of operation?

A
  1. User mode (application)
  2. Kernel mode (OS kernel)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the transitions between user/kernel mode?

A
  1. Hardware interrupt: HW device requests OS services (asynchronous, event-triggered)
  2. System call (aka trap): User program requests OS services (synchronous, program-triggered)
  3. Exception: Error handling (Invalid memory access, invalid permission, etc.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe a monolithic kernel

A

Monolithic kernel: A large process running entirely in a single address space (single binary file)
- All kernel services execute in kernel address space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the pros and cons of a monolithic kernel?

A

Pros:
- Fast
Cons:
- Huge kernel, harder to maintain
- No protection between kernel components
- Complex dependencies, not easily extensible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe a microkernel

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the pros and cons of a microkernel?

A

Pros:
- Modular design, easily extensible
- Easy to maintain
- More reliable + secure
Cons:
- Performance loss
- Complicated process management

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

On a magnetic disk, read/write data is a 3-stage process. What are the three steps and which is the longest?

A
  1. Seek time: Position the arm over the proper track (longest time)
  2. Rotational latency: Wait for the desired sector to rotate under the read/write head
  3. Transfer time: Transfer a block of bits (sector) under the read/write head
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you make information generated by HW device events available to running applications?

A
  1. Polling
  2. (HW) Interrupt
  3. DMA
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain polling

A

Polling (busy waiting):
- I/O device puts information in a status register.
- OS periodically checks the status register
(SIMPLE, WASTES CPU CYCLES, LATENCY)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain HW interrupt

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Briefly explain DMA

A

Direct memory access, delegate I/O responsibility from CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a process?

A

An instance of a program running on a computer.
An abstraction that supports running programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between a program and a process?

A
  • 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())
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the fork() function do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What makes output deterministic?

A

Deterministic: Output stays the same no matter no matter how many times it’s run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are 5 process management system calls?

A
  1. fork: Creates a new process
  2. exec: Execute a new process image
  3. exit: voluntary process termination
  4. wait: parent wait for child to finish
  5. kill: send a signal to process (or group), can cause involuntary process termination
17
Q

What is the 5-state process model?

A
  1. New: New process is first accepted into the queue
  2. Ready: Process is waiting to be selected to run
  3. Blocked: Process is waiting for some event
  4. Running: Process current being executed by CPU
  5. Terminated: Process released due to completion or by some issue
18
Q

What is a thread?

A

A program in execution w/out dedicated address space: threads of the same process share address space

19
Q

Processes vs threads, describe some characteristics of threads.

A

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

20
Q

Processes vs threads, describe some characteristics of processes.

A

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

21
Q

What are the pros and cons of user-level threads?

A

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

22
Q

What are the pros and cons of kernel-level threads?

A

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

23
Q

What are the different types of CPU scheduling?

A
  1. First-come-first-serve (FCFS)
  2. Shortest job first (SJF)
  3. Round Robin (RR)
24
Q

What is mutual exclusion and critical regions?

A

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.

25
Q

What is busy waiting? What are the pros and cons of busy waiting?

A

Busy waiting: Continuously testing a variable until some value appears (spin lock)
Pros:
- Avoids expensive context switching when CR is very short
Cons:
- Wastes CPU cycles
- Priority inversion problem

26
Q

What is sleep-and-wakeup? What are the pros and cons of sleep-and-wakeup?

A

Sleep-and-wakeup: Uses IPC primates (sleep and wakeup) that manage access to a shared variable.
Pros:
- Less CPU-costly
- Avoids priority inversion problem
Cons:
- Requires context switching

27
Q

When should you use busy waiting? When should you use sleep-and-wakeup?

A

Busy waiting is used for a few processes or when critical region (CR) is very short. Sleep-and-wakeup is used for multi-threaded applications with many processes.
Sleep-and-wakeup used on single-core systems, busy waiting on multi-core systems.