1/23
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
Interrupt
A signal to the CPU to request immediate attention, temporarily halting current execution.
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.
Kernel
The privileged core of the OS that manages hardware, memory, processes, and I/O. Runs in kernel mode.
System Call
A controlled entry point through which a user program requests a privileged service (open file, allocate memory, send data).
User Mode
Restricted mode for running application code. Cannot execute privileged instructions or access hardware directly
Kernel Mode
Full privilege level. Can execute any instruction, access all memory, and control hardware. OS runs here.
Program
A static file on disk — executable instructions and data. Has no CPU or memory allocation by itself.
Process
A running instance of a program. Has its own address space (code, heap, stack), open files, and OS resources. Unit of isolation.
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.
Key Contrast
Multiple threads in a process share memory (fast, but risky). Multiple processes have separate memory (safe, but costly to communicate).
Executor
An interface (java.util.concurrent) that decouples task submission from thread management. Call executor.execute(task) without worrying about thread lifecycle.
Runnable
Functional interface with run() — no return value, cannot throw checked exceptions. Use when you just need to perform a side effect.
Callable
Functional interface with call() — returns a value V and can throw checked exceptions. Submitted via submit(), returns a Future.
Critical section
A block of code that accesses shared data — only one thread/process should execute it at a time.
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.
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.
Unbounded buffer
Conceptually infinite capacity. Producer never blocks. Consumer still waits if buffer is empty.
Primary purpose of dual-mode operation
Differentiate between user processes and kernel services.
Function of an interrupt
A signal to the CPU to request immediate attention, temporarily halting current execution.
Role of an Executor in Java
Represents a thread pool.
Requirement for thread synchronization?
Safety (mutual exclusion) — this IS a requirement.
Liveness/progress — this IS a requirement.
Bounded waiting — this IS a requirement.
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.
Identify the critical section
public void run() {
k++; // <-- critical section
}
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();