Operating System: Question Set – 19
What is hyper-threading?
Intel’s hyper-threading technology enables a single physical CPU core to function as two logical cores. Through the use of idle core resources, it allows a single core to operate several threads simultaneously.
What is thread granularity?
Thread granularity refers to the level of subdivision of tasks among threads:
- Fine-Grained Threads: Smaller tasks, more threads.
- Coarse-Grained Threads: Larger tasks, fewer threads. Choosing the granularity depends on the balance between overhead and performance.
What is the difference between multithreading and multitasking?
- Multithreading: Multiple threads execute within the same process.
- Multitasking: Multiple processes execute concurrently, which may involve multithreading within those processes.
What is thread starvation vs. deadlock?
- Thread Starvation: A thread is perpetually denied access to resources due to prioritization or scheduling policies.
- Deadlock: Two or more threads are stuck, waiting for each other to release resources, causing a standstill.
What is a detached thread?
A detached thread is one that operates separately from other threads; after it completes its execution, its resources are immediately returned to the system. To detach a thread in POSIX, use pthread_detach().
What is a joinable thread?
A joinable thread is one that can be joined by another thread to make sure it has finished executing or to retrieve its exit state. pthread_join() is used to join POSIX threads.
How does a thread yield execution?
To make room for other threads to run, a thread may choose to freely cede execution. This is accomplished in the majority of systems by employing a function such as yield() or sched_yield() in POSIX.
How are threads used in real-time operating systems (RTOS)?
In RTOS:
- Threads are prioritized based on strict timing constraints.
- Preemptive scheduling ensures high-priority threads meet deadlines.
- Threads are lightweight to minimize latency.
What is a reader-writer lock?
A reader-writer lock is a synchronization primitive that allows:
- Multiple threads to read concurrently.
- Only one thread to write, with no readers allowed during writing.
What are some common thread libraries?
- POSIX Threads (pthreads): Common on Unix-like systems.
- Java Threads: Provided by the Java runtime environment.
- Boost.Thread: C++ library for threading.
- Threading Building Blocks (TBB): Intel’s library for C++.
- Win32 Threads: Windows-specific threading API.
What is a zombie thread?
When a thread ends without its parent thread collecting its exit status, it’s known as a zombie thread. You can either join the thread or detach it to fix this issue.
What are thread barriers, and how are they used?
When a thread ends without its parent thread collecting its exit status, it’s known as a zombie thread. You can either join the thread or detach it to fix this issue.