Question 1
EasyWhat is a critical section?
- A.
A section of memory reserved for the OS
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Operating Systems
What is a critical section?
A section of memory reserved for the OS
A part of code that accesses shared data and must not run in two processes at once
A function that never returns
The first line of a program
Answer: B
Code that reads or writes shared resources is a critical section; only one process or thread should execute it at a time.
What is a race condition?
When the result depends on the order in which processes or threads run
When a process never finishes
When two processes finish at the same time
When the CPU runs too fast
Answer: A
Unsynchronised access to shared data can give different results depending on timing — a race condition.
What is a mutex lock mainly used for?
Scheduling the CPU
Allocating memory
Reading files faster
Mutual exclusion: letting only one thread into a critical section at a time
Answer: D
A thread acquires the mutex before entering the critical section and releases it on leaving.
What are the two atomic operations on a semaphore?
wait (P) and signal (V)
push and pop
read and write
lock and fork
Answer: A
wait() decrements the semaphore (blocking if it can't), and signal() increments it, possibly waking a waiter.
What values can a binary semaphore take?
Only positive integers
0 and 1
−1, 0 and 1
Any integer
Answer: B
A binary semaphore works like a lock: 1 means free, 0 means taken.
A solution to the critical-section problem must provide mutual exclusion, progress and…?
Minimum memory use
Priority inheritance
Bounded waiting
Maximum throughput
Answer: C
Bounded waiting means a process waiting to enter will get in after a limited number of others have entered.
What is busy waiting?
A process with high priority
A process repeatedly checking a condition in a loop while waiting
A process sleeping until it is woken
A process waiting for disk I/O
Answer: B
Busy waiting (spinning) uses CPU time while waiting, unlike blocking, where the process sleeps.
What does mutual exclusion mean?
Processes never share data
All processes run at the same time
Only one process at a time may be in its critical section
Each process has its own CPU
Answer: C
Mutual exclusion prevents two processes from changing shared data at the same moment.
What is a semaphore?
A file lock stored on disk
A network signal
A type of CPU register
An integer variable used for synchronisation, changed only by atomic wait and signal operations
Answer: D
Semaphores, introduced by Dijkstra, let processes wait for and signal each other safely.
What is a counting semaphore typically used for?
Controlling access to a resource that has several identical instances
Counting users on a system
Counting the number of files
Counting CPU cycles
Answer: A
Its value records how many instances are free; wait() takes one and signal() returns one.