Operating Systems Final Exam

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:17 AM on 4/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

24 Terms

1
New cards

Interrupt

A signal to the CPU to request immediate attention, temporarily halting current execution.

2
New cards

Interrupt Handling Process

The sequence of steps the OS takes when an interrupt fires.

Step 1 — Receive: Hardware raises an interrupt signal on the CPU's interrupt line.

Step 2 — Save state: CPU finishes the current instruction, then saves registers & program counter onto the kernel stack.

Step 3 — Identify: CPU reads the interrupt vector table to find the address of the correct ISR.

Step 4 — Execute ISR: Kernel runs the Interrupt Service Routine to handle the event (e.g. read from device buffer).

Step 5 — Restore & resume: Saved state is restored; CPU returns to user mode and continues the interrupted process.

3
New cards

Kernel

The privileged core of the OS that manages hardware, memory, processes, and I/O. Runs in kernel mode.

4
New cards

System Call

A controlled entry point through which a user program requests a privileged service (open file, allocate memory, send data).

5
New cards

User Mode

Restricted mode for running application code. Cannot execute privileged instructions or access hardware directly

6
New cards

Kernel Mode

Full privilege level. Can execute any instruction, access all memory, and control hardware. OS runs here.

7
New cards

Program

A static file on disk — executable instructions and data. Has no CPU or memory allocation by itself.

8
New cards

Process

A running instance of a program. Has its own address space (code, heap, stack), open files, and OS resources. Unit of isolation.

9
New cards

Thread

A unit of execution within a process. Shares the process's address space (heap, globals) but has its own stack and registers. Unit of concurrency.

10
New cards

Key Contrast

Multiple threads in a process share memory (fast, but risky). Multiple processes have separate memory (safe, but costly to communicate).

11
New cards

Executor

An interface (java.util.concurrent) that decouples task submission from thread management. Call executor.execute(task) without worrying about thread lifecycle.

12
New cards

Runnable

Functional interface with run() — no return value, cannot throw checked exceptions. Use when you just need to perform a side effect.

13
New cards

Callable

Functional interface with call() — returns a value V and can throw checked exceptions. Submitted via submit(), returns a Future.

14
New cards

Critical section

A block of code that accesses shared data — only one thread/process should execute it at a time.

15
New cards

Three requirements of synchronization

Requirement 1: Mutual exclusion: At most one thread is in the critical section at any time.

Requirement 2: Progress: If no thread is in the critical section, a waiting thread must eventually be allowed in (no deadlock).

Requirement 3: Bounded waiting: A thread waiting to enter the critical section must eventually succeed — no starvation.

16
New cards

Bounded Buffer

Fixed-size buffer (capacity N). Producer must wait if buffer is full. Consumer must wait if buffer is empty. Both wait conditions must be handled.

17
New cards

Unbounded buffer

Conceptually infinite capacity. Producer never blocks. Consumer still waits if buffer is empty.

18
New cards

Primary purpose of dual-mode operation

Differentiate between user processes and kernel services.

19
New cards

Function of an interrupt

A signal to the CPU to request immediate attention, temporarily halting current execution.

20
New cards

Role of an Executor in Java

Represents a thread pool.

21
New cards

Requirement for thread synchronization?


Safety (mutual exclusion) — this IS a requirement.

Liveness/progress — this IS a requirement.

Bounded waiting — this IS a requirement.

22
New cards

Layered synchronization framework (short answer)

Hardware primitives — atomic instructions like test-and-set, compare-and-swap (CAS), and fetch-and-add. These are the only truly atomic operations; everything else is built from them.

2OS-level primitives — mutex locks and semaphores. Built using hardware primitives + OS scheduler support so waiting threads block (sleep) instead of busy-waiting.

3Language-level monitors — Java's synchronized keyword, ReentrantLock, and Condition variables. Wrap mutex + condition variable patterns in a safer, language-integrated API.

4High-level abstractions — thread-safe collections (ConcurrentHashMap), BlockingQueue, atomic types (AtomicInteger). Use lower layers internally so application code avoids explicit locking.

23
New cards

Identify the critical section

public void run() {
k++; // <-- critical section
}

24
New cards

Write the consumer pseudo-code for bounded buffer

Producer (given)

lock.lock();
while (queue.size() == N) {
itemRemoved.await(lock); // wait if full
}
add an item to the buffer;
itemAdded.signal(lock); // wake a waiting consumer
lock.unlock();

Consumer (your answer)

lock.lock();
while (queue.size() == 0) {
itemAdded.await(lock); // wait if empty
}
remove an item from the buffer;
itemRemoved.signal(lock); // wake a waiting producer
lock.unlock();