Timedora
Free Practice Quiz Question List

Synchro Online Quiz Questions

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

20 questions
01
Choose one
1 point

Which statement correctly describes how sync_set and sync_wait work together to synchronize two threads?

  1. A

    sync_set waits for the other thread to finish, and sync_wait sets the flag to 1.

  2. B

    sync_set orders prior memory accesses before setting the flag, and sync_wait waits for the flag before allowing subsequent accesses.

  3. C

    Both operations rely on a fixed delay to ensure the threads run in order.

  4. D

    sync_set and sync_wait only work if the operating system schedules the sending thread first.

02
Choose all
1 point

Select all statements that explain why a data race is more serious than unpredictable thread scheduling.

  1. A

    In C and C++, a data race causes undefined behavior.

  2. B

    A data race only makes the result unpredictable because the operating system may schedule threads differently.

  3. C

    The compiler may assume the program has no data races and optimize based on that assumption.

  4. D

    The compiler must preserve the apparent behavior of a racy program under every optimization.

03
True or false
1 point

Adding a fixed-duration sleep before a thread reads shared data guarantees that another thread has finished writing that data.

  1. A

    True

  2. B

    False

04
Written response
1 point

What is the name of the RISC-V instruction that acts as a barrier against memory accesses being reordered across it?

05
Fill in the blank
1 point

A data race occurs when make unsynchronized, conflicting non-atomic accesses to the , and at least one access is a .

06
Open ended
1 point

Why are ordinary loads and stores alone insufficient for reliable thread synchronization? Explain both the hardware issue and the compiler issue.

07
Choose one
1 point

Which description best matches a happens-before graph?

  1. A

    A graph whose vertices are threads and whose edges show which thread the scheduler runs first.

  2. B

    A graph where every event in one thread is automatically ordered before every event in all other threads.

  3. C

    A graph whose vertices are events and whose edges represent ordering, including inter-thread order established by synchronization.

  4. D

    A graph that records only memory locations and excludes instructions or statements.

08
Choose all
1 point

Select all correct statements about nondeterministic bugs and heisenbugs.

  1. A

    A bug with probability 0 is necessarily a deterministic bug.

  2. B

    A bug that occurs sometimes but not every time is nondeterministic.

  3. C

    A heisenbug is a bug that always occurs whenever it is investigated.

  4. D

    A heisenbug is a bug that goes away when someone looks for it.

09
True or false
1 point

Because threads share a virtual memory address space, creating the receiving thread second guarantees that it reads a shared variable after the sending thread writes it.

  1. A

    True

  2. B

    False

10
Written response
1 point

According to the stated RISC-V fence semantics, what must all loads and stores written before a plain fence do relative to the fence?

11
Fill in the blank
1 point

A data race occurs when two different threads perform accesses to the same memory location and at least one of those accesses is a .

12
Choose one
1 point

Which situation describes a heisenbug?

  1. A

    A bug that occurs on every run.

  2. B

    A bug that disappears when someone investigates it.

  3. C

    A bug that occurs only when a program is compiled without optimization.

  4. D

    A bug caused by two threads reading the same shared data.

13
True or false
1 point

In C and C++, a data race merely makes a program’s output unpredictable; the compiler must still preserve its behavior.

  1. A

    True

  2. B

    False

14
Written response
1 point

What operating-system component chooses which thread to run and when, so creating the receiving thread second does not guarantee that it runs second?

15
Choose one
1 point

Why is adding a fixed sleep to a thread not a reliable way to ensure the other thread has completed its work?

  1. A

    Sleep always makes the receiving thread run before the sending thread.

  2. B

    Sleep prevents the compiler from reordering memory accesses.

  3. C

    Sleep may make the desired ordering more likely, but it cannot guarantee that the other thread has completed its work.

  4. D

    Sleep ensures that the operating system runs both threads in the order they were created.

16
True or false
1 point

Ordinary loads and stores alone are sufficient for reliable thread synchronization because hardware visibility delays are the only concern; compiler optimizations do not matter.

  1. A

    True

  2. B

    False

17
Written response
1 point

What is the standard name for a graph whose vertices are program events and whose edges represent ordering, including ordering established between threads by synchronization?

18
Choose one
1 point

In the RISC-V sync_wait implementation, what does the fence after the flag-checking loop ensure?

  1. A

    It ensures that accesses before the call to sync_wait finish before the flag is set.

  2. B

    It ensures that memory accesses after sync_wait occur after the wait loop has observed the flag.

  3. C

    It repeatedly stores 1 to the flag until the sending thread continues.

  4. D

    It ensures that all loads and stores in both threads happen simultaneously.

19
Written response
1 point

In the data-race definition, what one-word qualifier describes accesses by different threads to the same location when no synchronization operation establishes an order between them?

20
Choose one
1 point

Why can’t choosing a sufficiently long fixed sleep duration prove that the receiving thread will read the value only after the sending thread stores it?

  1. A

    There is no reliable duration that forces the ordering, because the threads may start at different times and the delay does not guarantee the sending thread has completed the store.

  2. B

    A sleep call always prevents a thread from running on a different CPU core.

  3. C

    A sleep call guarantees that the receiving thread reads the latest value from shared memory.

  4. D

    A sleep call makes the order depend on the value stored rather than on thread execution.