Unit No: 1 Distributed Programming Pavan R Jaiswal

    

Introduction Simple lock Bounded buffer Message-passing services Distributed lock service ◦ Using time stamp



Object transfer service ◦ Using path reversal



Distributed shared memory service ◦ Single copy, multi copy Distributed Programming

2



Distributed computing ◦ Field of computer science that studies distributed systems ◦ Use of distributed systems to solve computational problems



Distributed systems ◦ A software system ◦ Components located on networked computers ◦ Communication by passing messages

Distributed Programming

3

◦ Components interacts with each other in order to

achieve a common goal ◦ Message passing alternatives: RPC, message queue 

Distributed programming ◦ Computer program is a distributed program that runs on distributed system ◦ Distributed programming is a process of writing distributed programs

Distributed Programming

4

Fig 1 Distributed system Distributed Programming

5

Fig 2 Parallel system

Distributed Programming

6

Fig 3. Parallel, concurrent, distributed Distributed Programming

7

Fig 4. A Distributed system implementing a message-passing service from location a1 to a2 Distributed Programming

8

Fig 5. Message-passing service Option 1

Distributed Programming

9

Fig 6. Message-passing service Option 2

Distributed Programming

10



The simple lock program is shown in Fig. 6



The program, called SimpleLock, has one parameter, N, indicating the number of possible users



their tids would be 0, . . ., N−1. The program input assumption requires N to be at least 1. Distributed Programming

11



The main code first defines some variables. Boolean

array xreq has its ith entry true if user i has a request pending. Boolean xacq is true if a user has the lock. 

Integer xp is an index into xreq. The main code then

starts a thread to execute function serve and stores its tid in variable t. 

The main code ends by returning its sid. (Tid t may coincidentally be in 0..N−1, but it doesn’t matter.)

Distributed Programming

12

Fig 7. Simple lock program Distributed Programming

13



In function serve, thread t repeatedly cycles through xreq. When it finds that the user corresponding to xp is waiting,



it sets xacq to true, sets xreq[xp] to false (freeing thread xp to return from its acq call),



and busy waits until xacq becomes false (which happens when the thread releases the lock).



There are three input functions: acq and rel to acquire and release the lock; and end to initiate termination of the lock

system.

Distributed Programming

14



In acq and rel, the input assumption requires the calling

thread’s tid, mytid, to be in 0..N−1 

When thread i calls acq, it sets xreq[i] to true, busy waits until xreq[i] becomes false (due to thread t

executing a2 with xp equal to i) and returns. 

When thread i calls rel, it sets xacq to false (which frees thread t from waiting on a3) and returns.



Function end can be called by any thread (its tid need not be in 0..N−1). It executes endSystem

Distributed Programming

15



So far we have seen one role of the lock service

program, that is, as the standard that any lock implementation must satisfy. 

We now illustrate the other role of the lock service, that

is, to serve as a lock in the design of a larger program that makes use of locks. 

Figure 8 shows a program ProdCons1 in which a producer and consumer make use of the lock service

Distributed Programming

16

Fig 8. Producer-consumer program Distributed Programming

17

   

Bounded buffer means a buffer with bounded size. Figures 9 and 10 defines a bounded-buffer service. It has a parameter N denoting the size of the buffer. It has three input functions:

◦ put(x), to append item x to the buffer; ◦ get(), to remove an item from the buffer and return it; and ◦ end(), to stop further calls of put and end.

Distributed Programming

18



Variable buff is the buffer; ◦ it is a sequence that is empty initially. ◦ Variable ending is true if end has been called. ◦ Variable putBusy (getBusy) is true iff a put (get) call is ongoing.



Function put(x) can be called whenever end has not been called and no put call is ongoing. Distributed Programming

19

Fig 9. Bounded buffer program Distributed Programming

20

Fig 10 Bounded buffer program Distributed Programming

21

Fig 11. A channel with addresses 1, .., n and access system v[1] at address 1 Distributed Programming

22



Channel is a service used for message passing.



Bounded

buffer

&

lock

are

also

services

for

communication. 

A channel allows a user at one location to transmit a

message to be received by a user at another location. 

Because a channel is a service that is spread over different locations, users access the service via multiple

systems, one at each location (unlike the previous lock service and bounded-buffer service).

Distributed Programming

23



Fig 11 illustrates a channel where each access system

provides functions tx(k,msg), to transmit message msg to address k, and rx(), to receive a message. 

Messages are sequences. We require channels to have

at least one address. 

Although a channel with one address doesn’t do anything, it can be convenient for writing programs

that use the channel.

Distributed Programming

24



In the context of computer networking, a channel can be

“connection-less” or “connection-oriented”. 

With a connection-less channel, a user can send and receive messages without any prior intimation to the service.



Connectionless channels typically do not guarantee any level of service.



With a connection-oriented channel, a user can send and

receive messages to a remote user only after a “connection”

Distributed Programming

25







Distributed lock service, that is, a lock whose users may be spread over different locations (e.g., users at different computers of a network). At each location there is an access system through which users access the lock. (Incontrast, SimpleLockService, is centralized because all users access the service at one system.) The service has one parameter, ◦ the set of addresses of the locations at which the lock can be accessed. ◦ At each address j, the program has an access system  with two input functions: acq(), to request the lock; and  rel(), to release the lock. Figure 12 illustrates the service diagrammatically on next slide.

Distributed Programming

26

Fig 12. Distributed lock service over addresses 1,2,3 and 4 with access system v[j] at address j Distributed Programming

27



The service program is given in Fig. 13 next.



Parameter ADDR is the set of addresses of the locations at which the lock can be accessed.



The main code defines the following.



Variable eating is null if no one has the lock;



otherwise it stores the tid of the user currently holding the lock.



Variable users is a map indexed by addresses such that users[j], for address j, is the set of tids of users currently accessing Distributed Programming

28

Distributed Programming

29

Fig 14. Distributed lock using timestamps and FIFO channel with addresses 1, .., n Distributed Programming

30



In a distributed computation the component systems of the computation share a set of objects, each characterized by an id and a mutable value, ◦ for example,-- a set of intermediate results



A system can acquire an object, make changes to its value, and

release the object. 

Over time the object passes from system to system, changing its value. When a system acquires an object, its value should be what it was at its last release.



Other than this last requirement, an object is just like a token.

Distributed Programming

31



In object-transfer service,

the service spans a set of

addresses, with an access system at each address, as illustrated in Fig. 15 (given in next slide) 

Each access system has three input :

◦ functions: acq(oid), to acquire object oid and get its value; ◦ rel(oid,oval), to release object oid with value oval; and ◦ rxReq(), to receive a request for an object.

Distributed Programming

32

Fig 15. Object transfer service spanning addresses 1,2,3,4 with access system v[j] at address j Distributed Programming

33



With respect to acquires and releases, an object is like a lock with an associated value.



But unlike a lock, a user releases an object only upon receiving a request for it (whereas a user releases a lock when it no longer needs the lock).



We refer to the user holding an object as the current owner of the object.



Because an object is just like a token with a value, the service

can be implemented over a fifo channel using any distributed token-passing algorithm

Distributed Programming

34



A distributed program that implements the object-transfer service over the addresses of a fifo channel.



The component systems of the program employ a distributed “path-reversal” algorithm to track the current location of an object.



Each system maintains for each object a last pointer that is either nil or points to another system.



To a first approximation, the path of last pointers leading out

of any system ends at the system holding the object, i.e., the last pointers form an in-tree.

Distributed Programming

35



To acquire the object, a system j sends a request that

gets forwarded along the last pointer path leading out of j until it reaches the system with the object, say system k. At each hop, the system receiving j’s request

sets its last pointer to j. 

The evolutions of the distributed program are quite simple if at most one request is in transit at any time.



Then the sequence of last pointer redirections results in a path reversal in the in-tree of last pointers.

Distributed Programming

36



A distributed program, called

pathReversalDist,

that achieves object transfer for one object of a fixed value. 

The program is given in Fig. 16.



It has two parameters: ADDR, the addresses of the service; and a0, the initial address of the object.



It starts a fifo channel with addresses ADDR, and then starts a component

Distributed Programming

37

Fig 16 Distributed program of path reversal

Distributed Programming

38



The distributed shared memory (DSM) implements the

shared memory model in distributed systems, which have no physical shared memory 

The shared memory model provides a virtual address

space shared between all nodes 

The overcome the high cost of communication in distributed systems, DSM systems move data to the location of access

Distributed Programming

39



Data moves between main memory and secondary memory (within a node) and between main memories of different nodes



Each data object is owned by a node



Initial owner is the node that created object



Ownership can change as object moves from node to node



When a process accesses data in the shared address space, the mapping manager maps shared memory address to physical memory (local or remote)

Distributed Programming

40

Fig 17 DSM Distributed Programming

41



Data sharing is implicit, hiding data movement (as

opposed to ‘Send’/‘Receive’ in message passing model) 

Passing data structures containing pointers is easier (in message passing model data moves between different address spaces)



Moving entire object to user takes advantage of locality

difference

Distributed Programming

42



Less

expensive

multiprocessor

to

build

system:

than

tightly

off-the-shelf

coupled

hardware,

no

expensive interface to shared physical memory 

Very large total physical memory for all nodes: Large programs can run more efficiently



Programs written for shared memory multiprocessors can be run on DSM systems with minimum changes

Distributed Programming

43

Fig 18. Distributed shared memory implementation Distributed Programming

44

1.

What is concurrency? What are the basic

approaches to achieve concurrency? 2.

What are service programs?

3.

What are correctness properties in a distributed program?

4.

Explain the producer-consumer lock program

5.

Explain the Lock Service Program

Distributed Programming

45

6.

Explain use of simple lock in a producer

consumer problem. 7.

Discuss about Bounded-Buffer Service.

8.

How condition variables are used in locks?

9.

Write

a

simple

program

using

locks and

condition variables 10.

How semaphores are useful in bounded buffer?

Distributed Programming

46

11.

Explain connection-less and connection –oriented

channels in detail. 12.

What are

the different conventions used in

message passing services? 13.

What

are

different

types

of

connection-less

channels? 14.

Explain connection-less FIFO channels

15.

Explain connection-less LOSSY channels

Distributed Programming

47

16.

Explain connection-less LRD channels

17.

Explain Lamport’s timestamp mechanism

18.

How to use timestamp in the distributed

request scheduling problem?

Distributed Programming

48

[1]http://en.wikipedia.org/wiki/Distributed_computi

ng [2] Shankar A. Udaya, “Distributed Programming, Theory and Practice”

Distributed Programming

49

Thank You Distributed Programming

50

Unit 1 - Distributed Programming.pdf

... system. ◦ Distributed programming is a process of writing. distributed programs. Distributed Programming 4. Page 4 of 50. Unit 1 - Distributed Programming.pdf.

2MB Sizes 5 Downloads 47 Views

Recommend Documents

UNIT-1 - PDFKUL.COM
If P is a permutation matrix of order 5 x 5, why is P6 = I? Also find a non-zero vector x so that (I – P)x = 0. 30. Solve using Gauss-Jordan method: 1 a b. 1. 0. 0. 0. 1.

UNIT-1 -
From the cubics P3 to the fourth degree polynomials P4. What matrix ... There are 2 bases : v1, v2 ,…..vn and w1, w2,….wn for Rn. If a vector x Є Rn is such that.

Curriculum Unit 1 - Pearson
Curriculum Unit 4. What Would You Rather Be? (Data Analysis) attribute compare data describe equation representation sorting survey tally mark. Curriculum Unit 5. Fish Lengths and Animal Jumps. (Measurement) distance height in-between inch length lon

Unit 1 Chapter 1.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Unit 1 Chapter ...

unit 1 understanding groups - eGyanKosh
collective security. Third, the group became both a creator and a transmitter of culture, language and technical know-how beliefs and art forms, games and.

unit 1.pdf
need for DBMS exploding. DBMS encompasses most of CS. OS, languages, theory, AI, multimedia, logic. Files vs. DBMS. Application must stage large ...

Unit 1 Ecommerce.pdf
E-commerce is based on the electronic processing and transmission of data. It is encompasses. many devices activities including electronic trading of goods and ...

Unit 1 Vocabulary
2. Aristocracy- any class or group considered to be superior, as through education, ability, wealth, or social prestige. 3. Autocracy- a form of government in which a country is ruled by a person or group with total power. 4. Constitution- the system

Course 1 Unit 3 Practice
Feb 19, 2015 - than her brother Dyami. The sum of their ages is. 23 years. How old is Dyami? 25. Corrine and Elizabeth went out for dinner. The check for their dinner was $32.75. Corrine knows her dinner cost $18.95. How much did Elizabeth's dinner c

Course 1 Unit 2 Practice
Robert lives at 5th Street and 8th Avenue. a. Write each location as an ordered pair. b. What is the distance between Jeremy's home and Adriana's home? c.

unit -1.pdf
Adaptation to prefabrication. Speed of erection. Elasticity. Ductility. Toughness. Suitability to provide additions to existing structures. Disadvantages Of ...

unit 1 understanding groups - eGyanKosh
collectivities are differences of kind. No one would suggest that eggs, caterpillars, pupae, and moths are not part of the same life cycle despite -heir apparent.

Course 1 Unit 2 Practice
SpringBoard Course 1, Unit 2 Practice. LeSSon 7-1. 1. Model with mathematics. Identify the integer at each point. a. 28 b. 0 c. 10 d. 8 e. 25 f. 11. 2. Write the opposite of each integer. a. 1 b. 228 c. 0 d. 2(27) e. |2100| f. 23. 3. Write an integer

Unit 1 bootstrapping.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item.

Course 2 Unit 1 Practice
Explain how you would divide a mixed number by a fraction. 13. John cut a 4 ft long piece of lumber into shorter pieces to repair his deck. He cut three pieces each. 3. 4 ft long, and two pieces each. 1. 2 ft long. How much ... SpringBoard Course 2,

UNIT-1.PDF
The File System ... In this mode, whatever you type is ... pwd, cd, mkdir, rmdir, ls, cp, mv, rm, cat, more, wc,. Page 2 of 15. Page 3 of 15. UNIT-1.PDF. UNIT-1.PDF.

unit 1 first impressions -- unit test
My mother says that I am a 1__________because I am very messy and don't follow any rules, but I am not a 2___________ boy. I know that I have to centre ...

Algebra 1 Unit 1 Section 1 Patterns Copies.pdf
Algebra 1 Unit 1 Section 1 Patterns Copies.pdf. Algebra 1 Unit 1 Section 1 Patterns Copies.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying ...

PSC unit (1)_NoRestriction.pdf
End encno4g"s- Nnt renrrired Required. 4 G,routing. 5. tnss of Preqllregr --=.- ffi. dead loadi can be counteracted. L^. 6. Dead load counter action ?. Cable Profile.

Unit 1 Review Modern World.notebook
Unit 1 Review Modern World.notebook. 2. January 21, 2015. Questions. Click a number below to answer a question. (Drag the # behind the trash can so you know which have been used!) Q1. Game. Board. When did the Industrial. Revolution start? 1750 ...

CGG Unit 1 & 2.pdf
Loading… Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Main menu. There was a problem previewing

english test unit-1
(3) He is going to temple. (where) ..…………………………………………………………………………………………………………………………………… (4) Brinjal is ...

physics 20n unit 1
moving south along a river at 8.0 m/s. What is the apparent velocity of the man ... A student moves on a straight sidewalk from one school to an adjacent one; she then turns and walks partway back to the first school. School B is straight east of sch