encyclopegia.org

Shared snapshot objects

In distributed computing, a shared snapshot object is a type of data structure, which is shared between several threads or processes. For many tasks, it is important to have a data structure, that can provide a consistent view of the state of the memory. In practice, it turns out that it is not possible to get such a consistent state of the memory by just accessing one shared register after another, since the values stored in individual registers can be changed at any time during this process. To solve this problem, snapshot objects store a vector of n components and provide the following two atomic operations: update(i,v) changes the value in the ith component to v, and scan() returns the values stored in all n components. Snapshot objects can be constructed using atomic single-writer multi-reader shared registers. In general, one distinguishes between single-writer multi-reader (swmr) snapshot objects and multi-writer multi-reader (mwmr) snapshot objects. In a swmr snapshot object, the number of components matches the number of processes and only one process P i is allowed to write to the memory position i and all the other processes are allowed to read the memory. In contrast, in a mwmr snapshot object all processes are allowed to write to all positions of the memory and are allowed to read the memory as well.

In distributed computing, a shared snapshot object is a type of data structure, which is shared between several threads or processes. For many tasks, it is important to have a data structure, that can provide a consistent view of the state of the memory. In practice, it turns out that it is not possible to get such a consistent state of the memory by just accessing one shared register after another, since the values stored in individual registers can be changed at any time during this process. To solve this problem, snapshot objects store a vector of n components and provide the following two atomic operations: update(i,v) changes the value in the ith component to v, and scan() returns the values stored in all n components. Snapshot objects can be constructed using atomic single-writer multi-reader shared registers. In general, one distinguishes between single-writer multi-reader (swmr) snapshot objects and multi-writer multi-reader (mwmr) snapshot objects. In a swmr snapshot object, the number of components matches the number of processes and only one process P i is allowed to write to the memory position i and all the other processes are allowed to read the memory. In contrast, in a mwmr snapshot object all processes are allowed to write to all positions of the memory and are allowed to read the memory as well. a[1..n] := collect; b[1..n] := collect; if (∀i∈{1, .., n} location i was not changed between the reads of it during the two collects)) then return b; // double collect successful loop end function update(i, v) M[i] := v; end This algorithm provides a very basic implementation of snapshot objects. It guarantees that the system proceeds, while individual threads can starve due to the behaviour of individual processes. A process P i can prevent another process P j from terminating a scan() operation by always changing its value, in between the two memory collects. Thus, the algorithm is lock-free, but not wait-free. To hold this stronger the property, no process is allowed to starve due to the behavior of other processes. Figure 1 illustrates the problem. While P 1 tries to execute the scan() operation, a second process P 2 always disturbs the "double-collect". Thus, the scanning process always has to restart the operation and can never terminates and starves. for j = 1 to n do moved[j] := 0 end while true do a[1..n] := collect; // collects (data, sequence, view) triples b[1..n] := collect; // collects (data, sequence, view) triples if (∀j∈{1, ..., n}) (a[j].seq = b[j].seq) then return (b[1].data, ..., b[n].data) // no process changed memory else for j = 1 to n do if a[j].seq ≠ b[j].seq then // process moved if moved[j] = 1 then // process already moved before return b[j].view; else moved[j] := moved[j] + 1; end end end function procedure update(i,v) // updates the registers with the data-values, updates the sequence number, embedded scan s[1..n] := scan; // embedded scan r i := (v, r i .seq = r i .seq + 1, s[1..n]); end procedure Every register consists of a field for the data-value, the sequence number and a field for the result of the last embedded scan, collected before the last update. In each scan operation the process P i can decide whether a process changed its memory using the sequence number. If there is no change to the memory during the double collect, P i can return the result of the second scan. Once the process observes that another process updated the memory in between, it saves this information in the moved field. If a process P j changed its memory twice during the execution of the scan(), the scanning process P i can return the embedded scan of the updating process, which it saved in its own register during its update operation. These operations can be linearized by linearizing each update() operation at its write to the register. The scan operation is more complicated to linearize. If the double collect of the scan operation is successful the scan operation can be linearized at the end of the second scan. In the other case - one process updated its register two times - the operation can be linearized at the time the updating process collected its embedded scan before writing its value to the register. for j=1 to n do moved[j] := 0 end while true do for j=1 to n do q i,j := r j .p j,i end a[1..n] := collect; // collects (data, bit-vector, toggle, view) triples b[1..n] := collect; // collects (data, bit-vector, toggle, view) triples if (∀j∈{1, ...,n}) (a[j].p j,i = b[j].p j,i = q i,j ) and a[j].toggle = b[j].toggle then return (b[1].data, ..., b[n].data) // no process changed memory else for j=1 to n do if (a[j].p j,i ≠ q i,j ) or (b[j].p j,i ≠ q i,j ) or (a[j].toggle ≠ b[j].toggle) then // process j performed an update if moved[j] = 2 then // process already moved before return b[j].view; else moved[j] := moved[j] + 1; end end end function procedure update(i,v) // updates the registers with the data-value, "write-state" of all registers, invert the toggle bit and the embedded scan for j = 1 to n do f[j] := ¬q j,i end s[1..n] := scan; // embedded scan r i := (v, f[1..n], ¬r i .toggle, s[1..n]); end procedure The unbounded sequence number is replaced by two handshake bits for every pair of processes. These handshake bits are based on swsr registers and can be expressed by a matrix M, where process P i is allowed to write to row i and is allowed to read the handshake bits in a column i. Before the scanning-process performs the double-collect it collects all the handshake bits from all registers, by reading its column. Afterwards, it can decide whether a process changed its value during the double value or not. Therefore, the process just has to compare the column again with the initially read handshake bits. If only one process P j has written twice, during the collection of P i it is possible that the handshake bits do not change during the scan. Thus, it is necessary to introduce another bit called "toggle bit", this bit is changed in every write. This makes it possible to distinguish two consecutive writes, even though no other process updated its register. This approach allows to substitute the unbounded sequence numbers with the handshake bits, without changing anything else in the scan procedure. While the scanning process P i uses a handshake bit to detect whether it can use its double collect or not, other processes may also perform update operations. As a first step, they read again the handshake bits provided by the other processes, and generate the complement of them. Afterwards these processes again generate the embedded scan and save the updated data-value, the collected - complemented - handshake bits, the complemented toggle bit and the embedded scan to the register. Since the handshake bits equivalently replace the sequence numbers, the linearization is the same as in the unbounded memory case.

References

No reference rows published for this article.

Cite this article

MLA

"Shared snapshot objects." encyclopegia.org, 2025, https://encyclopegia.org/wiki/shared-snapshot-objects. Accessed 24 November 2026.

Chicago

"Shared snapshot objects." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/shared-snapshot-objects.

APA

encyclopegia.org. (2025). Shared snapshot objects. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/shared-snapshot-objects

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1314913461 · 0.5 · snapshot enwiki-001314913461

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.