System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 152
Q3361:
In the Consume thread, what prevents processing the same message twice?
A. Check on fReady flag
B. Mutex locking
C. Event signaling
D. Semaphore wait
Correct Answer:
A
Chapter: 152
Q3362:
Which function is called to release the mutex after message filling?
A. ReleaseMutex
B. WaitForSingleObject
C. SetEvent
D. InterlockedIncrement
Correct Answer:
A
Chapter: 152
Q3363:
What does the InterlockedIncrement(&mBlock.nCons) in Consume() do?
A. Atomically increments consumed message count
B. Signals the producer thread
C. Resets fReady
D. Decrements lost message count
Correct Answer:
A
Chapter: 152
Q3364:
MessageDisplay uses _tctime_s to:
A. Convert timestamp to string
B. Generate checksum
C. Lock mutex
D. Signal event
Correct Answer:
A
Chapter: 152
Q3365:
What type of event is mReady created as?
A. Auto-reset
B. Manual-reset
C. Counting
D. Binary
Correct Answer:
A
Chapter: 152
Q3366:
What happens when command 'c' is entered in the consumer thread?
A. The next message is consumed
B. The consumer thread stops
C. The producer thread starts
D. A checksum is calculated
Correct Answer:
A
Chapter: 152
Q3367:
What does the WaitForSingleObject function do?
A. Waits for a synchronization object to be signaled
B. Creates a thread
C. Locks a mutex
D. Initializes a message buffer
Correct Answer:
A
Chapter: 152
Q3368:
The checksum of the message is calculated using which method?
A. Bitwise XOR
B. Addition
C. Multiplication
D. Division
Correct Answer:
A
Chapter: 152
Q3369:
The MSG_BLOCK contains a volatile keyword for which variables?
A. mSequence and nCons
B. mGuard and mReady
C. fReady and fStop
D. mData and mChecksum
Correct Answer:
A
Chapter: 152
Q3370:
The function _beginthreadex is used to:
A. Create threads
B. Create mutexes
C. Signal events
D. Lock resources
Correct Answer:
A
Chapter: 152
Q3371:
What is the effect of calling CloseHandle on mutex and event objects?
A. Releases system resources
B. Starts the threads
C. Increments counters
D. Validates checksum
Correct Answer:
A
Chapter: 152
Q3372:
The consumer thread stops when:
A. User enters 's' command
B. All messages are consumed
C. Producer thread ends
D. Checksum fails
Correct Answer:
A
Chapter: 152
Q3373:
The producer thread generates messages at:
A. Random intervals
B. Fixed intervals
C. At user input
D. Constant speed
Correct Answer:
A
Chapter: 152
Q3374:
What does the MessageFill function update besides mData?
A. mChecksum and mTimestamp
B. fReady and fStop
C. mGuard and mReady
D. nCons and nLost
Correct Answer:
A
Chapter: 152
Q3375:
Which Windows API function is used to create an auto-reset event?
A. CreateEvent
B. CreateMutex
C. WaitForSingleObject
D. SetEvent
Correct Answer:
A
Chapter: 152
Q3376:
The producer-consumer problem is an example of:
A. Inter-thread synchronization
B. Database locking
C. File handling
D. Memory management
Correct Answer:
A
Chapter: 152
Q3377:
The variable nLost keeps track of:
A. Messages lost during processing
B. Messages consumed
C. Mutex locks
D. Event signals
Correct Answer:
A
Chapter: 152
Q3378:
The interlocked functions provide:
A. Atomic operations
B. Thread creation
C. Event signaling
D. Mutex locking
Correct Answer:
A
Chapter: 152
Q3379:
The variable mChecksum is used for:
A. Verifying message integrity
B. Controlling thread access
C. Signaling message readiness
D. Counting messages
Correct Answer:
A
Chapter: 152
Q3380:
Which Windows API is used to wait indefinitely for a synchronization object?
A. WaitForSingleObject
B. CreateMutex
C. CreateEvent
D. SetEvent
Correct Answer:
A