Free Practice Quiz Question List

5 Concurrency and Synchronization Online Quiz Questions

Use this free practice quiz with 20 questions to review 5 Concurrency and Synchronization, test your knowledge, and prepare for your next test or exam.

20 questions
01
True or false
1 point

True or false: After a condition-variable wait returns, a thread can assume that the condition it was waiting for is true.

  1. A

    True

  2. B

    False

02
Choose one
1 point

A parallel computation has several stages, and no thread should start the next stage until every thread has finished the current one. Which synchronization primitive best fits this requirement?

  1. A

    To let multiple readers examine shared data while excluding all writers permanently

  2. B

    To let one thread wait until a shared queue becomes nonempty

  3. C

    To make a group of threads wait until all have reached the same stage

  4. D

    To represent a pool of several identical available resources

03
Written response
1 point

A counting semaphore has a count of 7. Three threads each successfully acquire it once, and no thread releases it. What is the count afterward?

04
Fill in the blank
1 point

In a bounded-buffer system, producers should when the buffer is full, while consumers should when it is empty.

05
Choose one
1 point

Two threads increment a shared counter without synchronization. Each increment consists of reading the counter, adding one, and writing the result. Which outcome is possible?

  1. A

    The counter is guaranteed to increase twice because each thread executes an increment statement.

  2. B

    Both threads may read the same old value and then write the same new value, losing one increment.

  3. C

    The operating system must terminate one thread because simultaneous writes are impossible.

  4. D

    The counter will decrease because each thread overwrites the other thread's read.

06
Written response
1 point

What synchronization property requires that a thread requesting entry to a critical section cannot be bypassed forever by other threads?

07
True or false
1 point

Threads repeatedly respond to one another but make no useful progress. This situation is an example of deadlock.

  1. A

    True

  2. B

    False

08
Fill in the blank
1 point

In the dining-philosophers problem, requiring everyone to acquire forks in a can prevent the circular wait that leads to deadlock.

09
Choose one
1 point

A shared data structure is read frequently and updated occasionally. The design should allow multiple readers at once but exclude readers while a writer holds the lock. Which primitive best matches this access pattern?

  1. A

    A mutex, because it allows all readers to access the data simultaneously

  2. B

    A read-write lock, because it can allow multiple readers while excluding readers when a writer holds the lock

  3. C

    A barrier, because it grants writers exclusive access to shared data

  4. D

    A counting semaphore, because it automatically prevents writers from being delayed

10
Choose all
1 point

Which practices support safer synchronization in a concurrent program? Select all that apply.

  1. A

    Define which lock guards each piece of shared state.

  2. B

    Keep a lock held while waiting for unrelated work, so the protected state cannot change.

  3. C

    Release locks promptly when the protected work is complete.

  4. D

    Test concurrent programs under varied timing.

  5. E

    Avoid waiting for unrelated work while holding a lock.

11
Choose all
1 point

Which conditions must all hold for the classic resource deadlock described in operating-systems theory? Select all that apply.

  1. A

    Mutual exclusion

  2. B

    Hold and wait

  3. C

    A safe state for every possible resource allocation

  4. D

    No preemption

  5. E

    Circular wait

12
Open ended
1 point

A system designer is comparing deadlock prevention, avoidance, and detection and recovery. Explain how each approach handles the possibility of deadlock, including what avoidance must know before granting a resource request.

13
Choose one
1 point

A single-core operating system switches between two threads, allowing each to make progress during overlapping periods. Which statement best describes this situation?

  1. A

    Concurrency requires multiple processor cores.

  2. B

    The operating system can interleave threads so they make progress during overlapping periods.

  3. C

    Concurrency occurs only when threads access the same shared variable.

  4. D

    A single-core system runs all threads simultaneously.

14
Choose one
1 point

A service has a pool of four identical connections and must limit how many threads use them at once. Which approach directly matches this requirement?

  1. A

    A mutex initialized to four permits four simultaneous holders.

  2. B

    A condition variable initialized to four permits four threads to skip checking a predicate.

  3. C

    A counting semaphore initialized to four can limit access to four connections.

  4. D

    A barrier initialized to four provides exclusive access to four connections.

15
Choose one
1 point

A thread waits on a condition variable for a shared queue to become nonempty. What should it do after waking?

  1. A

    Recheck the predicate in a loop after waking.

  2. B

    Treat the wake-up as proof that the predicate is true.

  3. C

    Unlock the mutex before checking the predicate for the first time.

  4. D

    Replace the predicate with a fixed delay.

16
Choose one
1 point

In a bounded-buffer producer–consumer system, under which conditions should producers and consumers wait?

  1. A

    Producers wait when the buffer is empty; consumers wait when it is full.

  2. B

    Both producers and consumers wait only when the buffer is empty.

  3. C

    Consumers wait when the buffer is full; producers wait when it is empty.

  4. D

    Producers wait when the buffer is full; consumers wait when it is empty.

17
Choose one
1 point

A shared data structure is read frequently and updated less often. Which read-write-lock behavior can support this pattern?

  1. A

    It permits multiple writers at once but only one reader.

  2. B

    It permits multiple readers at once and excludes readers while a writer holds the lock.

  3. C

    It forces every reader and writer to wait until all other threads terminate.

  4. D

    It allows readers to update data while a writer holds the lock.

18
True or false
1 point

If no thread is in a critical section and some threads want to enter, the progress property rules out postponing the choice of the next entrant indefinitely.

  1. A

    True

  2. B

    False

19
Written response
1 point

Two threads repeatedly respond to each other's actions, but neither makes useful progress. What is this problem called?

20
Written response
1 point

A parallel computation is divided into phases, and each group of threads must wait until all threads reach the same stage before proceeding. What synchronization primitive supports this?