Multithreading MCQ Questions - C Programming
This section focuses on the "Multithreading" in C programming. These Multiple Choice Questions (MCQ) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Thread are often called as ?
A. heavyweight processes
B. lightweight processes
C. both a and b
D. None of the above
View Answer
Ans : B
Explanation: Thread are often called as lightweight processes.
2. Threads operate faster than processes.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, Threads operate faster than processes.
3. In C programming, multithreading can be implemented using the ____________ library
A. cthreads
B. cppthreads
C. pthreads
D. pnthreads
View Answer
Ans : C
Explanation: In C programming, multithreading can be implemented using the pthreads library.
4. In general, there are _________ types of multitasking.
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : B
Explanation: In general, there are two types of multitasking: process-based and thread-based.
5. A multithreaded program contains _________ parts that can run concurrently.
A. two
B. three
C. two or more
D. three or more
View Answer
Ans : C
Explanation: A multithreaded program contains two or more parts that can run concurrently.
6. __________ is used to explicitly exit a thread.
A. exit
B. pthread_exit
C. exit_pthread
D. Both B and C
View Answer
Ans : B
Explanation: pthread_exit is used to explicitly exit a thread.
7. What is the purpose of the pthread_create() function?
A. To create a new thread
B. To terminate a thread
C. To synchronize threads
D. To allocate memory for a thread
View Answer
Ans : A
Explanation: pthread_create() function is used to create a new thread
8. mutex is a synchronization primitive used to prevent multiple threads from accessing a shared resource simultaneously.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, mutex is a synchronization primitive used to prevent multiple threads from accessing a shared resource simultaneously
9. __________ that can be called from multiple threads simultaneously without causing a race condition.
A. thread function
B. safe function
C. both a and b
D. thread-safe function
View Answer
Ans : D
Explanation: thread-safe function that can be called from multiple threads simultaneously without causing a race condition.
10. _______________ is a synchronization primitive used to prevent multiple threads from accessing a shared resource simultaneously.
A. mutex
B. semaphore
C. deadlock
D. race
View Answer
Ans : B
Explanation: semaphore is synchronization primitive used to prevent multiple threads from accessing a shared resource simultaneously.
Discussion