6cs5 Ds Unit 4 Unit 4
6cs5 Ds Unit 4 Unit 4
7/12/2021
Department of
Computer Science & Engineering
Ms.Rashi jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
UNIT-IV
7/12/2021
Distributed Shared
Memory
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
3
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
Outline
7/12/2021
• Introduction of DSM
• Non-Uniform Memory Access Architectures
• Memory Consistency Models
• Multiprocessor Cache Systems
• Implementation of DSM Systems
7/12/2021
Distributed shared memory(DSM) system is a resource management component
of distributed operating system that implements shared memory model in distributed
system which have no physically shared memory. The shared memory model provides a virtual
address space which is shared by all nodes in a distributed system.
Distributed shared memory (DSM) is a form of memory architecture where physically separated
memories can be addressed as one logically shared address space.
Note: Here, the term "shared" does not mean that there is a single centralized memory, but that the
address space is "shared" (same physical address on two processors refers to the same location in
memory). 5
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
DSM cont...
o A distributed-memory system, often called a multicomputer, consists of multiple
independent processing nodes with local memory modules which is connected by a
7/12/2021
general interconnection network.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
NUMA is a type of parallel processing architecture.
Numa cont...
7/12/2021
A processor usually uses its local memory
to store the data required for its processing.
Accessing a local memory has least latency.
It can also utilize the remote memory.
Scalability is not an issue even if the count
of processors grow up in this architecture.
7/12/2021
Consistency requirement vary from application to application.
Defined as a set of rules that application must obey if they want the DSM
system to provide the degree of consistency guaranteed by the consistency
model.
If a system support the stronger consistency model then the weaker
consistency model is automatically supported but the converse is not true
9
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Strict Consistency model
Sequential Consistency model
Causal consistency model
Pipelined Random Access Memory consistency model(PRAM)
Processor Consistency model
Weak consistency model
Release consistency model
10
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
This is the strongest form of memory coherence having the most stringent
consistency requirement.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Absolute synchronization of clock of all the nodes of a distributed system is
not possible.
Only acceptable ordering for a strictly consistency memory is (r1, w1, r2)
12
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Proposed by Lamport [1979].
A shared memory system is said to support the sequential consistency model if all
processes see the same order.
Any of the orderings (r1, w1, r2), (r1, r2, w1), (w1, r1, r2), (w1, r2, r1), (r2, r1, w1),
13
(r2, w1, r1) is acceptable provided all processes see the same ordering
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
The consistency requirement of the sequential consistency model is weaker
than that of the strict consistency model.
14
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Proposed by Hutto and Ahamad (1990).
All processes see only those memory reference operations in the correct
order that are potentially causally related.
15
Maintaining dependency graphs for memory access operations.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Proposed by Lipton and Sandberg (1988).
Ensures that all write operations performed by a single process are seen by
all other processes in the order in which they were performed.
7/12/2021
If w11 and w12 are two write operations performed by a process P1 in that
order, and w21 and w22 are two write operations performed by a process
P2 in that order.
PRAM consistency all processes do not agree on the same order of memory
reference operations 17
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Very similar to PRAM model with additional restriction of memory coherence.
Memory coherence means that for any memory location all processes agree on the
same order of all write operations performed on the same memory location (no
matter by which process they are performed) are seen by all processes in the
same order.
If w12 and w22 are write operations for writing the same memory location x, all
processes must see them in the same order- w12 before w22 or w22 before w12.
Processes P3 and P4 must see in the same order, which may be either [(w11,w12),
18
(w21,w22)] or [(w21,w22), (w11,w12)]
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Common characteristics to many application:
7/12/2021
variable called a synchronization variable.
Requirements:
1. All accesses to synchronization variables must obey sequential
consistency semantics.
2. All previous write operations must be completed everywhere before an
access to a synchronization variable is allowed.
3. All previous accesses to synchronization variables must be completed
before access to a non synchronization variable is allowed.
20
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Use of two synchronization variables.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Barrier can be implemented by using a centralized barrier server .
Requirements:
1 All accesses to acquire and release synchronization variable obey processor
consistency semantics.
2 All previous acquires perform by a process must be completed successfully before
the process is allowed to perform a data access operation on the memory.
3 All previous data access operations performed by a process must be completed
successfully before a release access done by the process is allowed.
7/12/2021
copies of shared data: one copy in the main memory and one in the
local cache of each processor that requested it.
23
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
24
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
In this type of system distributed shared memory provides a virtual memory space that is
accessible by all the system (also known as nodes) of the distributed hierarchy.
7/12/2021
Some common challenges that are to be kept in mind while the implementation of DSM −
Tracking of the memory address (location) of data stored remotely in shared memory.
To reduce the communication delays and high overhead associated with the references to remote
data.
Controlling the concurrent access of the data shared in DSM.
Based on these challenges there are algorithms designed to implement distributed shared memory.
There are four algorithms −
-Central Server Algorithm
-Migration Algorithm
-Read Replication Algorithm 25
-Full Replication Algorithm Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
with acknowledgment messages.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
migration algorithm
As the name suggest the migration
algorithm does the work of migration of
data elements. Instead of using a central
server serving each request, the block
7/12/2021
containing the data requested by a
system is migrated to it for further
access and processing. It migrates the
data on request.
7/12/2021
operation is to be done, then all read
access is put on halt till all the copies are
updated.
7/12/2021
access of nodes is controlled to maintain
its consistency.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
3) Distributed Snapshots
4) Modelling a distributed computation
5) Failure in DS
6) Distributed mutual exclusion
7) Election
8) Distributed Deadlock handling
9) Distributed Termination detection
10) Detection of dynamic termination
- The STD algorithm
30
- The DTD algorithm
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
31
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
32
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
Distributed snapshots
A snapshot algorithm is used to create a
consistent snapshot of the global state of
a distributed system. Due to the lack of globally
shared memory and a global clock, this isn't trivially
possible.
7/12/2021
A distributed snapshot algorithm captures a
consistent global state of a distributed system. A
global state can be described by a cut that indicates
the time at which each process “checkpoints” its local
state and messages. In the case of a consistent cut C
(Fig), if a message crosses C, its “send” should be
before C and its “receive” should be after C.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
34
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
Failure in DS
DSM implements distributed systems shared memory model in an
exceedingly distributed system, that hasn’t any physically shared
memory.
7/12/2021
The shared model provides a virtual address space shared between any
numbers of nodes. The DSM system hides the remote communication
mechanism from the appliance author, protecting the programming ease
and quality typical of shared-memory systems.
35
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
Failure in DS cont...
Failure recovery is an interesting problem in many applications, but especially in distributed systems, where
there may be multiple devices participating and multiple points of failure.
It’s very educational to identify the distinct roles in a system, and ask for each one, “What would happen
if that part of the system failed?”
7/12/2021
Network failures: participants are still running, but the connection between two or more is lost, or one or more
messages are dropped before reaching the recipient. Some systems may also have issues with unexpected delays
in message delivery.
Crash failures: a participant shuts down unexpectedly. This can occur as a result of application or environment
errors, or simply a loss of power.
Byzantine failures: a participant may act arbitrarily. This may be due to an adversary taking control of a
server, after which they may actively attempt to undermine the system. Byzantine failures remain an open
research area, and are often difficult to handle unless the system was explicitly designed with potentially
compromised participants in mind.
Simultaneous or repeated failures: these are somewhat meta-failures, in which multiple participants fail at
the same time, or a single participant experiences recurring failures.
Fault tolerant systems are those that are able to survive common failures and continue providing service even
while failures are occurring.
A lot of the work that results in failure recovery occurs at the design level of a system, so it’s useful to consider
the types of failures that may occur, the expected frequency and impact of failures, and design choices that may 36
reduce the risk of failures impacting our users.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Only one process is allowed to execute the critical section (CS) at any
given time.
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
1 Safety Property: At any instant, only one process can execute the
7/12/2021
critical section.
3 Fairness: Each process gets a fair chance to execute the CS. Fairness
property generally means the CS execution requests are executed in the
order of their arrival (time is determined by a logical clock) in the system.
38
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
in distributed systems:
7/12/2021
⚫ This approach use timestamps instead of sequence number to order requests
for the critical section.
⚫ When ever a site make request for critical section, it gets a timestamp.
Timestamp is also used to resolve any conflict between critical section
requests.
⚫ All algorithm which follows non-token based approach maintains a logical
clock. Logical clocks get updated according to Lamport’s scheme
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
⚫ This common site is responsible to ensure mutual exclusion
41
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
Suzuki-kasami algorithm
Suzuki–Kasami algorithm is a token-based algorithm for achieving mutual exclusion in
distributed systems.This is modification of Ricart–Agrawala algorithm, a permission based
(Non-token based) algorithm which uses REQUEST and REPLY messages to ensure mutual
exclusion.
In token-based algorithms, A site is allowed to enter its critical section if it possesses the unique
7/12/2021
token. Non-token based algorithms uses timestamp to order requests for the critical section
where as sequence number is used in token based algorithms.
Each requests for critical section contains a sequence number. This sequence number is used to
distinguish old and current requests.
Suzuki-kasami algorithm
Algorithm:
7/12/2021
Here sn is update value of RNi[i]
⚫ When a site Sj receives the request message REQUEST(i, sn) from site Si, it sets RNj[i] to
maximum of RNj[i] and sn i.e RNj[i] = max(RNj[i], sn).
⚫ After updating RNj[i], Site S j sends the token to site Si if it has token and RNj[i] = LN[i] + 1
To execute the critical section:
⚫ Site S executes the critical section if it has acquired the token.
i
7/12/2021
Two type of messages ( REQUEST and REPLY) are used and communication channels
are assumed to follow FIFO order.
A site send a REQUEST message to all other site to get their permission to enter
critical section.
A site send a REPLY message to other site to give its permission to enter the critical
section.
A timestamp is given to each critical section request using Lamport’s logical clock.
Timestamp is used to determine priority of critical section requests. Smaller timestamp
gets high priority over larger timestamp. The execution of critical section request is
always in the order of their timestamp.
44
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
When a site Sj receives a REQUEST message from site Si, It sends
a REPLY message to site Si if and only if
Site Sj is neither requesting nor currently executing the critical section.
In case Site Sj is requesting, the timestamp of Site Si‘s request is smaller than its own
request.Otherwise the request is deferred by site S j.
To execute the critical section:
⚫ Site Si enters the critical section if it has received the REPLY message from all
other sites.
To release the critical section:
⚫ Upon exiting site Si sends REPLY message to all the deferred requests.
45
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
but from a subset of sites which is called quorum.
In this algorithm:
Three type of messages ( REQUEST, REPLY and RELEASE) are used.
A site send a REQUEST message to all other site in its request set or
quorum to get their permission to enter critical section.
A site send a REPLY message to requesting site to give its permission to
enter the critical section.
A site send a RELEASE message to all other site in its request set or
quorum upon exiting the critical section. 46
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
a REPLY message to site Si if it has not sent a REPLY message to the site from the
time it received the last RELEASE message. Otherwise, it queues up the request..
To execute the critical section:
⚫ A site Si can enter the critical section if it has received the REPLY message from all the
site in request set R i
To release the critical section:
⚫ When a site S i exits the critical section, it sends RELEASE(i) message to all other sites
in request set R i
⚫ When a site S j receives the RELEASE(i) message from site Si , it send REPLY message
to the next site waiting in the queue and deletes that entry from the queue
⚫ In case queue is empty, site Sj update its status to show that it has not sent 47
any REPLY message since the receipt of theJain
Ms.Rashi last RELEASE message
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Communication in networks is implemented in a process on one machine
communicating with a process on other machine.
48
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
Election algorithms
Election algorithms choose a process from group of processors to act as a
coordinator. If the coordinator process crashes due to some reasons, then
a new coordinator is elected on other processor. Election algorithm
basically determines where a new copy of coordinator should be restarted.
7/12/2021
Election algorithm assumes that every active process in the system has a
unique priority number. The process with highest priority will be chosen
as a new coordinator. Hence, when a coordinator fails, this algorithm
elects that active process which has highest priority number. Then this
number is send to every active process in the distributed system.
49
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Suppose process P sends a message to the coordinator.
If coordinator does not respond to it within a time interval T, then it is assumed that
coordinator has failed.
Now process P sends election message to every process with high priority number.
It waits for responses, if no one responds for time interval T then process P elects itself
as a coordinator.
Then it sends a message to all lower priority number processes that it is elected as
their new coordinator.
However, if an answer is received within time T from any other process Q,
⚫ (I) Process P again waits for time interval T’ to receive another message from Q
that it has been elected as coordinator.
⚫ (II) If Q doesn’t responds within time interval T’ then it is assumed to have failed
and algorithm is restarted. 50
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
51
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Algorithm –
If process P1 detects a coordinator failure, it creates new active list which is
empty initially. It sends election message to its neighbour on right and adds
number 1 to its active list.
If process P2 receives message elect from processes on left, it responds in 3
ways:
⚫ (I) If message received does not contain 1 in active list then P1 adds 2 to its active list
and forwards the message.
⚫ (II) If this is the first election message it has received or sent, P1 creates new active list
with numbers 1 and 2. It then sends election message 1 followed by 2.
⚫ (III) If Process P1 receives its own election message 1 then active list for P1 now
52
contains numbers of all the active processes in the system. Now Process P1 detects
highest priority number from list andMs.Rashi
elects it as the new coordinator.
Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
53
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
54
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
55
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Progress –
The method should be able to detect all the deadlocks in the system.
Safety –
The method should not detect false or phantom deadlocks.
56
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
fails the whole system crashes) which in turns makes the system less reliable.
Distributed approach –
In the distributed approach different nodes work together to detect deadlocks.
No single point failure (that is the whole system is dependent on one node if
that node fails the whole system crashes) as the workload is equally divided
among all nodes. The speed of deadlock detection also increases.
Hierarchical approach –
This approach is the most advantageous. It is the combination of both
centralized and distributed approaches of deadlock detection in a distributed
system. In this approach, some selected nodes or clusters of nodes are 57
Basic idea: "When one process is about to block waiting for a resource that
another process is using, a check is made to see which has a larger timestamp (i.
7/12/2021
e. is younger)."
7/12/2021
chain of waiting processes,
cycles are impossible.
59
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
so cycles are again impossible.
It is wiser to give older processes priority.
60
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
Termination occurs when all processes in the distributed
system become idle and there are no computational messages in transit.
61
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
A distributed task is started by a process sending a computational message to another
process. This initial process to send the message is the "controlling agent".
⚫ The initial weight of the controlling agent is {\displaystyle w} (usually 1).
The following rules are applied throughout the computation:
⚫ A process sending a message splits its current weight between itself and the message.
⚫ A process receiving a message adds the weight of the message to itself.
⚫ Upon becoming idle, a process sends a message containing its entire weight back to the
controlling agent and it goes idle.
⚫ Termination occurs when the controlling agent has a weight of {\displaystyle w} and is in the
idle state.
Some weaknesses to Huang's algorithm are that it is unable to detect termination if a
message is lost in transit or if a process fails while in an active state.
62
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])
lOMoARcPSD|55959726
7/12/2021
of study. A large number of termination detection algorithms have been
proposed for static distributed systems in which the number of nodes present
in the system is fixed and never changes during runtime.
7/12/2021
Thank You .....
64
Ms.Rashi Jain
Downloaded by Jitesh Kumawat ([email protected])