B CompE Bachelor of Computer Engineering Bachelor of Computer Engineering Operating System 4 — Questions and Answers
Question 1: Which synchronization construct guarantees that only one thread executes a protected block at a time and automatically releases on exit, including via exceptions?
- Counting semaphore
- Spinlock
- Monitor (Correct answer)
- Barrier
Correct answer: Monitor
A monitor encapsulates shared data with mutual exclusion and condition variables, automatically releasing the lock when the thread exits the protected procedure.
Question 2: In the Banker's Algorithm for deadlock avoidance, what does the 'safe state' guarantee?
- No process is currently waiting
- There exists a sequence in which every process can obtain its maximum resources and finish (Correct answer)
- All resources are allocated optimally
- No circular wait can form
Correct answer: There exists a sequence in which every process can obtain its maximum resources and finish
A safe state means the OS can find an ordering (safe sequence) of processes such that each can run to completion using currently available and released resources.
Question 3: What is the role of the 'inode' in Unix/Linux file systems?
- Store the file's actual data blocks
- Hold metadata (permissions, size, block pointers) about a file (Correct answer)
- Map file names to directory entries
- Cache recently accessed file content
Correct answer: Hold metadata (permissions, size, block pointers) about a file
An inode stores file metadata including owner, permissions, timestamps, size, and pointers to data blocks, but not the file name itself.
Question 4: Which CPU scheduling algorithm can lead to indefinite postponement (starvation) of long jobs in favor of shorter ones?
- Round Robin
- FCFS
- SJF (non-preemptive)
- Priority Scheduling (Correct answer)
Correct answer: Priority Scheduling
Priority Scheduling may indefinitely delay low-priority processes if higher-priority processes keep arriving; aging is the standard mitigation.
Question 5: What distinguishes a 'thread' from a 'process' in modern operating systems?
- Threads have separate address spaces; processes share one
- Threads share the address space of their process; processes have independent address spaces (Correct answer)
- Threads cannot communicate; processes use pipes
- Threads require separate page tables
Correct answer: Threads share the address space of their process; processes have independent address spaces
Threads within the same process share code, data, and open file descriptors but have individual stacks and register sets, making context switching cheaper.
Question 6: In memory management, what is 'internal fragmentation'?
- Unused memory between allocated segments
- Wasted space within an allocated block due to fixed partition size (Correct answer)
- Memory lost to page table overhead
- Fragmentation caused by disk seeks
Correct answer: Wasted space within an allocated block due to fixed partition size
Internal fragmentation occurs when a process is allocated more memory than it requested (e.g., due to fixed partition or page size), leaving unused bytes inside the allocated region.
Question 7: Which system call in Linux changes the priority (nice value) of a running process?
- setpriority()
- renice()
- nice() (Correct answer)
- sched_setparam()
Correct answer: nice()
nice() adjusts the scheduling priority of the calling process by adding an increment to its current nice value, affecting how much CPU time it receives.
Which synchronization construct guarantees that only one thread executes a protected block at a time and automatically releases on exit, including via exceptions?