M1
M1
SOFT
SEND( MSG,B)
RECEIVE (&BUF, A)
Process Synchronisation
Part-2
3. Language support:
Processes in the urgent queue have a higher priority than processes trying
to enter the monitor , when a process relinquishes control of the monitor.
• Disadvantages
• Only one active process inside a monitor: no concurrency.
• Responsibility of programmers to ensure proper synchronization.
• Nested monitor calls can lead to deadlocks:
• Responsibility of valid programs shifts to programmers, difficult to validate
correctness.
Serializers
• When the process completes execution of the body, a leave-crowd operation is executed.
• As a result of the leave-crowd operation the process regains control of the serializer.
• Please note that, if the serializer is currently in possession of some other process then
the process executing the leave crowd operation will result in a wait queue.
Structure of a procedure
Serializers- Queue variables
• whenever a process requests to gain or regain access of a serializer certain
conditions are checked.
• The process is held in a waiting queue until the condition is true. This is
accomplished using an enque operation.
• The syntax of the enque command is
enque (<priority>, <queue-name>) until (<condition>)
• The queue name specifies the name of the queue in which the process has to be
held and the priority options specifies the priority of the process to be delayed.
OPERATION OF SERIALIZER
As shown in the above figure, every operation in a serializer
can be identified as an event.
Ø An Entry event can be a request for serializer, in which a
condition will be checked. ( For eg., Is the serializer free for
the process to enter ? )
Ø If the condition is true the process gains control of the
serializer.
Properties:
Examples:
Amoeba and Cambridge distributed computing systems
Advantages of distributed system
• Main advantage :Price/Performance ratio is high.
• Other advantages:
• 1.Resource sharing: Computers can send a request for other resources (s/w or
h/w) available in the system.
• 2. Enhanced performance: shorter response time and higher system throughput.
• 3.Improved reliability and availability: System is fault tolerant . Failure of single
system does not affect the whole
3. Protocol level
All the system components to support a common set of protocols.
Advantage: Individual computers can run different operating systems while not
sacrificing interoperability.
5. Process Synchronisation
• Synchronisation of processes is difficult because there is no shared
memory.
• But it is essential when different systems trying to access a shared
resource.(eg:- fileserver)
• For ensuring correctness, it is necessary that the shared resource be
accessed by a single process at a time.
• This problem is known as mutual exclusion problem.
6. Resource Management
• Resource management is concerned with making both local and
remote resources available to users.
• Users should be able to access remote resources as easily as they can
access local resources.
• In other words ,Specific location of resources should be hidden from
users.
It can done using different ways.
Resource Management cntd..
1.Data migration
• Data is brought to the location where it is needed
• Data may be a file or contents of a physical memory.
• If any changes made ,the orginal location have to be updated.
2. Computation migration
• Computation migrates to another location.
• Mechanism used is RPC (Remote Procedure call)
3. Distributed Scheduling
• Processes are transferred from one location to another by the Distributed OS.
• It is desirable when a computer where process originated is overloaded or it does not
have necessary resources required for a process .
7. Security
• Two issues must be considered in the design of security
1.Authentication
• Process of guaranteeing that an entity is what it claims to be.
2.Authorisation
• Process of deciding what privileges an entity has and making only those
privileges available.
8. Structuring
• Structuring defines how various parts of OS are organised.
• Different structures:
• 1.Collective Kernel structure (Microkernel)
• OS services such as distributed memory management, scheduling, name services,
RPC, time management etc are implemented as independent processes.
• Nucleus ,also called microkernel supports the interaction between processes.
• Other functions of kernel are task management, processor management ,etc.
• The microkernel runs on all computers in a distributed system.
• The other processes may or may not run at a computer.
• Examples:
• Mach, Chorus
Structuring contd..
2. Object oriented OS
• In Collective Kernel structure, services are implemented as process whereas
in object oriented OS ,system services are implemented as objects.
• Each object encapsulates a data structure and defines a set of operations on
that data structure.
• Examples: Amoeba, Cloud
9. Client server model
• Processes are categorised as client and servers.
• Process needs service (client) sends request to servers.
• Severs respond with the request and result may be send back to the
client.
• In systems with multiple servers, location and conversations among
the servers are transparent to the clients.
Communication Networks and Primitives
• Reading Assignment:
Communication Networks
Communication models and the primitives
used for communication
There are two communication models that provide communication
primitives.
1. Message passing model
2. Remote Procedure call
1.Message Passing model
• A form of communication between two processes
• A physical copy of message is sent from one process to the other
• 2 primitives
1.Send(msg, destination)
2.Receive( source, buf)
These two can be :
1.Blocking VS Non blocking
2.Synchronous VS Asynchronous
Synchronization
• Message passing may be either blocking or non-blocking
• Blocking is considered synchronous
• Blocking send -- the sender is blocked until the message is
received
• Blocking receive -- the receiver is blocked until a message is
available
• Non-blocking is considered asynchronous
• Non-blocking send -- the sender sends the message and
continue
• Non-blocking receive -- the receiver receives:
• A valid message, or
• Null message
• Different combinations possible
• If both send and receive are blocking, we have a rendezvous
2.RPC
• RPC –Remote Procedure Call
Basic RPC Operation
Problem:
To determine that an event a happened before an event b, either a common clock
or a set of perfectly synchronized clocks is needed.
Lamport [1978] provided a solution for this problem by introducing the concept of
logical clocks.
The logical clocks concept is a way to associate a timestamp (which may be simply
a number independent of any clock time) with each system event so that events
that are related to each other by the happened-before relation (directly or
indirectly) can be properly ordered in that sequence.
Solution: attach a timestamp C(e) to each event e, satisfying the
following properties:
P1: If a and b are two events in the same process, and a b, then we
demand that C (a) < C (b)
P2: If a corresponds to sending a message m, and b to the receipt of that
message, then also C (a) < C (b)
Implementation of Logical Clocks using counters
Fig 5-7. (a) Three processes, each with its own clock. The clocks
run at different rates. (b) Lamport’s algorithm corrects the clocks
a e
j
b f k
c
g
d h l
i
Problem: it can still occur that two events happen at the same time. Avoid
this by attaching a process number to an event:
Pi timestamps event e with Ci (e) i
Then: Ci (a) i happened before Cj (b) j if and only if:
1: Ci (a) < Cj (a) ; or
2: Ci (a) = Cj (b) and i < j
Limitations of Lamport’s logical clock
Causal Ordering of Messages
• Basic idea: Buffer each message until the message that immediately
precedes it is delivered.
• It make use of vector clocks
• In this example, sender SI sends message m1 to receivers R1, R2 , and R3
and sender S2 sends message m2 to receivers R2 , and R3 .
• On receiving m1 , receiver R1 inspects it, creates a new message
m3, and sends m3; to R2 and R3 .
• Note that the event of sending m3 is causally related to the event of
sending m1, because the contents of m3 might have been derived in part
from ml; hence the two messages must be delivered to both R2 and R3 in
the proper order, m1 before m3.
• Also note that since m2 is not causally related to either m1 or m3 , m2 can
be delivered at any time to R2 and R3 irrespective of m, or m3.
(3,2,5,1) means that, until now, A has sent three
Example messages, B has sent two messages, C
has sent five messages, and D has sent one message to
other processes
Birman-Shiper-Stephenson Causal Message
Ordering
• Before Pi broadcasts m, it increments VTPi[i] and timestamps m. Thus
VTPi[i]-1 is the number of messages from Pi preceding m.
• When Pj (j � i) receives message m with timestamp VTm from Pi,
delivery is delayed locally until both of the following are satisfied:
• VTPj[i] = VTm[i] - 1
• VTPj[k] � VTm[k] for all k � i
Delayed messages are queued at each process, sorted by their vector
timestamps, with concurrent messages ordered by time of receipt.
• When m is delivered to Pj, VTPj is updated as usual for vector clocks.