Operating Systems - Chapter 4: Threads (Full Question Bank)
Q: What is a thread in the context of computer systems?
A: A thread is the fundamental unit of CPU utilization, consisting of a thread ID, program
counter, register set, and stack.
Q: Why are modern applications often multithreaded?
A: Multithreading allows applications to handle multiple tasks such as user input, data
processing, and networking simultaneously, improving responsiveness and efficiency.
Q: What are the benefits of multithreading?
A: Responsiveness, resource sharing, economy (less overhead than processes), and
scalability.
Q: What are the main challenges of multicore programming?
A: Dividing activities, balancing load, avoiding data dependency, and debugging.
Q: What is data parallelism?
A: It involves distributing subsets of the same data across multiple cores, performing the
same operation on each.
Q: What is task parallelism?
A: It involves distributing tasks (threads) across cores where each performs a unique
operation.
Q: What does Amdahl’s Law describe?
A: The theoretical speedup in latency of the execution of a task using multiple
processors based on the proportion of the task that can be parallelized.
Q: What are user threads?
A: Threads managed by user-level thread libraries without kernel support.
Q: What are kernel threads?
A: Threads that are supported and managed directly by the operating system kernel.
Q: Which libraries are used to implement threads?
A: POSIX Pthreads, Windows threads, Java threads.
Q: What is the many-to-one multithreading model?
A: Multiple user-level threads are mapped to a single kernel thread. One thread blocking
causes all to block.
Q: What is the one-to-one multithreading model?
A: Each user thread maps to a kernel thread. It provides more concurrency but may
have thread creation limits.
Q: What is the many-to-many multithreading model?
A: Allows many user-level threads to be mapped to many kernel threads, allowing better
resource use.
Q: What is the two-level threading model?
A: Similar to many-to-many but allows binding of some user threads to specific kernel
threads.
Q: What is a thread library?
A: A thread library provides the programmer an API to create and manage threads.
Q: What is Pthreads?
A: POSIX threads, a standard API for thread creation and synchronization, common in
UNIX systems.
Q: How are threads created in Java?
A: By extending the Thread class or implementing the Runnable interface.
Q: What is the Global Interpreter Lock (GIL) in Python?
A: A mutex that allows only one thread to execute in the interpreter at once, limiting true
multithreading.
Q: How can Python achieve parallelism despite GIL?
A: By using multiprocessing, where each process has its own interpreter and memory
space.
Q: What is implicit threading?
A: Threading where creation and management are handled by compilers and libraries
rather than the programmer.
Q: What are the advantages of thread pools?
A: Reduces overhead of thread creation and limits the number of concurrent threads.
Q: What is OpenMP?
A: A set of compiler directives and an API for parallel programming in C/C++/FORTRAN
for shared memory systems.
Q: What is Grand Central Dispatch (GCD)?
A: A technology by Apple for managing concurrent code execution using queues.