Which statement correctly describes how sync_set and sync_wait work together to synchronize two threads?
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.
Select all statements that explain why a data race is more serious than unpredictable thread scheduling.
- A
In C and C++, a data race causes undefined behavior.
- B
A data race only makes the result unpredictable because the operating system may schedule threads differently.
- C
The compiler may assume the program has no data races and optimize based on that assumption.
- D
The compiler must preserve the apparent behavior of a racy program under every optimization.
Adding a fixed-duration sleep before a thread reads shared data guarantees that another thread has finished writing that data.
- A
True
- B
False
What is the name of the RISC-V instruction that acts as a barrier against memory accesses being reordered across it?
A data race occurs when make unsynchronized, conflicting non-atomic accesses to the , and at least one access is a .
Why are ordinary loads and stores alone insufficient for reliable thread synchronization? Explain both the hardware issue and the compiler issue.
Which description best matches a happens-before graph?
- A
A graph whose vertices are threads and whose edges show which thread the scheduler runs first.
- B
A graph where every event in one thread is automatically ordered before every event in all other threads.
- C
A graph whose vertices are events and whose edges represent ordering, including inter-thread order established by synchronization.
- D
A graph that records only memory locations and excludes instructions or statements.
Select all correct statements about nondeterministic bugs and heisenbugs.
- A
A bug with probability 0 is necessarily a deterministic bug.
- B
A bug that occurs sometimes but not every time is nondeterministic.
- C
A heisenbug is a bug that always occurs whenever it is investigated.
- D
A heisenbug is a bug that goes away when someone looks for it.
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.
- A
True
- B
False
According to the stated RISC-V fence semantics, what must all loads and stores written before a plain fence do relative to the fence?
A data race occurs when two different threads perform accesses to the same memory location and at least one of those accesses is a .
Which situation describes a heisenbug?
- A
A bug that occurs on every run.
- B
A bug that disappears when someone investigates it.
- C
A bug that occurs only when a program is compiled without optimization.
- D
A bug caused by two threads reading the same shared data.
In C and C++, a data race merely makes a program’s output unpredictable; the compiler must still preserve its behavior.
- A
True
- B
False
What operating-system component chooses which thread to run and when, so creating the receiving thread second does not guarantee that it runs second?
Why is adding a fixed sleep to a thread not a reliable way to ensure the other thread has completed its work?
- A
Sleep always makes the receiving thread run before the sending thread.
- B
Sleep prevents the compiler from reordering memory accesses.
- C
Sleep may make the desired ordering more likely, but it cannot guarantee that the other thread has completed its work.
- D
Sleep ensures that the operating system runs both threads in the order they were created.
Ordinary loads and stores alone are sufficient for reliable thread synchronization because hardware visibility delays are the only concern; compiler optimizations do not matter.
- A
True
- B
False
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?
In the RISC-V sync_wait implementation, what does the fence after the flag-checking loop ensure?
- A
It ensures that accesses before the call to
sync_waitfinish before the flag is set. - B
It ensures that memory accesses after
sync_waitoccur after the wait loop has observed the flag. - C
It repeatedly stores 1 to the flag until the sending thread continues.
- D
It ensures that all loads and stores in both threads happen simultaneously.
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?
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?
- 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.
- B
A sleep call always prevents a thread from running on a different CPU core.
- C
A sleep call guarantees that the receiving thread reads the latest value from shared memory.
- D
A sleep call makes the order depend on the value stored rather than on thread execution.
Related study packs and tools
- Study guide
02 — Information and Representation
A progressive guide to how computers encode numbers, text, images, and sound as binary data, including the trade-offs and limits of digital representation.
- Quiz
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
- Flashcards
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
- Study guide
3 CPU Architecture
Learn how registers, the ALU, datapath connections, and control logic work together to fetch and execute CPU instructions.
- Study guide
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
- Study guide
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
- Study guide
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
- Flashcards
08 — Discrete Mathematics for Computer Science
A focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
- Study guide
8 Software Documentation
Learn how to choose, structure, document, and maintain software documentation for users, developers, integrators, and operators.
- Study guide
9 Sorting Algorithms
A structured guide to comparison-based sorting algorithms, their complexity, stability, memory use, and practical selection criteria.
- Study guide
10 — Data, Systems, and Applications
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
- Quiz
12 — Foundations Capstone
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.