Chapter 2
Chapter 2
Distributed Operating
Systems
1
Introduction to distributed systems
• A distributed system is a loosely coupled architecture wherein
processors are inter-connected by a communication network.
• Distributed systems are multiprocessor systems but with the
following differences:
Distributed system works in a wide area network involving much
more communication as compared to computation.
Each node in a distributed system is a complete computer
having full set of peripherals including memory, communication
hardware, possibly different operating system and different file
system, etc.
The users of a distributed system have an impression that they
are working on a single machine.
2
Types of Distributed Operating Systems
3
Distributed Operating System
5
Distributed-Operating Systems (Cont.)
• Process Migration – execute an entire process, or parts of it,
at different sites
– Load balancing – distribute processes across network to
even the workload
– Computation speedup – subprocesses can run
concurrently on different sites
– Hardware preference – process execution may require
specialized processor
– Software preference – required software may be
available at only a particular site
– Data access – run process remotely, rather than transfer
all data locally
• Consider the World Wide Web
6
Advantages of Distributed Systems
– Economy – Better price performance ratio
– Resource sharing
• Sharing and printing files at remote sites
• Processing information in a distributed database
• Using remote specialized hardware devices
– Computation speedup – load sharing or job migration results higher
throughput & rapid response time
– Reliability – detect and recover from site failure, function transfer,
reintegrate failed site
– Communication – at geographically distant nodes
– Incremental Growth – new hardware or software can be added
7
Network Operating System
9
Network Operating System
10
Network Operating System
• Accesses resources on remote computers that run
independent operating systems
• Not responsible for resource management at remote locations
• Distributed functions are explicit rather than transparent
– A user or process must explicitly specify the resource’s
location to retrieve a networked file or remotely execute
an application
• Lack of transparency in network OSs
– Disadvantage: Does not provide some of the benefits of
distributed OSs
– Advantage: Easier to implement than distributed OSs
11
Distributed-Operating Systems
• Manage resources located in multiple networked computers
• Employ many of the same communication methods, file
system structures and other protocols found in network
operating systems
• Transparent communication
– Objects in the system are unaware of the separate
computers that provide the service (unlike network
operating systems)
• Rare to find a “truly” distributed system because the high level
of transparency is difficult to achieve
12
Design Issues in distributed operating
system
Transparency: the distributed system should appear as a conventional, centralized
system to the user
Transparency Description
Hide differences in data representation and how a resource is
Access
accessed
Location Hide where a resource is located
Migration Hide that a resource may move to another location
Relocation Hide that a resource may be moved to another location while in use
Replication Hide that a resource may be shared by several competitive users
Concurrency Hide that a resource may be shared by several competitive users
Failure Hide the failure and recovery of a resource
Persistence Hide whether a (software) resource is in memory or on disk
13
Design Issues in Distributed Operating System
Fault tolerance – the distributed system should continue to function in the face of
failure
Hardware, software and networks fail!
14
Design Issues in distributed operating
system
Scalability – as demands increase, the system should easily accept the addition of new
resources to accommodate the increased demand
Concept Example
Centralized services A single server for all users
Centralized data A single on-line telephone book
Centralized Doing routing based on complete
algorithms information
16
Communication in Distributed Operating System
17
Message Passing Protocol
18
Blocking versus Nonblocking Primitives
Client blocked
Client running Client running
19
Nonblocking send primitive
Client
blocked
Client running
Client running
Trap Return
21
Solutions to the drawbacks of nonblocking
primitives
22
Reliable versus Unreliable Primitives
23
Some examples of packet exchanges for
client-server communication
REQ
Client Server
ACK
REP
ACK
REQ
Client Server
REP
24
Remote Procedure call
• Basic idea: To execute a procedure at a remote site and ship
the results back.
• Goal: To make this operation as distribution transparent
as possible (i.e., the remote procedure call should look like a
local one to the calling procedure).
25
Remote Procedure Call (RPC)
26
Steps of a Remote Procedure Call
1. Client procedure calls client stub in normal way
2. Client stub builds message, calls local OS
3. Client's OS sends message to remote OS
4. Remote OS gives message to server stub
5. Server stub unpacks parameters, calls server
6. Server does work, returns result to the stub
7. Server stub packs it in message, calls local OS
8. Server's OS sends message to client's OS
9. Client's OS gives message to client stub
10. Stub unpacks result, returns to client
27
Implementation of Remote Procedure Call
Kernel Kernel
Message transport
over the network 28
Passing Value Parameters
30
Clock synchronization in distributed system
• It is clear that when one event changes the system state, it may
affect its related future events that will happen after this. This
influence among causally-related events satisfying the Happens-
before relation, are known as causal affects.
31
Clock synchronization in distributed system
• If two events are with the following conditions:
32
Lamport’s Logical Clock
33
Lamport’s Logical Clock
• The timestamp value T must always be increasing and never
decreasing. Thus, for the implementation, the clock is incremented
between any two successive events with a positive integer always,
i.e.,
Ti(y) = Ti(x) + d where d >0
• Using all the conditions mentioned above, we can assign
timestamp to all events in the system and thereby provide a total
ordering of all the events in the system.
34
Mutual Exclusion
To provide mutual exclusion among processes in distributed system
the following algorithms are used:
Centralized algorithm: In this algorithm, a process on one
node of the distributed system is assigned as coordinator to
manage the mutual exclusion problem.
Ricart-Agarwala algorithm: It is a fully distributed algorithm.
According to this algorithm, a process wishing to enter its
critical section sends a time-stamped request messages to all
other processes and waits.
Token-ring algorithm: This algorithm assumes a logical
structure of all the processes in a ring, i.e. all the processes are
connected together in a ring sequence and every process
knows who the next process in that sequence is.
35
Centralized algorithm
36
Ricart- Agarawala Algorithm
Ricart-Agarwala Algorithm for Mutual Exclusion
1.A process Pi wishing to enter its critical section CS sends a message M(Name, Process_ID, TS) to all other processes,
i.e. n-1 in the system; where n is the number of processes in the system.
2.When a process Pj receives the message M from Pi, the following actions may be taken:
If Pj is not inside CS
Send OK message to Pi.
Else
{
If Pj has sent M to other processes
{
If (TSi < TSj) // Compare the time stamps of Pi and Pj.
Send OK message to Pi.
Else
Add the Pi ‘s request to Pending_request_queue.
}
Else
{
If Pj is inside the CS
Add the Pi ‘s request to Pending_request_queue.
}
}
3. The process if receives n-1 OK messages from the processes, it gets the permission to enter its CS and starts
executing inside it.
4. If the process Pj exits its CS
{
If items are there in Pending_request_queue
Send OK message to all the processes inside the
Pending_request_queue
}
37
Token-Ring algorithm for mutual exclusion
38
The Deadlock problem
• Wait-for graph.
• Resource-allocation graph.
Wait-for graph
P2
P1
P3
P5
P4
Resource allocation graph
P1 P2 P1 P2
r1 r2
P3 P3
Resource allocation graph With deadlock
Without deadlock
Wait-for graph and Resource-
allocation graph conversion
• Any resource allocation graph with a single
copy of resources can be transferred to a wait-
for graph.
P1 P1
P3 P2 P3 P2
Strategies for handling deadlocks
46
Deadlock Detection
47
Deadlock Detection
• Distributed Approach
– Detect cycles using probes.
– If process pi blocked on pj , it launches probe pi pj
– pj sends probe pi pj pk along all request edges, etc.
– When probe returns to pi, cycle is detected
48
Deadlock Prevention
• To provide deadlock prevention in distributed system the following
algorithms are used:
– Ordering of resources
– Wait-die algorithm: The older process waits for a younger
process but a younger process is killed if tries to wait for an
older process
– Wound-wait algorithm: The older process preempts the
younger one but if younger one requests, it is allowed to wait.
49
Deadlock Prevention
50
Distributed Process Scheduling
• To perform distributed process scheduling, Load balancing is
performed by transferring some processes from heavily loaded
node to lightly loaded node. This is known as process migration.
• Implementation issues:
– Process Migration Policy (Pre-emptive/non-premptive)
– Transfer Policy (Based on load)
– Selection Policy
– Location Policy
– Information Policy (demand/periodic)
51
Distributed Process Scheduling
• There are two types of schedulers.
Local scheduler
Global load scheduler
52
Reasons of Process Migration
53
Distributed Process Scheduling
Algorithms
• Sender-Initiated Algorithm-overloaded node
– Random scheduling
– Threshold based scheduling
– Shortest queue length scheduling
• Receiver-Initiated Algorithm-underloaded node
• Symmetrically Initiated Algorithm
– Benefits of both
54
Distributed file systems
• In distributed system, to have a distributed file system, some nodes
are dedicated to store the files only. These nodes perform the
storage and retrieval operation on the files. These nodes are known
as file servers. The other nodes used for computational purposes
are known as clients.
55
Distributed file systems
• Single processor
1. Write “c”
Original file
a b On a single processor,
A when a READ follows
a b c a WRITE, the value
returned by the READ
B is the value just written.
2. Read gets “abc”
File Modification Notification
• Distributed system
Client 1
File Server
A a b 1. Read “ab”
a b c a b
2. Write “c”
3. Read gets “ab”
In a distributed system with Client 2
caching, obsolete values may
be returned. If client 1 modifies B
the file in its cache, it must a b
inform client 2.
Semantics of File Sharing
• Unix semantics
– All updates are immediately visible
– Generates a lot of network traffic
• Session semantics
– Updates visible when file closes
– Simultaneous updates are unpredictable (lost)
• Transaction semantics
– Updates visible at end of transaction
• Immutable-files semantics
– Updates create a new version of file
– Now the problem is one of version management
63
File service implementation
Client Server
Client Server
Client’s main memory Client’s disk Server’s main memory Server’s disk
70