Which of the following best describes a race condition? A) Two threads deadlocked on resources B) Correctness depends on relative timing of events C) A thread starves forever D) Sequential execution of threads Answer: B. Explanation: A race occurs when interleaving affects correctness.
Which primitive provides mutual exclusion with blocking (no busy-wait)? A) Spinlock B) Mutex (blocking) C) Test-and-set loop D) Volatile flag Answer: B. Explanation: Mutex lets threads sleep while waiting.
What is livelock? A) Two threads blocked forever B) Threads active but not making progress due to mutual retries C) Thread crash due to memory error D) Process swap thrashing Answer: B. Explanation: Livelock: constant state change without progress.
Which property ensures every waiting thread eventually gets the resource? A) Atomicity B) Fairness (no starvation) C) Mutual exclusion D) Livelock Answer: B. Explanation: Fairness/aging prevents starvation.
Which algorithm solves mutual exclusion for N processes using only reads/writes (Lamport’s bakery)? A) Peterson’s B) Dekker’s C) Lamport’s bakery D) Spinlock Answer: C. Explanation: Bakery algorithm works for N processes using numbers.
Peterson’s algorithm requires which of the following? A) Atomic test-and-set B) Two shared variables and strict ordering C) Kernel support D) Hardware locks Answer: B. Explanation: Peterson uses flag[] and turn in software.
Which instruction is typically used to implement lock-free algorithms? A) MOV B) CAS (compare-and-swap) C) DIV D) JMP Answer: B. Explanation: CAS allows atomic conditional update.
What does “wait-free” mean? A) No locking at all B) Every thread completes in a bounded number of steps independent of others C) No memory allocation required D) Only one thread runs Answer: B. Explanation: Wait-free guarantees per-thread bounded progress.
Which concurrency bug is represented by two processes each holding one resource and waiting for the other? A) Starvation B) Deadlock C) Livelock D) Race condition Answer: B. Explanation: Circular wait with held resources → deadlock.
Which of the following is NOT one of Coffman’s necessary conditions for deadlock? A) Mutual exclusion B) Hold and wait C) Preemption D) Circular wait Answer: C. Explanation: Preemption absence (not presence) is required; the four conditions are mutual exclusion, hold-and-wait, no-preemption, circular-wait.
Which scheme is used to prevent deadlock by ordering resources? A) Banker’s algorithm B) Resource hierarchy (ordering) C) Dining philosophers D) Readers-writers lock Answer: B. Explanation: Enforce acquiring resources in increasing order to avoid cycles.
Banker’s algorithm is primarily used for: A) Allocating CPU time B) Deadlock avoidance by checking safe states C) Mutex implementation D) Lock-free synchronization Answer: B. Explanation: It simulates allocation to ensure system remains in a safe state.
Which of the following is true about monitors? A) They are low-level atomic instructions B) High-level construct combining mutual exclusion and condition variables C) They are identical to semaphores D) Only available in kernel Answer: B. Explanation: Monitor encapsulates data, mutual exclusion, and condition synchronization.
A condition variable is always used with a: A) Spinlock B) Mutex C) Atomic integer D) Semaphore only Answer: B. Explanation: Cond var operations assume an associated mutex to protect the condition.
Which pattern avoids priority inversion by temporarily boosting priority of lock holder? A) Priority inversion B) Priority inheritance C) Priority degradation D) Priority aging Answer: B. Explanation: Priority inheritance raises holder’s priority to that of highest waiter.
Which lock is fair and gives FIFO ordering for waiters? A) Test-and-set spinlock B) Ticket lock C) Mutex with default policy D) Reader-writer lock Answer: B. Explanation: Ticket locks serve waiters in FIFO order.
Which of these can cause false sharing? A) Threads accessing same variable B) Threads accessing separate variables on same cache line C) Having per-thread local storage D) Using atomic operations only Answer: B. Explanation: Writes on different variables in same cache line cause cache ping-pong.
Which approach reduces contention by partitioning data structures and locks? A) Coarse-grained locking B) Fine-grained locking / lock striping C) Single global lock D) Disabling interrupts Answer: B. Explanation: Lock striping reduces contention by sharding data.
What is the effect of disabling preemption inside kernel critical section? A) Eliminates need for spinlocks on single CPU context B) Causes deadlock across CPUs C) Always speeds up system D) Makes user-level scheduling impossible Answer: A. Explanation: Disabling preemption avoids being preempted by other threads; on single CPU it’s enough.
Which synchronization primitive can be used for producer-consumer with a bounded buffer? A) Mutex + two semaphores (empty, full) B) Only mutex C) Only condition variables (without counts) D) Spinlock without counters Answer: A. Explanation: Standard solution: mutex + semaphores for counts.
What does pthread_mutex_trylock() return if the lock is not available? A) Blocks forever B) Returns immediately with EBUSY C) Kills calling thread D) Acquires lock after delay Answer: B. Explanation: trylock is non-blocking and indicates busy status.
Which of the following best characterizes a spinlock? A) A blocking lock that sleeps the thread B) A busy-wait lock spinning until free C) A lock safe for long wait times D) A lock that prevents CPU preemption permanently Answer: B. Explanation: Spinlocks busy-wait; good for short critical sections.
Which is preferable on multi-core for very short critical sections? A) Mutex (sleep/wakeup) B) Spinlock C) No synchronization D) Blocking I/O Answer: B. Explanation: Spinlocks avoid expensive context switch when wait is short.
Which synchronization model uses wait/notify semantics where notifying thread does not release mutex? A) Semaphores B) Condition variables C) Locks only D) Atomic counters Answer: B. Explanation: With cond vars, notify wakes waiter but mutex release behavior is defined by API.
What is priority aging? A) Reducing priority of long-running tasks B) Increasing priority of waiting tasks over time C) Random priority change D) Immediate priority swap Answer: B. Explanation: Aging increments priority of waiting jobs to prevent starvation.
Which of the following is true about readers-writers locks with reader preference? A) Writers never starve B) Readers may block if writer waiting C) Writers can starve if continuous readers arrive D) Both readers and writers are equally prioritized Answer: C. Explanation: Reader-preference can starve writers.
Which is true about optimistic concurrency control? A) Uses locks always B) Reads without locks, validates on commit, may abort and retry C) Never aborts transactions D) Only for single-threaded apps Answer: B. Explanation: Optimistic methods assume rare conflicts, validate at commit.
Which technique is commonly used in databases to avoid deadlocks among transactions? A) Two-phase locking with deadlock detection or strict ordering (timestamp ordering) B) Using spinlocks exclusively C) No locking at all D) Always serial execution Answer: A. Explanation: Databases use 2PL with deadlock detection or timestamp ordering.
Which concurrency control provides serializability by rolling back transactions on conflict? A) Locking only B) Optimistic concurrency (validation + rollback) C) Spinlocks D) Condition variables Answer: B. Explanation: Optimistic control validates and aborts conflicting transactions.
Which is a safe approach to avoid race conditions on a shared counter in multithreaded code? A) counter++ without locks B) Use atomic increment (fetch_add) or protect with mutex C) Use volatile only D) Use printf to serialize Answer: B. Explanation: Atomic ops or mutex ensure correct increments.
What does ABA problem refer to in lock-free algorithms? A) A type of deadlock B) A location changes from A to B and back to A; CAS may be misled C) A race condition fix D) A memory leak pattern Answer: B. Explanation: CAS can be fooled when value returns to previous one — use version tags.
Which tool helps detect data races in programs? A) gdb only B) ThreadSanitizer or Helgrind C) valgrind without plugins D) strace Answer: B. Explanation: TSAN and Helgrind detect races and concurrency bugs.
Which technique reduces ABA by embedding a counter with pointer? A) Use only mutexes B) Pointer tagging (versioned pointers) C) Remove all pointers D) Use printf statements Answer: B. Explanation: Tagging pointer with version avoids ABA.
When two threads use a condition variable, which pattern is correct when waiting? A) if (!cond) pthread_cond_wait(&cv,&m); B) while (!cond) pthread_cond_wait(&cv,&m); C) pthread_cond_wait(&cv,NULL); D) No need to lock around wait Answer: B. Explanation: Use while-loop to handle spurious wakeups and re-check condition.
What is meant by “atomic” operation? A) Operation visible partially to others B) Operation appears indivisible to other threads C) Operation always uses kernel calls D) Operation is slow Answer: B. Explanation: Atomic means other threads see either before or after state, not between.
Which is true about lock-free vs wait-free? A) Lock-free guarantees system-wide progress; wait-free guarantees per-thread bounded progress B) Lock-free = wait-free always C) Wait-free may deadlock D) Lock-free uses locks internally Answer: A. Explanation: Lock-free ensures some thread makes progress; wait-free stronger.
What is the tradeoff of lock-free algorithms? A) Simplicity and less errors B) Complexity and often extra CPU cycles due to retries C) Always faster than locks in all scenarios D) Always require kernel support Answer: B. Explanation: Lock-free code can be complex and involve spinning/retries.
Which of the following is a non-blocking synchronization primitive? A) pthread_mutex_lock B) spinlock (busy-wait) C) sem_wait D) sleep Answer: B. Explanation: Spinlocks busy-wait instead of blocking/sleeping.
Which synchronization allows multiple concurrent readers but one writer? A) Mutex B) Read–write lock (rwlock) C) Semaphore with count 1 D) Spinlock only Answer: B. Explanation: RW-lock allows reader concurrency, exclusive writer.
In the dining philosophers, one simple deadlock-free solution is: A) All pick left fork simultaneously B) Limit number of philosophers concurrently trying to eat to N-1 C) No locks used D) Each philosopher grabs both forks without coordination Answer: B. Explanation: Limiting active philosophers prevents circular wait.
What is condition variable broadcast used for? A) Wake a single thread B) Wake all waiting threads to re-check condition C) Destroy the mutex D) Sleep all threads Answer: B. Explanation:pthread_cond_broadcast wakes all waiting threads.
Which of following is true for Reentrant locks? A) Allow same thread to acquire same lock multiple times B) Prevent any re-acquisition by same thread C) Always faster D) Not supported in pthreads Answer: A. Explanation: Recursive/ reentrant locks permit nested acquisitions by same thread.
Which is a benefit of using thread pools? A) Create threads per request B) Reuse threads to amortize creation cost and control concurrency C) Avoid synchronization entirely D) Disable preemption Answer: B. Explanation: Pools reduce overhead and control resource usage.
Which is a common pattern to avoid deadlock when acquiring multiple locks? A) Acquire locks in fixed global order B) Acquire in arbitrary order C) Use sleep() between locks D) Hold locks forever Answer: A. Explanation: Lock ordering prevents circular wait.
What is a semaphore with initial count 0 typically used for? A) Mutual exclusion only B) Signaling (synchronization) between threads — wait until event occurs C) Counting resources >0 only D) Allocating memory Answer: B. Explanation:sem_init(&s,0) with 0 used for rendezvous.
Which is true about semaphores? A) Binary semaphores can implement mutexes, but must be used carefully for ownership semantics B) Semaphores always provide ownership semantics like mutex C) sem_wait never blocks D) sem_post blocks thread Answer: A. Explanation: Binary semaphores can act as mutex but lack owner identification.
Which approach minimizes critical section length? A) Do all work inside lock B) Move noncritical computations outside lock and only protect essential updates C) Use global lock for everything D) No need to minimize Answer: B. Explanation: Short critical sections reduce contention.
Which of the following is a correct use of memory barriers? A) Ensure memory operations ordering across CPUs for lock-free algorithms B) Eliminate need for synchronization entirely C) Reduce atomicity of operations D) Swap the contents of memory randomly Answer: A. Explanation: Barriers enforce visibility and ordering on weakly ordered CPUs.
Which pattern is susceptible to priority inversion if not handled? A) High-priority thread waiting on lock held by low-priority thread while medium-priority runs B) Low-priority thread always idle C) Mutex with priority inheritance enabled D) No locking Answer: A. Explanation: Medium priority can preempt low holder, blocking high priority → inversion.
Which method is used to detect deadlock? A) Construct resource allocation graph and detect cycles B) Ignore and hope C) Always use spinlocks D) Use only mutexes Answer: A. Explanation: Cycle detection in resource allocation graph identifies deadlock.
What is the function of pthread_cond_signal()? A) Signal to create a new thread B) Wake at least one waiting thread (if any) C) Destroy a condition variable D) Lock the mutex associated Answer: B. Explanation:cond_signal wakes one waiter (scheduling dependent).
Which is true for certain real-time systems regarding priority? A) Lower numerical priority always runs first B) Higher-priority preemption is often required to meet deadlines C) Priority never changes D) Preemption is not allowed in RT systems Answer: B. Explanation: RT systems use priority/preemption to meet deadlines.
Which concurrency model uses message passing rather than shared memory to avoid aliasing and races? A) CSP (Communicating Sequential Processes) / Actors model B) Threads with shared memory only C) Kernel mutexes only D) Global locks only Answer: A. Explanation: CSP/Actors use message passing to isolate state.
Which statement is accurate about lock elision (speculative locking)? A) Always replaces locks perfectly B) Uses hardware transactional memory to speculatively execute critical sections without acquiring locks, falling back on locks on conflict C) Is software-only technique requiring no hardware D) Makes code non-deterministic always Answer: B. Explanation: HTM can speculatively run critical sections; on conflict revert to locking.
What is “grace period” in RCU (Read-Copy-Update)? A) Time until writer holds a lock B) Period after which all pre-existing readers have finished, safe for reclamation C) Delay before a lock is acquired D) Interval where no threads run Answer: B. Explanation: After grace period, safe to reclaim memory because readers done.
Which is true about readers in RCU? A) They acquire a writer lock B) Readers proceed without locks and are very fast C) Readers block writers always D) RCU is unsuitable for read-dominated workloads Answer: B. Explanation: RCU allows lockless read-side for high read throughput.
Which is a drawback of coarse-grained locking? A) Simpler code B) Higher concurrency C) Increased contention and lower parallelism D) Avoids deadlocks always Answer: C. Explanation: Coarse locks reduce parallelism.
What is the difference between mutex and semaphore? A) Mutex has owner semantics (only owner unlocks); semaphore is a counter allowing multiple permits B) No difference C) Semaphore only for single thread D) Mutex is integer counter only Answer: A. Explanation: Mutex exclusive; semaphore counts resources.
Which pattern can cause convoying (one slow thread causing many to wait) in locks? A) FIFO queue locks with slow holder B) Randomized unlocking C) No queueing locks D) Atomic CAS only Answer: A. Explanation: If holder is delayed, queued threads pile up (convoy effect).
Which lock reduces writer latency at expense of reader throughput? A) Reader-preferring rwlock B) Writer-preferring rwlock (gives writers priority) C) No locks D) Spinlock only Answer: B. Explanation: Writer-preference favors writers, potentially slowing readers.
Which of the following best describes a “futex”? A) File-based mutex B) Fast userspace mutex: primarily user-space with kernel fallback for blocking/wakeup C) Type of semaphore only in Windows D) Only used in single-threaded programs Answer: B. Explanation: Futex does user-space wait-free path and kernel assistance when blocking.
Which operation should not be performed while holding a mutex? A) Quick local computation B) Blocking I/O calls or long sleeps C) Updating protected variables D) Releasing the mutex Answer: B. Explanation: Lock holders should avoid blocking to prevent contention/convoy.
Which is true about barrier synchronization? A) Only one thread waits B) All threads must reach barrier; none proceeds until all arrive C) Barrier eliminates locks completely D) Barrier is same as semaphore Answer: B. Explanation: Barrier sync waits until all participating threads reach it.
Which scenario is typical for using a concurrent queue with multiple producers and consumers? A) Single-threaded logging only B) Work-stealing or task queues in thread pools to distribute work safely without blocking (using lock-free or fine-grained locks) C) Avoid any synchronization D) Replace all locks in program Answer: B. Explanation: MPMC queues distribute work between threads efficiently.
Which technique is used by work-stealing schedulers? A) Workers steal tasks from others’ deques when idle, improving load balance B) Always block threads C) Centralized queue only D) Single producer only Answer: A. Explanation: Work stealing balances load with low contention.
Which of the following is true for hazard pointers? A) Used for lock-free memory reclamation to avoid freeing objects still referenced by other threads B) Always block threads C) Replace all atomic operations D) Are debugging tools only Answer: A. Explanation: Hazard pointers let threads mark nodes to defer reclamation safely.
Which is more scalable for many cores: per-core queues or a single global queue? A) Single global queue (always best) B) Per-core or sharded queues to reduce contention and cache-coherence overhead C) No queues at all D) Random technique Answer: B. Explanation: Sharding reduces contention and improves cache locality.
Which of the following is true about concurrent hash maps with lock striping? A) Single lock for entire map B) Multiple locks protecting buckets reduce contention and allow parallel operations on different buckets C) Lock striping makes code single-threaded D) It serializes all ops Answer: B. Explanation: Lock striping assigns locks per bucket/stripe for concurrency.
What problem does exponential backoff solve in spin-based retries? A) It increases contention B) It reduces contention by backing off progressively to reduce repeated collisions C) Always deterministic ordering D) No effect Answer: B. Explanation: Backoff reduces hot spinning and contention.
Which is true regarding transactional memory? A) Serializes all transactions trivially B) Allows optimistic concurrency by executing code in transactions and committing atomically; conflicts cause aborts and retries C) Is same as locks D) Never used in practice Answer: B. Explanation: TM provides optimistic atomic execution with rollback on conflict.
Which is an advantage of using immutable data structures in concurrency? A) Avoid copying entirely B) Readers never need locks; updates create new versions, enabling safe concurrency with structural sharing C) Always fastest for writes D) Not useful in multithreaded systems Answer: B. Explanation: Immutability eliminates data races for readers.
Which of the following is a correct deadlock recovery strategy? A) Kill one or more processes involved (victim selection) and roll back resources B) Do nothing and wait forever C) Increase priorities randomly D) Use only spinlocks Answer: A. Explanation: Deadlock recovery may choose victims and preempt resources.
Which is true about “thundering herd” problem? A) Efficient wakeup of only necessary thread B) Many threads wake up to contend for resource when only one is needed, causing contention and overhead C) Only occurs in single-threaded programs D) Solved by increasing lock hold time Answer: B. Explanation: Waking many threads causes unnecessary context switches and contention.
Which mechanism can mitigate thundering herd on sockets? A) Use epoll/kqueue with edge-triggered or use accept mutex / queueing to wake only one waiter B) select() always solves it C) Increase socket buffer size only D) No mitigation exists Answer: A. Explanation: Advanced event mechanisms and coordinated accept strategy limit wakeups.
Which is true about deterministic replay for debugging concurrency? A) Always trivial to implement B) Records events (synchronization order) and replays them to reproduce bugs, enabling reproducible debugging of races/deadlocks C) Makes program non-deterministic D) Not useful for concurrency bugs Answer: B. Explanation: Recording and replaying events helps reproduce elusive concurrency bugs.
What is a “data race” in C/C++ memory model? A) Concurrent accesses where at least one is a write and they are not ordered by happens-before (no synchronization) B) Two reads only C) Only in single-threaded code D) Happens only with locks Answer: A. Explanation: Unsynchronized conflicting accesses cause undefined behavior.
Which technique uses atomic snapshot and helping to ensure wait-free progress? A) Using just mutexes B) Lock-free algorithms with helping (threads help finish other threads’ operations) C) Sleeping until done D) Always use global locks Answer: B. Explanation: Helping avoids starvation and can provide wait-free guarantees.
Which synchronization primitive is best when changes are infrequent and reads are extremely frequent? A) Mutex only B) Read–write lock (allow many readers) or RCU-like patterns C) Spinlock with heavy contention D) No synchronization Answer: B. Explanation: RW-locks or RCU maximize read throughput.
What is “coherence traffic” in multicore concurrency? A) Network packets only B) Cacheline invalidation and transfer traffic when cores modify shared cachelines, causing interconnect load C) Disk I/O only D) Only used in single-core systems Answer: B. Explanation: Writes to shared cachelines generate bus and coherence protocol messages.
Which pattern helps avoid false sharing? A) Packing hot variables into same cache line B) Padding structures so frequently modified fields are on separate cache lines C) Letting threads modify adjacent fields D) Using volatile only Answer: B. Explanation: Padding prevents unrelated fields from sharing cache line.
Which lock is best when number of readers >> writers and reads are short? A) Exclusive mutex B) Reader–writer lock with reader preference or fair variant C) Global spinlock always D) No lock Answer: B. Explanation: RW-lock allows concurrent readers.
Which approach reduces latency in critical sections under heavy contention? A) Keep critical sections long B) Use fine-grained locking, lock striping, and lock-free data structures where appropriate C) Serialize everything with global lock D) Use busy waits always Answer: B. Explanation: Smaller locks and lock-free approaches lower contention.
Which of the following is a hazard when using condition variables? A) Using if instead of while to recheck condition (susceptible to spurious wakeups) B) Releasing mutex inside pthread_cond_wait C) Always using pthread_cond_broadcast only D) Not using pthread_cond_signal Answer: A. Explanation:while loop is necessary to re-check the predicate.
Which is true about thread-local storage (TLS)? A) Shared across threads B) Provides per-thread copies of variables to avoid synchronization overhead for that data C) Solves all concurrency problems D) Replaces mutexes always Answer: B. Explanation: TLS avoids sharing and synchronization for per-thread data.
Which technique can reduce lock acquisition overhead when many threads are idle? A) Spinning forever B) Parking threads (sleeping) and using futex-like system calls to wake only necessary threads C) Waking all threads always D) Avoid using kernels ever Answer: B. Explanation: Parking reduces CPU waste compared to busy spinning.
In lock-free stacks using CAS, which issue often requires special handling? A) Stack never grows B) ABA problem and memory reclamation (use hazard pointers or epoch-based reclaim) C) CAS always succeeds D) No synchronization required Answer: B. Explanation: Need to prevent ABA and ensure safe reclamation.
Which of the following is an advantage of using async/await or coroutines for concurrency? A) Always faster than threads B) Lower stack overhead and cooperative scheduling for I/O-bound tasks, leading to high concurrency with fewer resources C) Remove need for synchronization in all cases D) Only for CPU bound tasks Answer: B. Explanation: Coroutines are lightweight for many concurrent I/O tasks.
Which metric measures how quickly a system completes tasks over time under concurrency? A) Latency only B) Throughput (tasks per unit time) C) Memory usage only D) CPU temp Answer: B. Explanation: Throughput indicates work completed per time.
Which is true about coarse-grained locks vs fine-grained locks? A) Coarse-grained simpler but restricts concurrency; fine-grained increases parallelism but complexity and deadlock risk B) Fine-grained always better and simpler C) Coarse-grained never used D) Both identical in tradeoffs Answer: A. Explanation: Tradeoff: simplicity vs concurrency.
Which is an effect of contention collapse? A) More threads improve throughput linearly forever B) Adding more threads beyond certain point reduces throughput due to increased contention and overhead C) Only affects single-threaded apps D) Always improves latency Answer: B. Explanation: Excess threads increase synchronization overhead and degrade performance.
Which technique gives bounded wait for lock acquisition and fairness? A) Test-and-set spinlock B) Ticket locks or queued locks (MCS lock) C) Global atomic counter only D) No locking Answer: B. Explanation: Queue-based locks provide FIFO fairness and bounded wait.
Which is a property of MCS (Mellor-Crummey and Scott) queue locks? A) High contention on single memory location B) Each waiter spins on a private node, improving scalability on many cores C) No fairness D) Only for single-core systems Answer: B. Explanation: MCS scales well: per-waiter spinning and FIFO.
Which is a common approach to implement a scalable concurrent hashmap? A) Single global lock B) Lock striping + per-bucket locks and resizing strategies with careful coordination C) No synchronization on buckets D) Avoid resizing altogether Answer: B. Explanation: Stripe locks per bucket reduce contention and enable parallelism.
Which is true about “deterministic multithreading”? A) Ensures exact same thread interleaving and results across runs by constraining scheduler (useful for debugging) B) Impossible to implement C) Only for single-threaded apps D) Uses random scheduling always Answer: A. Explanation: Deterministic schedulers reproduce ordering for debugging.
Which approach helps in concurrent memory reclamation for lock-free structures? A) Immediate free after unlink B) Epoch-based reclamation or hazard pointers to ensure no active readers reference freed memory C) free() from any thread immediately always safe D) No reclamation needed Answer: B. Explanation: Defer reclamation until safe to avoid use-after-free.
Which is true of “helping” in lock-free algorithms? A) Threads ignore others’ operations B) Threads can assist completing other threads’ pending operations to ensure progress C) Always harmful D) Only used in blocking algorithms Answer: B. Explanation: Helping reduces stalls and can provide progress guarantees.
Which of the following is a correct guideline for locking order to prevent deadlock? A) Acquire locks in random order each time B) Always acquire locks in globally consistent order (e.g., by address or ID) C) Acquire second lock only after releasing first always D) Never lock two resources Answer: B. Explanation: Consistent ordering prevents cycles.
Which is true about preemption and critical sections? A) Preemption makes critical sections safer B) Kernel may disable preemption in very short critical sections to avoid lock overhead on single CPU C) Preemption eliminates need for locks D) Preemption always increases throughput Answer: B. Explanation: Disabling preemption protects small kernel critical sections.
Which is a good practice when designing concurrent data structures? A) Avoid documenting concurrency semantics B) Keep APIs simple, clearly document thread-safety guarantees (thread-safe, externally synchronized, etc.), and prefer fine-grained or lock-free designs when needed C) Use global locks for everything always D) Rely on undefined behavior Answer: B. Explanation: Clear contracts and design reduce misuse and bugs.
Which one-line summary best captures concurrent programming challenge? A) Make code run faster always B) Coordinate access to shared mutable state safely while maximizing parallelism and minimizing overhead C) Avoid all shared state by single-threading always D) Use infinite threads to solve everything Answer: B. Explanation: Concurrency balances safety (correctness) with performance (parallelism, low overhead).