System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 148
Q3261:
In producer-consumer synchronization, the consumer thread calls _______ to decrease the semaphore count.
A. WaitSemaphore()
B. ReleaseSemaphore()
C. CreateSemaphore()
D. OpenSemaphore()
Correct Answer:
A
Chapter: 148
Q3262:
Semaphore count can never exceed _______.
A. the initial value
B. the number of threads
C. the maximum value
D. set during creation
Correct Answer:
D
Chapter: 148
Q3263:
Using semaphores removes the need to _______ threads manually after creation.
A. suspend
B. start
C. terminate
D. restart
Correct Answer:
A
Chapter: 148
Q3264:
Threads waiting on a semaphore are in a _______ state.
A. running
B. blocked
C. suspended
D. terminated
Correct Answer:
B
Chapter: 149
Q3265:
A thread requesting to decrease the semaphore count by 2 must call wait _______ times.
A. once
B. twice
C. three
D. twice but atomically
Correct Answer:
B
Chapter: 149
Q3266:
The problem with calling wait twice on a semaphore is that the calls are not _______.
A. atomic
B. synchronous
C. asynchronous
D. deterministic
Correct Answer:
A
Chapter: 149
Q3267:
If wait functions are not atomic, the execution may switch between threads causing _______.
A. deadlock
B. deadlock-like situation
C. successful synchronization
D. resource leak
Correct Answer:
B
Chapter: 149
Q3268:
To avoid switching between two wait functions, use _______ to make them atomic.
A. Mutex
B. CriticalSection
C. Lock
D. Semaphore
Correct Answer:
B
Chapter: 149
Q3269:
WaitForMultipleObjects() fails when it detects _______ objects in the array.
A. duplicate
B. unique
C. uninitialized
D. null
Correct Answer:
A
Chapter: 149
Q3270:
Using WaitForMultipleObjects() with duplicate semaphore references may cause all handles to get _______ even if count is 1.
A. signals
B. blocked
C. released
D. waiting
Correct Answer:
A
Chapter: 149
Q3271:
CriticalSection is used to avoid _______ during the wait calls.
A. context switching
B. resource allocation
C. thread blocking
D. thread switching
Correct Answer:
D
Chapter: 149
Q3272:
Calling wait twice on a semaphore is not atomic because the wait calls are _______ functions.
A. separate
B. combined
C. synchronized
D. blocking
Correct Answer:
A
Chapter: 149
Q3273:
The limitation of semaphores arises because they do not support _______ operations on multiple wait calls.
A. atomic
B. parallel
C. synchronized
D. serial
Correct Answer:
A
Chapter: 149
Q3274:
WaitForMultipleObjects() with multiple references to the same semaphore is not a valid solution because it _______.
A. works perfectly
B. fails due to duplicates
C. succeeds always
D. ignores duplicates
Correct Answer:
B
Chapter: 149
Q3275:
In the semaphore limitation scenario, thread switching between wait calls can lead to _______.
A. deadlock
B. race condition
C. memory leak
D. successful execution
Correct Answer:
A
Chapter: 149
Q3276:
To prevent deadlock-like situations caused by multiple wait calls, a _______ can be used.
A. CriticalSection
B. Mutex
C. Semaphore
D. Lock
Correct Answer:
A
Chapter: 149
Q3277:
The primary issue with calling wait multiple times on a semaphore is the lack of _______ between calls.
A. atomicity
B. thread safety
C. parallelism
D. synchronization
Correct Answer:
A
Chapter: 149
Q3278:
Deadlocks caused by semaphore wait switching can be prevented by making wait calls _______.
A. independent
B. atomic
C. concurrent
D. asynchronous
Correct Answer:
B
Chapter: 149
Q3279:
WaitForMultipleObjects() cannot be used with multiple identical handles because it _______.
A. does not detect duplicates
B. fails
C. ignores duplicates
D. locks handles
Correct Answer:
B
Chapter: 149
Q3280:
Semaphore waits that are not atomic may cause _______ between threads during execution.
A. context switching
B. parallel execution
C. atomic execution
D. thread synchronization
Correct Answer:
A