Limitations of Distributed System

advertisement
HINDUSTAN COLLEGE OF SCIENCE & TECHNOLOGY
Department of Computer Science & Engineering
SUBJECT: DISTRIBUTED SYSTEM (ECS-701)
SOLUTIONS OF PAPER-(MT-I)
SESSION: (2012-13)
Time: 1.5hrs
M.M.30
Note-Read each question carefully and give your answers concisely & precisely manner.
SECTION –A
Q1. Attempt any two parts of the following -
(3*2=6)
a) What is Distributed System? What are the significant advantages & limitations of Distributed
System? Explain with Example what could be the impact of absence of global Clock &
Shared Memory?
ANS: - Distributed System- A distributed system is one in which components located at networked
computers communicate and coordinate their actions only by passing messages.
OR
It is a no of autonomous processing elements(not necessarily homogenious) that are interconnected by a
Computer network & they cooperate in processing there assigned task transpareantly.
Advantages of Distributed System:



Data sharing: allow many users to access to a common data base
Resource Sharing: expensive peripherals like color printers
Communication: enhance human-to-human communication, e.g., email, chat
Flexibility: spread the workload over the available machines
Page 1 of 23
Limitations of Distributed System:a. A distributed system is a set of computers that communicate over a network, and do not
share a common memory or a common clock.
b. Absence of a common (global) clock
i. No concept of global time
ii. It’s difficult to reason about the temporal ordering of events
1. Cooperation between processes(e.g., producer/consumer, client/server)
2. Arrival of requests to the OS (e.g., for resources)
3. Collecting up-to-date global state
c. It’s difficult to design and debug algorithms in a distributed system



Mutual exclusion
Synchronization
Deadlock
Impact: It is impossible to have a coherent global state.(explain with diagram)
Page 2 of 23
b) Give 5 types of Hardware Resources & 5 types of Data or Software resources that can be
usually be shared. Give example of their Sharing as it occurs in Distributed System?
ANS:-
Page 3 of 23
c) What do you means by Global State of Distributed System? What are the difference between
Consistent GS, Transit less GS and Strongly Consistent GS?
ANS:- Global State of Distributed System:-
Page 4 of 23
Page 5 of 23
SECTION –B
Q2. Attempt any three parts of the following-
(3*3=9)
a) What do you mean by Casual ordering of Messages? Discuss an algorithm which guarantees
the Casual ordering of message in DS? (BSS ALGO)
ANS:-


Protocol
Birman-Schiper-Stephenson Protocol (BSS)IntroductionThe goal of this protocol is to preserve ordering in the sending of messages. For
example, if send(m1) -> send(m2), then for all processes that receive both m1 and m2,
receive(m1) -> receive(m2). The basic idea is that m2 is not given to the process until m1
is given. This means a buffer is needed for pending deliveries. Also, each message has an
associated vector that contains information for the recipient to determine if another
message preceded it. Also, we shall assume all messages are broadcast. Clocks are
updated only when messages are sent.
Notation
 n processes
 Pi process
Ci vector clock associated with process Pi; jth element is Ci[j] and contains Pi's latest
value for the current time in process Pj.
tm vector timestamp for message m (stamped after local clock is incremented).
Pi sends a message to Pj
Pi increments Ci[i] and sets the timestamp t
m = Ci[i] for message m. 1.
Pj receives a message from Pi
When Pj, j != i, receives m with timestamp t
m, it delays the message's delivery
until both:
Cj[i] = t
m[i] - 1; and a.
for all k <= n and k != i, Cj[k] <= t
m[k]. b.
1.
When the message is delivered to Pj, update Pj's vector clock 2.Check buffered
messages to see if any can be delivered.
Page 6 of 23
Page 7 of 23
b) Explain the Haung’s termination detection Algorithm in distributed system? Explain with
example?
ANS: - Haung’s termination detection-
Example
The picture shows a process P0, designated the controlling agent, with W0 = 1. It asks
P1 and P2 to do some computation. It sets W1 to 0.2, W2 to 0.3,and W3 to 0.5. P2 in turn
asks P3 and P4 to do some computations. It sets W3 to 0.1 and W4 to 0.1.
When P3 terminates, it sends C(W3) = C(0.1) to P2, which changes W2 to 0.1 + 0.1 = 0.2.
Page 8 of 23
c) What is Vector Clock? Explain with the help of Implementation rules of Vector Clock? What
are the advantages of Vector Clock over Lamport’s Clock?
Page 9 of 23
ANS: - Vector Clock-
Page 10 of 23
•
d) Explain the Key Characteristics of Distributed System? What is Architectural Model of the
Distributed System?
ANS:- Key Characteristics of Distributed System:- The key characteristics of a distributed
system-(Explain Each)
– Resource sharing
– Fault Tolerance
– Openness
– Transparency
– Concurrency
– Heterogeneity
– Scalability
– Quality of service.
Architectural Model of the Distributed System:- Architectural models describe a system in
terms of the computational and communication tasks performed by its computational elements;
the computational elements being individual computers or aggregates of them supported by
appropriate network interconnections. Client-server and peer-to-peer are two of the most
commonly used forms of architectural model for distributed systems..
Models:-(explain each)






Client Server Model
Service provided by multiple servers
Proxy Server & caches
Peer process
Variation of client server Model
Mobile Device and Spontaneous network
SECTION –C
Q3. Attempt any three parts of the following-
(3*5=15)
a) Define the Problem of Distributed Mutual Exclusion? What are the Requirements of Good
Mutual Exclusion Algorithm? How to Measure the performance metrics for distributed
mutual exclusion algorithm?
Page 11 of 23
ANS: - Problem of Distributed Mutual Exclusion:-
Page 12 of 23
Performance: Number of messages per CS invocation: should be minimized.
 Synchronization delay, i.e., time between the leaving of CS by a site and the entry of CS by the
next one: should be minimized.
 Response time: time interval between request messages transmissions and exit of CS.
 System throughput, i.e., rate at which system executes requests for CS: should be maximized.

If sd is synchronization delay, E the average CS execution time: system throughput = 1 / (sd + E).
b) What is Non-Token Based Algorithms? Explain Lamport’s Algorithms with Suitable
Examples?
ANS :- Non-Token Based Algorithms:-
Page 13 of 23
Page 14 of 23
c) What is Deadlock? Explain the Deadlock Handling Strategies in Distributed System in
Detail?
ANS: - Deadlock- A deadlock is a situation in which two or more competing actions are each
waiting for the other to finish, and thus neither ever does.
 A deadlock is a situation which occurs when a process enters a waiting state because
a resource requested by it is being held by another waiting process, which in turn is waiting for
another resource.
 If a process is unable to change its state indefinitely because the resources requested by it are
being used by another waiting process, then the system is said to be in a deadlock.
 Deadlock is a common problem in multiprocessing systems, parallel computing and distributed
systems.
Example Suppose a computer has three CD drives and three processes. Each of the three processes holds
one of the drives.
 If each process now requests another drive, the three processes will be in a deadlock.
 Each process will be waiting for the "CD drive released" event, which can be only caused by one
of the other waiting processes.
 Thus, it results in a circular chain.
Necessary conditionsA deadlock situation can arise if and only if all of the following conditions hold simultaneously in a
system:
 Mutual Exclusion
 Hold and Wait or Resource Holding:
 No Preemption
 Circular Wait
Deadlock Handling Strategies in Distributed System1)Ignoring deadlock
In this approach, it is assumed that a deadlock will never occur. This is also an application of the Ostrich
algorithm. This approach was initially used by MINIX and UNIX. This is used when the time intervals between
occurrences of deadlocks are large and the data loss incurred each time is tolerable.
2)Detection
Under deadlock detection, deadlocks are allowed to occur. Then the state of the system is examined to detect that a
deadlock has occurred and subsequently it is corrected. An algorithm is employed that tracks resource allocation and
process states, it rolls back and restarts one or more of the processes in order to remove the detected deadlock.
Page 15 of 23
Detecting a deadlock that has already occurred is easily possible since the resources that each process has locked
and/or currently requested are known to the resource scheduler of the operating system. [9]
Deadlock detection techniques include, but are not limited to, model checking. This approach constructs a finite statemodel on which it performs a progress analysis and finds all possible terminal sets in the model. These then each
represent a deadlock.
After a deadlock is detected, it can be corrected by using one of the following methods:
1. Process Termination: One or more process involved in the deadlock may be aborted. We can choose to
abort all processes involved in the deadlock. This ensures that deadlock is resolved with certainty and
speed. But the expense is high as partial computations will be lost. Or, we can choose to abort one process
at a time until the deadlock is resolved. This approach has high overheads because after each abortion an
algorithm must determine whether the system is still in deadlock. Several factors must be considered while
choosing a candidate for termination, such as priority and age of the process.
2. Resource Preemption: Resources allocated to various processes may be successively preempted and
allocated to other processes until the deadlock is broken.
3)Prevention
Deadlock prevention works by preventing one of the four Coffman conditions from occurring.

Removing the mutual exclusion condition means that no process will have exclusive access to a resource. This
proves impossible for resources that cannot be spooled. But even with spooled resources, deadlock could still
occur. Algorithms that avoid mutual exclusion are called non-blocking synchronization algorithms.

The hold and wait or resource holding conditions may be removed by requiring processes to request all the
resources they will need before starting up (or before embarking upon a particular set of operations). This
advance knowledge is frequently difficult to satisfy and, in any case, is an inefficient use of resources. Another
way is to require processes to request resources only when it has none. Thus, first they must release all their
currently held resources before requesting all the resources they will need from scratch. This too is often
impractical. It is so because resources may be allocated and remain unused for long periods. Also, a process
requiring a popular resource may have to wait indefinitely, as such a resource may always be allocated to some
process, resulting in resource starvation.[1] (These algorithms, such as serializing tokens, are known as the allor-none algorithms.)

The no preemption condition may also be difficult or impossible to avoid as a process has to be able to have a
resource for a certain amount of time, or the processing outcome may be inconsistent or thrashing may occur.
However, inability to enforce preemption may interfere with a priority algorithm. Preemption of a "locked out"
resource generally implies a rollback, and is to be avoided, since it is very costly in overhead. Algorithms that
allow preemption include lock-free and wait-free algorithms and optimistic concurrency control.

The final condition is the circular wait condition. Approaches that avoid circular waits include disabling interrupts
during critical sections and using a hierarchy to determine a partial orderingof resources. If no obvious hierarchy
exists, even the memory address of resources has been used to determine ordering and resources are
requested in the increasing order of the enumeration Dijkstra's solution can also be used.
Page 16 of 23
4)Avoidance
Deadlock can be avoided if certain information about processes are available to the operating system before
allocation of resources, such as which resources a process will consume in its lifetime. For every resource request,
the system sees whether granting the request will mean that the system will enter an unsafe state, meaning a state
that could result in deadlock. The system then only grants requests that will lead to safe states.[1] In order for the
system to be able to determine whether the next state will be safe or unsafe, it must know in advance at any time:

resources currently available

resources currently allocated to each process

resources that will be required and released by these processes in the future
It is possible for a process to be in an unsafe state but for this not to result in a deadlock. The notion of safe/unsafe
states only refers to the ability of the system to enter a deadlock state or not. For example, if a process requests A
which would result in an unsafe state, but releases B which would prevent circular wait, then the state is unsafe but
the system is not in deadlock.
One known algorithm that is used for deadlock avoidance is the Banker's algorithm, which requires resource usage
limit to be known in advance.[1] However, for many systems it is impossible to know in advance what every process
will request. This means that deadlock avoidance is often impossible.
Two other algorithms are Wait/Die and Wound/Wait, each of which uses a symmetry-breaking technique. In both
these algorithms there exists an older process (O) and a younger process (Y). Process age can be determined by a
timestamp at process creation time. Smaller timestamps are older processes, while larger timestamps represent
younger processes.
Wait/Die Wound/Wait
O needs a resource held by Y O waits
Y dies
Y needs a resource held by O Y dies
Y waits
5)Resolution-
Page 17 of 23
d) Write Short Notes on any Two of the Followings1) Suzuki and Kasami’s Algorithm.
ANS:-
Page 18 of 23
Page 19 of 23
2) Raymond Tree-Based Algorithm.
Page 20 of 23
ANS:-
Page 21 of 23
Page 22 of 23
3) Issues in deadlock detection and Resolution of Deadlock.
ANS: - Issues in deadlock detection and Resolution of Deadlock:• Progress
– No undetected deadlocks
• All deadlocks found
• Deadlocks found in finite time
• Safety
– No false deadlock detection
• Phantom deadlocks (false) caused by network latencies
• Principal problem in building correct DS deadlock detection
algorithms
Resolution:•
Breaking Existing Wait for dependencies in system
•
Rolling back one or more processes that are deadlocked and assigning their resources to blocked
processes in the deadlock.
•
When WF dependency is broken the corresponding information should be immediately cleaned
up (detection of phantom deadlock).
***********************BEST OF LUCK***********************
Page 23 of 23
Download