Professional Documents
Culture Documents
Pablo de la Fuente Departamento de Informtica E.T.S. de Ingeniera Informtica Campus Miguel Delibes 47011 Valladolid Spain pfuente@infor.uva.es
Organization
General concepts. Types of distributed systems. Comunication models. Concurrency and distributed systems Examples
Organization
General concepts. Types of distributed systems. Comunication models. Concurrency and distributed systems Examples
Common Characteristics
What are we trying to achieve when we construct a distributed system? Certain common characteristics can be used to assess distributed systems Resource Sharing Openness Concurrency Scalability Fault Tolerance Transparency
Security
Resource Allocation
Resources
Process synchronization
Comunication security
A. Goscinski, 1992
Transparency
Distributed systems should be perceived by users and application programmers as a whole rather than as a collection of cooperating components. Transparency has different dimensions that were identified by ANSA. These represent various properties that distributed systems should have.
Scalability Transparency
Performance Transparency
Failure Transparency
Migration Transparency
Replication Transparency
Concurrency Transparency
Access Transparency
Location Transparency
Transparencies
Access transparency: enables local and remote resources to be accessed using identical operations. Location transparency: enables resources to be accessed without knowledge of their location. Concurrency transparency: enables several processes to operate concurrently using shared resources without interference between them. Replication transparency: enables multiple instances of resources to be used to increase reliability and performance without knowledge of the replicas by users or application programmers. Failure transparency: enables the concealment of faults, allowing users and application programs to complete their tasks despite the failure of hardware or software components. Mobility transparency: allows the movement of resources and clients within a system without affecting the operation of users or programs. Performance transparency: allows the system to be reconfigured to improve performance as loads vary. Scaling transparency: allows the system and applications to expand in scale without change to the system structure or the application algorithms.
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Applications, services
Middleware
Component1
...
Componentn
Component1
...
Componentn
Component1
Middleware . . . Componentn
Component1
Middleware . . . Componentn
Computer hardware
Host1
Computer hardware
Network
Hostn
W. Emmerich, 2000
Organization
General concepts. Types of distributed systems. Comunication models. Concurrency and distributed systems Examples
Client
invocation result
invocation result
Server
Server
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Service
Server Client
Server
Client Server
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Web server
Client
Web server
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Web applets
Web server
Client
Applet
Web server
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Compute server
Application Process
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Alarm service
Discovery service
TV/PC
Laptop
PDA
Guests devices
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
process p
process q
send
receive
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Affects Process
Description
Process halts and remains halted. Other processes may detect this state. Crash Process Process halts and remains halted. Other processes may not be able to detect this state. Omission Channel A message inserted in an outgoing message buffer never arrives at the other ends incoming message buffer. Send-omission Process A process completes a send,but the message is not put in its outgoing message buffer. Receive-omission Process A message is put in a processs incoming message buffer, but that process does not receive it. Arbitrary Process or Process/channel exhibits arbitrary behaviour: it may (Byzantine) channel send/transmit arbitrary messages at arbitrary times, commit omissions; a process may stop or take an incorrect step.
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Timing failures
Description Processs local clock exceeds the bounds on its rate of drift from real time. Process exceeds the bounds on the interval between two steps. A messages transmission takes longer than the stated bound.
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
Organization
General concepts. Types of distributed systems. Comunication models. Concurrency and distributed systems Examples
The correct behaviour of a concurrent program depends on synchronisation and communication between its processes. Synchronisation: the satisfaction of constraints on the interleaving of the actions of processes (e.g. an action by one process only occurring after an action by another). Communication: the passing of information from one process to another. Concepts are linked since communication requires synchronisation, and synchronisation can be considered as contentless communication. Data communication is usually based upon either shared variables or message passing.
Process P1
Process P2
time
time
Alan Burns and Andy Wellings, 2001
Process Synchronisation
Variations in the process synchronisation model arise from the semantics of the send operation Asynchronous (or no-wait) (e.g. POSIX) Requires buffer space. What happens when the buffer is full?
Process P2
receive message
time
time
Alan Burns and Andy Wellings, 2001
Process Synchronisation
Synchronous (e.g. CSP, occam2) No buffer space required Known as a rendezvous
Process P2
receive message
time
time
Alan Burns and Andy Wellings, 2001
Process Synchronisation
Remote invocation (e.g. Ada) Known as an extended rendezvous Analogy: The posting of a letter is an asynchronous send A telephone is a better analogy for synchronous communication
Process P2
time
time
Asynchronous communication can implement synchronous communication: P1 P2 asyn_send (M) wait (M) wait (ack) asyn_send (ack) Two synchronous communications can be used to construct a remote invocation: P1 P2 syn_send (message) wait (message) wait (reply) ... construct reply ... syn_send (reply)
Process Naming
Two distinct sub-issues direction versus indirection symmetry With direct naming, the sender explicitly names the receiver: send <message> to <process-name> With indirect naming, the sender names an intermediate entity (e.g. a channel, mailbox, link or pipe): send <message> to <mailbox> With a mailbox, message passing can still be synchronous Direct naming has the advantage of simplicity, whilst indirect naming aids the decomposition of the software; a mailbox can be seen as an interface between parts of the program
Process Naming
A naming scheme is symmetric if both sender and receiver name each other (directly or indirectly) send <message> to <process-name> wait <message> from <process-name> send <message> to <mailbox> wait <message> from <mailbox> It is asymmetric if the receiver names no specific source but accepts messages from any process (or mailbox) wait <message> Asymmetric naming fits the client-server paradigm With indirect the intermediary could have: a many-to-one structure a many-to-many structure a one-to-one structure a one-to-many
Message Structure
A language usually allows any data object of any defined type (predefined or user) to be transmitted in a message Need to convert to a standard format for transmission across a network in a heterogeneous environment OS allow only arrays of bytes to be sent
The Ada Model Ada supports a form of message-passing between tasks Based on a client/server model of interaction The server declares a set of services that it is prepared to offer other tasks (its clients) It does this by declaring one or more public entries in its task specification Each entry identifies the name of the service, the parameters that are required with the request, and the results that will be returned
Message Characteristics
Principal Operations send receive Synchronization Synchronous Asynchronous Rendevous Multiplicity one-one many-one many-many Selective Anonymity anonymous message passing non-anonymous message passing Receipt of Messages Unconditional Selective
Selective waiting
So far, the receiver of a message must wait until the specified process, or mailbox, delivers the communication A receiver process may actually wish to wait for any one of a number of processes to call it Server processes receive request messages from a number of clients; the order in which the clients call being unknown to the servers To facilitate this common program structure, receiver processes are allowed to wait selectively for a number of possible messages Based on Dijkstras guarded commands x < y p m := x
Non-determinism and Selective Waiting Concurrent languages make few assumptions about the execution order of processes A scheduler is assumed to schedule processes non-deterministically Consider a process P that will execute a selective wait construct upon which processes S and T could call
Non-determinism and Selective Waiting P runs first; it is blocked on the select. S (or T) then runs and rendezvous with P S (or T) runs, blocks on the call to P; P runs and executes the select; a rendezvous takes place with S (or T) S (or T) runs first and blocks on the call to P; T (or S) now runs and is also blocked on P. Finally P runs and executes the select on which T and S are waiting The three possible interleavings lead to P having none, one or two calls outstanding on the selective wait If P, S and T can execute in any order then, in latter case, P should be able to choose to rendezvous with S or T it will not affect the programs correctness
Non-determinism and Selective Waiting A similar argument applies to any queue that a synchronisation primitive defines Non-deterministic scheduling implies all queues should release processes in a non-deterministic order Semaphore queues are often defined in this way; entry queues and monitor queues are specified to be FIFO The rationale here is that FIFO queues prohibit starvation but if the scheduler is non-deterministic then starvation can occur anyway!
POSIX Message Queues POSIX supports asynchronous, indirect message passing through the notion of message queues A message queue can have many readers and many writers Priority may be associated with the queue Intended for communication between processes (not threads) Message queues have attributes which indicate their maximum size, the size of each message, the number of messages currently queued etc. An attribute object is used to set the queue attributes when the queue is created
POSIX Message Queues Message queues are given a name when they are created To gain access to the queue, requires an mq_open name mq_open is used to both create and open an already existing queue (also mq_close and mq_unlink) Sending and receiving messages is done via mq_send and mq_receive Data is read/written from/to a character buffer. If the buffer is full or empty, the sending/receiving process is blocked unless the attribute O_NONBLOCK has been set for the queue (in which case an error return is given) If senders and receivers are waiting when a message queue becomes unblocked, it is not specified which one is woken up unless the priority scheduling option is specified
POSIX Message Queues A process can also indicate that a signal should be sent to it when an empty queue receives a message and there are no waiting receivers In this way, a process can continue executing whilst waiting for messages to arrive or one or more message queues It is also possible for a process to wait for a signal to arrive; this allows the equivalent of selective waiting to be implemented If the process is multi-threaded, each thread is considered to be a potential sender/receiver in its own right
Concurrency. Summary semaphore a non-negative integer that can only be acted upon by WAIT and SIGNAL atomic procedures Two more structured primitives are: condition critical regions and monitors Suspension in a monitor is achieved using condition variable POSIX mutexes and condition variables give monitors with a procedural interface Adas protected objects give structured mutual exclusion and highlevel synchronization via barriers Javas synchronized methods provide monitors within an objectoriented framework
receive 4
receive
receive
Physical time
Instructors Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 Addison-Wesley Publishers 2000
The happened-before relation The happened-before relation (denoted by p) is defined as follows: Rule 1 : If a and b are events in the same process and a was executed before b, then a p b. Rule 2 : If a is the event of sending a message by one process and b is the event of receiving that message by another process, then a p b. Rule 3 : If a p b and b p c, then a p c.
Relationship between two events. Two events a and b are causally related if a p b or b p a. Two distinct events a and b are said to be concurrent if a p b and b p a (denoted as a b).
A time-space representation
Organization
General concepts. Types of distributed systems. Comunication models. Concurrency and distributed systems Examples
Theoretical foundations State model: A process executes three types of events: internal actions, send actions, and receive actions. A global state: a collection of local states and the state of all the communication channels.
Process
receive send
Process
Process
Process
A formal study of concurrency enables: understanding the essential nature of concurrency reasoning about the behavior of concurrent systems developing tools to aid in producing correct systems The pi-calculus of Robin Milner and its former CCS: an algebra (operators, expressions, reaction rules) an interpretation for concurrent/communicating/mobile processes
A process is an autonomous entity possessing named ports through which it may communicate with other processes. The name of the process and its ports are introduced as: ProcessName(port-list) = behavior of the process In the description of the process behavior, port names with overbars are interpreted as output ports while names without overbars are often interpreted as input ports. The process below models a simple client that has one output port, request and one input port, reply.
Agent C Dynamic system is network of agents. Each agent has own identity persisting over time. Agent performs actions (external communications or internal actions). Behavior of a system is its (observable) capability of communication. Agent has labeled ports. Input port in. Output port out. Behavior of C: C := in(x).C'(x) C'(x) := out(x).C The behaviour can also be represented by: C:= in(x).out(x).C
C := in(x).out(x).C A := in(x).in(y).out(x).out(y).A How do behaviours differ? A inputs two values and outputs two values. C inputs and output a single value.
Agent expression C^C. Combinator A1^A2 (defined later). Agent formed by linking out of A2 to in of A1. ^ is associative.
To define un agent D whose interface looks as the figure: D = in(x).out(x).ackout.ackin.D Note that there no value parameters in the actions ackout, ackin. These action represent pure sinchronization between agents. We can also define a linking combinator ; it links the two right-hand ports of the first agent to the two left-hand ports of the second.Thus the combination of n copies of D:
in D ackin
def def
out D D D ackout
(n times)
Sem = wait.signal.Sem
wait
Sem.
signal
def
Process = wait.Process Process = signal.Process The total behaviour will be: (Process | Sem)\{wait, signal}
def
A vending machine: Big chocolade costs 2p, small one costs 1p. V := 2p.big.collect.V + 1p.little.collect.V
in
twice.
out
b B
c A A' allows A|B A'|B A B A' ->c A allows A'|B ->c A|B A' ->c A and B ->c B' allows A'|B ->tau A|B' Completed (perfect) action tau. Simultaneous action of both agents. Internal to composed agent. Act = L U {tau} Internal versus external actions Internal actions are ignored. Only external actions are visible. Two systems are equivalent if they exhibit same pattern of external actions. P ->tau P1 ->tau ...->tau Pn equivalent to P ->tau Pn ->a ->a
(A|B)\c = a.tau.C C := a.b.tau.C + b.a.tau.C Composite system Behavior defined without use of composition combinator | or restriction combinator\ Internal communication alpha.tau.P = alpha.P (A|B)\c = a.D D := a.b.D + b.a.D
Bibliography
George Coulouris, Jean Dollimore and Tim Kindberg. Distributed Systems: Concepts and Design (Edition 3 ). Addison-Wesley 2001 http://www.cdk3.net/ Andrew S. Tanenbaum, Maarten van Steen. Distributed Systems: Principles and Paradigms. Prentice-Hall 2002. http://www.cs.vu.nl/~ast/books/ds1/ P. K. Sinha, P.K. "Distributed Operating Systems, Concepts and Design", IEEE Press, 1993 Sape J. Mullender, editor. Distributed Systems, 2nd edition, ACM Press, 1993 http://wwwhome.cs.utwente.nl/~sape/gos0102.html J. Wu, Distributed System Design, CRC Press 1999 Gregory R. Andrews. Foundations of Multithreaded, Parallel, and Distributed Programming, Addison Wesley, 2000 http://www.cs.arizona.edu/people/greg/ J. Magee & J. Kramer. Concurrency. State Models and Java Programs. John Wiley, 1999 http://www-dse.doc.ic.ac.uk/concurrency/ Jean Bacon. Concurrent Systems.Operating systems, database and distributed systems an integrated approach. Addison Wesley, 2nd edition 1998 http://www.cl.cam.ac.uk/users/jmb/cs.html