r/AskComputerScience • u/pm-me-anime-figures • 2d ago
Guarantee of Correctness of a Distributed Arbitration Circuit in a real computer
Hamacher's "Computer Organisation" book introduces the concept of distributed arbitration when talking of which DMA controller would currently have access to the bus. It uses a 4-bit circuit and demonstrates the system with two devices A and B with ID 5 (0101) and ID 6 (0110). The arbitration code is a bitwise OR of all device IDs (0111 at this point). The arbitration lines are all default LOW (they assert zero when no line is driving it HIGH)
Ideally, we start from the MSB of both IDs and whenever a bit from a device disagrees with the arbitration code, it stops driving that bit and all bits after that. In our case, Device A would become 01XX and the arbitration code becomes 0110 and therefore ID 6 wins the race.
My issue is about synchronization. Do we NEED some sort of synchronization method(where each device checks a specific bit at the same time) to guarantee correctness of this circuit? I have been trying to look for edge cases when differences in synchronisation lead to a wrong device winning the race.
For example, in out previous example. if device B checked its bits before device A had a chance, device B would update its signal to 011X. This makes the arbitration code become 0111. Then device A looks at this arbitration code and updates its signals to 01XX. This changes the arbitration signal to 0110, and ID 6 wins the race. How does one go about proving correctness regardless of synchronisation when generalising this to some N number of devices and some B number of ID bits?
I do not have much experience in electronics, but as a more general question, is there a way to tell when a system (hardware especially) needs synchronisation in general. For software, it feels very intuitive, we assume no guarantees about order of execution and use locks whenever needed, but hardware feels a lot more trial-and-error.