System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 136
Q2921:
The example DWORD N=0; inside a for loop in a single-threaded program is ________.
A. safe
B. dangerous
C. incorrect
D. multithreaded
Correct Answer:
A
Chapter: 136
Q2922:
In the for loop, N += ThreadFunc(pArgs); aggregates return values ________.
A. in multiple threads
B. in parallel threads
C. in serial fashion
D. via external function
Correct Answer:
C
Chapter: 136
Q2923:
A global variable modified by multiple threads simultaneously requires ________.
A. no changes
B. user input
C. synchronization
D. recursion
Correct Answer:
C
Chapter: 136
Q2924:
Using the same variable in multiple threads without isolation leads to data ________.
A. encapsulation
B. protection
C. duplication
D. corruption
Correct Answer:
D
Chapter: 136
Q2925:
ThreadFunc should return a value rather than modifying a shared variable to ensure ________.
A. clarity
B. speed
C. thread safety
D. concurrency
Correct Answer:
C
Chapter: 136
Q2926:
Variables used to return thread-specific results should be declared ________ the thread.
A. outside
B. inside
C. globally
D. statically
Correct Answer:
B
Chapter: 136
Q2927:
If a function modifies a global variable for its local logic, it is a ________ design.
A. secure
B. standard
C. flawed
D. optimal
Correct Answer:
C
Chapter: 136
Q2928:
Global variables can safely be used in threads if the data is ________.
A. user input
B. OS-specific
C. shared among all threads
D. output only
Correct Answer:
C
Chapter: 136
Q2929:
The main problem with using global variables in threads is ________.
A. long execution time
B. high memory usage
C. unpredictable results
D. low CPU load
Correct Answer:
C
Chapter: 137
Q2930:
Thread-safe code ensures that multiple threads can execute code without ________.
A. memory allocation
B. blocking I/O
C. synchronization issues
D. variable declarations
Correct Answer:
C
Chapter: 137
Q2931:
Variables that are local to a thread should be placed in ________.
A. global memory
B. registers
C. stack or TLS
D. file system
Correct Answer:
C
Chapter: 137
Q2932:
What should be avoided when writing thread-safe code?
A. using TLS
B. race conditions
C. stack memory
D. synchronization
Correct Answer:
B
Chapter: 137
Q2933:
Which storage is suitable for thread-specific data?
A. file system
B. global memory
C. static storage
D. thread-local storage
Correct Answer:
D
Chapter: 137
Q2934:
Race conditions can be prevented by using ________.
A. mutexes and synchronization objects
B. recursion
C. pointers
D. global variables
Correct Answer:
A
Chapter: 137
Q2935:
What happens if one thread modifies the process environment?
A. No effect
B. Only that thread is affected
C. All threads are affected
D. OS halts
Correct Answer:
C
Chapter: 137
Q2936:
Changing standard input or output in a thread can affect ________.
A. only that thread
B. the file system
C. other threads
D. process priority
Correct Answer:
C
Chapter: 137
Q2937:
Variables that need to be shared among threads should be protected using ________.
A. static functions
B. recursion
C. memory barriers
D. file locks
Correct Answer:
C
Chapter: 137
Q2938:
One of the key goals of thread-safe code is to avoid ________.
A. stack overflow
B. deadlocks
C. synchronization
D. data corruption
Correct Answer:
D
Chapter: 137
Q2939:
A function being used by several threads must store thread-specific variables in ________.
A. shared registers
B. TLS or dedicated DS
C. environment variables
D. disk cache
Correct Answer:
B
Chapter: 137
Q2940:
Threads should avoid changing ________ devices.
A. local
B. virtual
C. standard input/output
D. USB
Correct Answer:
C