词条 | Shared register | ||||||||||||||||||||||||||||||||||||||||||||||||||
释义 |
In distributed computing, shared-memory systems and message-passing systems are two means of interprocess communication which have been heavily studied. In shared-memory systems, processes communicate by accessing shared data structures. A shared (read-write) register, sometimes just called a register, is a fundamental type of shared data structure which stores a value and has two operations: Read, which returns the value stored in the register, and Write, which updates the value stored. Other types of shared data structures include read-modify-write, test-and-set, compare-and-swap etc. The memory location which is concurrently accessed is sometimes called a register. ClassificationRegisters can be classified according to the consistency condition they satisfy when accessed concurrently, the domain of possible values that can be stored, and how many processes can access with the Read or Write operation, which leads to in total 24 register types.[1]
When Read and Write happen concurrently, the value returned by Read may not be uniquely determined. Lamport defined three types of registers: safe registers, regular registers and atomic registers.[1] A Read operation of a safe register can return any value if it is concurrent with a Write operation, and returns the value written by the most recent Write operation if the Read operation does not overlap with any Write. A regular register differs from a safe register in that the read operation can return the value written by either the most recent completed Write operation or a Write operation it overlaps with. An atomic register satisfies the stronger condition of being linearizable. Registers can be characterized by how many processes can access with a Read or Write operation. A single-writer (SW) register can only be written by one process and a multiple-writer (MW) register can be written by multiple processes. Similarly single-reader (SR) register can only be read by one process and multiple-reader (MR) register can be read by multiple processes. For a SWSR register, it is not necessary that the writer process and the reader process are the same. ConstructionsThe figure below illustrates the constructions stage by stage from the implementation of SWSR register in an asynchronous message-passing system to the implementation of MWMR register using a SW Snapshot object. This kind of construction is sometimes called simulation or emulation.[2] In each stage (except Stage 3), the object type on the right can be implemented by the simpler object type on the left. The constructions of each stage (except Stage 3) are briefly presented below. There is an article which discusses the details of constructing snapshot objects. {{image frame|align=center|caption=Shared Register Stages of Constructions|width=700|content= }} An implementation is linearizable if, for every execution there is a linearization ordering that satisfies the following two properties:
Implementing an atomic SWSR register in a message passing systemA SWSR atomic (linearizable) register can be implemented in an asynchronous message-passing system, even if processes may crash. There is no time limit for processes to deliver messages to receivers or to execute local instructions. In other words, processes can not distinguish between processes which respond slowly or simply crash. The implementation given by Attiya, Bar-Noy and Dolev[3] requires n>2f, where n is the total number of processes in the system and f is the maximum number of processes that can crash during execution. The algorithm is as follows:
The linearization order of operations is: linearize WRITEs in the order as they occur and insert the READ after the WRITE whose value it returns. We can check that the implementation is linearizable. We can check property 2 especially when op1 is WRITE and op2 is READ and READ is immediately after WRITE. We can show by contradiction. Assume the READ does not see the WRITE, and then according to the implementation, we must have two disjoint sets of size (n-f) among the n processes. So 2*(n-f)≤ n leading to n≤2f, which contradicts the fact that n>2f. So the READ must read at least one value written by that WRITE. Implementing a SWMR register from SWSR registersA SWMR register can be written by only one process but can be read by multiple processes.
Let n be the number of processes which can read the SWMR register. Let Ri, 0i when 0j. The implementations of Read and Write are shown below.
The t-value of an operation is the value of t it writes and the operations are linearized by t-values. If Write and Read have the same t-value, order Write before Read. If several Reads have the same t-values, order them by the start time. Implementing a MWMR register from a SW Snapshot objectWe can use the a SW Snapshot object of size n to construct a MWMR register.
The linearization order is as follows. Order WRITE operations by t-values. If several WRITEs have the same t-value, order the operation with small process ID in front. Insert READs right after WRITE whose value they return, breaking ties by process ID and if still tied, break tie by start time. See also
References1. ^1 {{cite book|last1=Kshemkalyani|first1=Ajay D.|last2=Singhal|first2=Mukesh|title=Distributed computing : principles, algorithms, and systems|date=2008|publisher=Cambridge University Press|location=Cambridge|isbn=9780521876346|pages=435–437}} 2. ^{{cite book|last1=Attiya|first1=Hagit|last2=Welch|first2=Jennifer|title=Distributed computing: fundamentals, simulations, and advanced topics|date=Mar 25, 2004|publisher=John Wiley & Sons, Inc.|isbn=978-0-471-45324-6|url=http://ca.wiley.com/WileyCDA/WileyTitle/productCd-0471453242.html}} 3. ^{{cite journal|last1=Attiya|first1=Hagit|last2=Bar-Noy|first2=Amotz|last3=Dolev|first3=Danny|title=Sharing Memory Robustly in Message-passing Systems|journal=Proceedings of the Ninth Annual ACM Symposium on Principles of Distributed Computing|date=1990|volume=PODC '90|pages=363–375|doi=10.1145/93385.93441|url=http://doi.acm.org/10.1145/93385.93441}} 1 : Distributed computing problems |
||||||||||||||||||||||||||||||||||||||||||||||||||
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。