Threads and Multithreading - multicore programming, multithreading models, thread libraries, implicit threading, threading issues - One Line Questions
1.
In the one-to-one multithreading model, what is a potential drawback? —
High overhead due to creating a kernel thread for each user thread
2.
What is a 'spin lock'? —
A lock that causes a thread to busy-wait (spin) until the lock is available
3.
What is thread-local storage (TLS)? —
A technique where each thread has its own copy of a variable
4.
What is a 'critical section' in multithreading? —
A block of code that accesses shared resources and must be protected from concurrent access
5.
Which of the following best describes a 'task' in task-based parallelism (often used in implicit threading)? —
A unit of work that can be executed independently
6.
What is starvation in multithreading? —
A condition where a thread is perpetually denied access to necessary resources
7.
What is a deadlock in the context of multithreading? —
A state where two or more threads are blocked forever, each waiting for the other to release a resource
8.
What is a 'detached thread' in multithreading? —
A thread whose resources are automatically reclaimed upon termination without needing to be joined
9.
Which of the following best describes a thread? —
A lightweight process sharing resources with other threads in the same process
10.
Which of the following is a common synchronization problem that can occur if not managed carefully? —
Race condition
11.
Which threading issue arises when multiple threads access and modify shared data concurrently, leading to unpredictable results? —
Race condition
12.
Which threading issue involves threads repeatedly making progress but failing to reach a final goal due to continuous changes in the system state? —
Livelock
13.
Which of the following is a characteristic of implicit threading? —
The creation and management of threads are hidden from the developer
14.
In multicore programming, what does 'load balancing' refer to? —
Distributing computational work evenly across available cores
15.
In the context of multicore programming, what is a common challenge faced by developers? —
Efficiently distributing work across multiple cores
16.
Which type of threading abstracts thread creation and management away from the programmer, often using libraries or language features? —
Implicit threading
17.
In the context of POSIX Threads (pthreads), what is a common function for creating a new thread? —
pthread_create()
18.
Which of the following is a disadvantage of the many-to-one multithreading model? —
A blocking system call by one thread blocks all threads
19.
What is a potential problem with fine-grained locking (using many locks for small sections of data)? —
Increased complexity and potential for deadlock
20.
What is the primary advantage of using threads within a single process? —
Reduced overhead for context switching compared to processes
21.
What is a potential issue with using a large number of kernel threads in the one-to-one model? —
High overhead and resource consumption
22.
Which of the following is a mechanism to prevent race conditions? —
Using a mutex to protect critical sections
23.
What is the main limitation of the many-to-one threading model concerning parallelism? —
It cannot utilize multiple CPU cores effectively
24.
In multicore programming, the challenge of ensuring that multiple threads operate on shared data without corrupting it is known as: —
Synchronization
25.
Which of the following is a benefit of the one-to-one multithreading model? —
Allows one thread to block without blocking others
26.
What is a common technique used in implicit threading to manage threads? —
Thread pools and task-based parallelism
27.
Which threading model is used by default in Java? —
It depends on the JVM implementation and the operating system
28.
Which model offers a good balance between the overhead of the many-to-one model and the potential resource consumption of the one-to-one model? —
Many-to-many
29.
A semaphore initialized to 1 can function similarly to which other synchronization primitive? —
Mutex
30.
Which synchronization primitive is suitable for managing access to a resource that can be used by a limited number of threads concurrently (e.g., a connection pool)? —
Semaphore
31.
Which programming paradigm is often associated with implicit threading, simplifying concurrent programming? —
Functional Programming
32.
The many-to-many model attempts to combine the benefits of which other models? —
Many-to-one and One-to-one
33.
Which multithreading model maps many user-level threads to one or more kernel-level threads? —
Many-to-many model
34.
Which type of threading allows a large number of user threads to be mapped onto a smaller or equal number of kernel threads? —
Many-to-many model
35.
In the many-to-one multithreading model, what happens if one user thread performs a blocking system call? —
The entire process is blocked, preventing other threads from executing
36.
Which thread library operates entirely in user space and does not require kernel support for thread management? —
Thread Library (like GNU Portable Threads)
37.
What is the primary difference between a thread and a process? —
Processes have their own memory space, while threads share the memory space of their parent process.
38.
Which of the following is a key component of the OpenMP API for implicit threading in C/C++? —
#pragma omp parallel for
39.
Which threading issue is characterized by a process not making progress because it is waiting for a resource held by another process that is also waiting? —
Deadlock
40.
Consider a scenario where Thread A holds Resource 1 and needs Resource 2, while Thread B holds Resource 2 and needs Resource 1. This is a classic example of: —
Deadlock
41.
What is the main benefit of the one-to-one multithreading model? —
Allows concurrency even if one thread makes a blocking system call
42.
Which synchronization primitive is often used to ensure that only one thread can access a critical section of code at a time? —
Mutex (Mutual Exclusion)
43.
Which of the following is an example of a common threading issue related to resource contention? —
Deadlock
44.
In multicore programming, what is 'granularity' referring to? —
The level of parallelism in a program, related to the size of independent tasks
45.
Which scenario is most likely to lead to a deadlock? —
Threads acquiring locks in a circular wait dependency
46.
What is the purpose of `pthread_join()` in POSIX threads? —
To allow a thread to wait for another thread to complete its execution
47.
What is the role of the 'scheduler' in a user-level threading implementation (like the many-to-one model)? —
To schedule user threads onto available kernel threads
48.
What is the primary function of a thread library? —
To provide an API for creating, managing, and synchronizing threads
49.
What is the primary purpose of a thread pool? —
To provide a fixed set of worker threads ready to execute tasks
50.
What is the purpose of a condition variable? —
To signal and wait for specific conditions to be met