320 likes | 437 Views
Distributed Programs. Clients and servers. Distributed computations. Concurrent programs Processes communicate by message passing Execution typically on network architectures Networks of workstations Distributed memory parallel machines. Paradigms for process interactions. Several models
E N D
Distributed Programs Clients and servers
Distributed computations • Concurrent programs • Processes communicate by message passing • Execution typically on network architectures • Networks of workstations • Distributed memory parallel machines
Paradigms for process interactions • Several models • Networks of filters, clients, servers • Heartbeat algorithms • Probe/echo algorithms • Broadcast algorithms • Token-pasing algorithms • Decentralised servers • Bags of tasks
Concurrent programming • Construct a program containing multiple processes that cooperate in performing some task • Design task given a problem: • How many processes? • How should they interact? • Application and hardware dependent • Critical problem: communication between processes
Historical perspective • Operating systems first • Independent device controller tasks • User tasks • Single processor systems used multiprogramming • Processes executed in interleaving manner • Multiprocessor systems • Shared memory multiprocessor • Multicomputers • Networks
Historical perspective con’t • Examples of concurrent programs • Operating systems • Window systems on PC:s or workstations • Transaction processing in databases • File servers in networks • Scientific computations with much data • Often called parallel program
Distributed programs • Processes communicate by message passing • Execute typically on distributed architectures • Typically (but not exclusively) no shared memory
Distributed programs • Four basic kind of processes • Filters • Clients • Servers • Peers
Filter • Data transformer • Receives streams of data from its input channels • Performs some computation on those values • Sends streams of results to its output channels • Many UNIX user-level commands are filters
Client and server • Client is a triggering process, server is a reactive process • Clients make requests that trigger reactions from servers • Client initiates activity • At times of its choosing • Often delays until request has been servised • Server waits for requests • Reacts to them • Usually a nonterminating process • Provides service to several clients
Client and server con’t • File server in a distributed system • Manages a collection of files • Services requests from any client
Peer • A peer is one of a collection of identical processes • Interact to provide service or • Compute a result • E.g two peers each manage a copy of a file and interact to keep the copies consistent • E.g. several peers might interact to solve a parallel programming problem, each solving a piece of the problem
Process-interaction paradigms • One-way data flow through networks of filters • Requests and replies between cleints and servers • Back-and-forth (heartbeat) interaction between neighboring processes • Probes and echoes in graphs • Broadcasts between processes in complete graphs • Token passing along edges in graphs • Coordination between decentralised server processes • Replicated workers sharing a bag of tasks
On notation • Channels • Abstraction of a physical communication network • Accessed by two primities: send and receive • Global vs associated with processes • One-way vs two-way information flow • Asynchronous (nonblocking) vs synchronous (blocking) communication
On notation con’t • Asynchronous message passing • Channels conceptually unbounded capacity => nonblocking • Synchronous message passing • Communication and synchronisation tightly coupled => sending process delays until receiver ready to receive • Message exchange is a sunchronisation point, no need to store messages in channels • Buffered message passing with fixed capacity
On notation con’t • Generative communication • Processes share a single communication channel called tuple space • Associative naming used to distinguish different kind of messages vs different channels in asynchronous message passing
On notation con’t • Remote procedure calls (RPC) and rendezvous • Combination of monitors and synchronous message passing • Process exports operations invoked by a call statement (monitors) • Execution of a call is synchronous • Calling process delays untill invokation and result • Hence, a two-way communication channel
Filters: a sorting network • Sort a list on n numbers into ascending order • Straightforward: one filter Chaninput(int), output(int) Sort:: decllaration of local variables Receive all numbers from input Sort the numbers Send the sorted numbers to output SORT: for all i: 1 ≤ i < n: sent[I] ≤ sent[I+1] and values sent to output are a permutation of values received from input
Filters: a sorting network con’t • A practical consideration: • Receive is blocking so how do we know when all numbers have been receved! • Sort knows n in advance? • The first input is n? • End input stream with a sentinel ! • Often most efficient approach to sorting • Network of processes!
Filters: a sorting network con’t • A merge network • Merge repeatedly and in parallel two sorted lists into a larger sorted list • Merge filters • Receive values from two ordered input streams in1, in2 • Merge the values • Produce one output stream out • Use sentinel EOS to mark end of stream
Filters: a sorting network con’t • MERGE: in1 and in2 are empty and sent[n+1] = EOS and for all i: 1≤ i < n: sent[I] ≤ sent[I+1] and values sent to out are a permutation of values received from in1 and in2
Filters: a sorting network con’t • How to implement Merge? • Receive all input, merge them and send the merged list to output • Repeatedly compare th next two values from in1 and in2 and send the smaller to out • When all values from one input are concumed append further values from the other input to out
Filters: a sorting network con’t • Sorting network • A collection of Merge processes and arrays of input and output channels connected together • Input and output channels need to be shared • Static vs dynamic naming • Filters can be connected in different ways • Output needs to meet the input assumptions • Sort can be replaced by Merge plus a process distributing the input values • Sort can be replaced by any sorting strategy
Clients and servers • A server is a process that repeatedly handles requests from clients • Two examples: • How to turn monitors into servers • How to implement disk scheduler and a disk server?
Centralised servers: Active monitors • A centralised server is a resource manager: • Local variables record the state of the resource • It services requests to access that resource • Similar to a monitor • Server is active, monitor is passive
Monitor-based Permanent variables Procedure identifiers Procedure call Monitor entry Procedure return Wait statement Signal statement Procedure bodies Message-based Local server vars Request channel and operation kinds Send request Receive reply Receive request Send reply Save pending request Retrieve and process pending request Arms of case statement on operation kind Centralised servers: Active monitors
Heartbeat algorithms • Consider the problem of computing the topology of a network consisting of processors connected by bidirectional communication channels. • Each processor can communicate only with its neighbors and know only about links to the neighbors. • Each processor should determine the topology of the entire network
Heartbeat algorithms con’t • Each processor modelled as a process • Communication links modelled as shared channles • Two solutions • Shared memory solution • Distributed computation
Probe/echo algorithms • How to be sure that a message reaches all nodes in a network? • Broadcast in a network • Using trees • Topology of a network • Cyclic/acyclic graphs
Broadcast algorithms • In LAN:s processors share a common communication channel (Ethernet, token ring) • Each processor can directly communicate with every other processor • How to implement broadcast? • Logical clocks and event ordering • Distributed semaphores
Token-passing algorithms • Token is a special message used to convey permission to some action • Two synchronisation problems: • Distributed mutual exclusion • Termination detection in a ring/graph
Replicated servers • Multiple server processes that each do the same • Replication of servers? • Increase accessability to data or services • Multiple worker processes