AMCAT Operating Systems Fundamentals 3 — Questions and Answers
Question 1: What is the purpose of the Translation Lookaside Buffer (TLB) in virtual memory?
- To store recently accessed data from the hard disk
- To cache recently used virtual-to-physical address translations for faster page table lookups (Correct answer)
- To buffer network packets before processing
- To translate programming languages to machine code
Correct answer: To cache recently used virtual-to-physical address translations for faster page table lookups
The TLB is a high-speed cache that stores recent virtual-to-physical page number translations. Since every memory access requires a page table lookup to convert virtual addresses to physical addresses, the TLB dramatically speeds up this process by caching frequently used translations.
Question 2: In the context of inter-process communication (IPC), what is a race condition?
- When two processes compete for CPU time
- When the outcome of a program depends on the unpredictable timing of multiple processes accessing shared data (Correct answer)
- When a process runs faster than expected
- When the scheduler assigns priority based on process speed
Correct answer: When the outcome of a program depends on the unpredictable timing of multiple processes accessing shared data
A race condition occurs when two or more processes access shared data concurrently, and the final result depends on the specific order in which their operations are interleaved. This non-deterministic behavior can lead to bugs that are difficult to reproduce and debug.
Question 3: Which disk scheduling algorithm processes requests in the order of the shortest seek time from the current head position?
- FCFS (First Come First Served)
- SSTF (Shortest Seek Time First) (Correct answer)
- SCAN (Elevator algorithm)
- C-LOOK
Correct answer: SSTF (Shortest Seek Time First)
SSTF selects the disk request that requires the least head movement from the current position. While it provides better average response time than FCFS, it can lead to starvation of requests far from the current head position.
Question 4: What is the key difference between a monolithic kernel and a microkernel?
- A monolithic kernel is smaller in size than a microkernel
- A microkernel runs most OS services in user space, while a monolithic kernel runs them all in kernel space (Correct answer)
- A monolithic kernel supports only one process at a time
- A microkernel does not support device drivers
Correct answer: A microkernel runs most OS services in user space, while a monolithic kernel runs them all in kernel space
In a monolithic kernel (like Linux), all OS services (file systems, device drivers, networking) run in kernel space. In a microkernel (like Minix, L4), only essential services (IPC, basic scheduling, memory management) run in kernel space, while others run in user space as separate processes.
Question 5: In the producer-consumer problem, what is the role of the buffer?
- It stores the program's source code
- It acts as a shared storage area where the producer places items and the consumer retrieves them (Correct answer)
- It encrypts data during transfer between processes
- It schedules the order of producer and consumer execution
Correct answer: It acts as a shared storage area where the producer places items and the consumer retrieves them
The buffer in the producer-consumer problem is a shared, fixed-size storage area. The producer generates data items and places them into the buffer. The consumer retrieves and processes items from the buffer. Synchronization is needed to prevent the producer from writing to a full buffer or the consumer from reading an empty buffer.
Question 6: What happens during a context switch in an operating system?
- The CPU is restarted
- The state of the currently running process is saved and the state of the next scheduled process is loaded (Correct answer)
- All processes are terminated and restarted
- The operating system is upgraded to a new version
Correct answer: The state of the currently running process is saved and the state of the next scheduled process is loaded
A context switch saves the state (registers, program counter, stack pointer, etc.) of the currently running process into its Process Control Block (PCB), then loads the saved state of the next process to be executed. This allows the CPU to switch between processes, enabling multitasking.
What is the purpose of the Translation Lookaside Buffer (TLB) in virtual memory?