I'm reading The Art of Multiprocessor Programming and am currently trying to understand Chapter 4 — The Foundations of Shared Memory.
In section 4.2 it is shown how to build a multi-reader, single-writer (MRSW) safe Boolean register from a single-reader, single-writer (SRSW) safe Boolean register. So, the only difference is that the new register supports multiple readers, but the consistency guarantee (safe) is the same.
The implementation (figure 4.6) uses an array of SRSW safe Boolean registers, with one element for each reader. What I don't understand is why can't we treat a SRSW safe Boolean register as a MRSW safe Boolean register, already?
The definition for the safe consistency level says that a register is safe if:
- A read call that does not overlap a write call must return the value written by the most recent write call.
- A read call that overlaps a write may return any value within the register's allowed range of values (in the case of a Boolean register, just 0 and 1).
It seems to me that a SRSW safe Boolean register can already be treated like a MRSW safe Boolean register because any number of reads concurrent with a write will return either 0 or 1. Non-overlapping reads are obviously fine.
Is there a nuance I'm missing here or is it just a self-imposed limitation that a SRSW safe Boolean register can't be used with multiple readers, just by the definition? I understand this whole register derivation tower is pretty artificial and used mostly for theoretical considerations, so I'm thinking such an artificial limitation is very possible.
Asked By : Ionuț G. Stan
Answered By : Tom van der Zanden
You do not know anything about the behavior of the register if read calls overlap.
Perhaps the register is a sensitive electrical component and overlapping reads will blow it up?
Perhaps reading (counter-intuitively) requires changing the state of the register, for instance writing the target memory location which the value must be read in to? If two reads overlap then it might end up writing the value to the wrong location or to only one of the two locations?
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/44527
0 comments:
Post a Comment
Let us know your responses and feedback