Questions: Threads and Concurrency

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A developer rewrites a single-threaded program to use 4 threads on a 4-core machine, expecting a 4x speedup. Instead, the program runs slower than before. What is the most likely explanation?

AThreads are inherently slower than single-threaded execution on all modern hardware
BSynchronization overhead and lock contention between threads eliminate the expected speedup
CUser-level threads cannot run on multiple cores, so only one core executes at a time
DThe OS scheduler can only assign one thread per process regardless of core count
Question 2 Multiple Choice

Thread A and Thread B both read a shared counter (value: 10), each increment it by 1, and write the result back. After both threads complete, what values are possible for the counter?

AAlways 12 — the OS ensures threads execute their operations atomically
BEither 11 or 12 — a race condition means one thread's write may overwrite the other's
CAlways 11 — the OS merges concurrent writes by taking the last value written
DThe program will always crash — concurrent writes to the same variable are undefined behavior
Question 3 True / False

Threads within the same process can communicate by reading and writing shared variables directly, without any OS-mediated mechanism like pipes or sockets.

TTrue
FFalse
Question 4 True / False

User-level threads can fully utilize multiple CPU cores because the thread library manages their scheduling independently of the OS.

TTrue
FFalse
Question 5 Short Answer

Why is creating a new thread much cheaper than creating a new process, and what is the fundamental tradeoff of this efficiency?

Think about your answer, then reveal below.