Practice
Solution
Step 1: Understand resource sharing in threads
Threads within the same process share memory and resources, allowing efficient communication and lower overhead compared to processes.Step 2: Compare overhead of context switching
Thread context switching is lighter than process context switching, making threads better for high concurrency.Step 3: Evaluate options
Use multiple processes, each handling a single client request independently uses processes, which have higher overhead and less efficient resource sharing. Use a single-threaded process with blocking I/O for all requests is single-threaded and blocks, limiting concurrency. Use multiple processes with shared memory segments for communication adds complexity with shared memory and still has process overhead.Final Answer:
Option A -> Option AQuick Check:
Threads maximize resource sharing and minimize overhead for concurrent tasks [OK]
- Assuming processes are always better for concurrency
- Ignoring context switching overhead differences
- Believing shared memory between processes is as simple as threads
Solution
Step 1: Understand Round Robin's fairness goal
Round Robin scheduling is designed to allocate CPU time slices fairly among all processes, especially when burst times vary widely.Step 2: Analyze other options
When all processes have identical priorities and long CPU bursts is less suitable because identical priorities and long bursts favor FCFS or SJF for efficiency, not fairness. When minimizing average turnaround time is the only goal ignores fairness and focuses only on turnaround time, which RR does not optimize. When processes have strict deadlines and real-time constraints requires real-time guarantees, which RR cannot provide due to its time slicing.Final Answer:
Option A -> Option AQuick Check:
RR is best when fairness and responsiveness matter, especially with variable burst times.
- Assuming RR always minimizes turnaround time
- Believing RR suits real-time deadlines
- Confusing RR with priority-based scheduling
Solution
Step 1: User program issues system call
The user program executes a special instruction causing a trap to kernel mode.Step 2: CPU switches to kernel mode
Control transfers to the OS kernel with elevated privileges.Step 3: Kernel validates system call
The kernel inspects the system call number and arguments to ensure they are valid and safe.Step 4: Why other options are incorrect
The kernel copies data directly to the user buffer without validation is unsafe; kernel must validate before copying data. The user program resumes execution in user mode happens after system call completion, not immediately after mode switch. The hardware raises an interrupt to the device is unrelated here; hardware interrupts occur asynchronously, not immediately after mode switch.Final Answer:
Option A -> Option AQuick Check:
System call trap -> kernel mode -> validate call -> execute service [OK]
- Assuming kernel copies data before validation
- Confusing interrupt handling with system call flow
- Thinking user mode resumes immediately after trap
Solution
Step 1: Define livelock behavior
Livelock involves processes actively changing states but failing to make progress, unlike deadlock where processes are blocked.Step 2: Analyze each statement
Livelock occurs when processes continuously change state in response to each other without making progress correctly describes livelock. Livelock can be resolved by introducing random delays or backoff strategies is true; random backoff can resolve livelock. In livelock, processes are blocked and waiting indefinitely for resources is incorrect because livelock processes are not blocked but active. Livelock differs from deadlock because processes remain active rather than blocked correctly contrasts livelock and deadlock.Final Answer:
Option D -> Option DQuick Check:
Livelock means active but no progress, not blocked waiting.
- Confusing livelock with deadlock
- Assuming livelock processes are blocked
Solution
Step 1: Review privilege separation
User mode is restricted; kernel mode has full privileges.Step 2: Validate each statement
User mode code cannot directly access kernel memory for protection reasons. is true; user mode cannot access kernel memory. Kernel mode has unrestricted access to all hardware and memory. is true; kernel mode has full access. Mode switches are triggered by traps or interrupts to ensure controlled privilege escalation. is true; traps/interrupts cause mode switches.Step 3: Identify incorrect statement
System calls execute entirely in user mode without switching to kernel mode. is false; system calls require switching to kernel mode to execute privileged operations.Final Answer:
Option D -> Option DQuick Check:
System calls always involve mode switch to kernel [OK]
- Believing system calls run entirely in user mode
- Confusing hardware interrupts with system calls
- Assuming user mode can access kernel memory
