structured concurrent programming
play

Structured Concurrent Programming Jayadev Misra Department of - PowerPoint PPT Presentation

D EPARTMENT OF C OMPUTER S CIENCES Structured Concurrent Programming Jayadev Misra Department of Computer Science University of Texas at Austin Email: misra@cs.utexas.edu web: http://www.cs.utexas.edu/users/psp Collaborators: William Cook,


  1. D EPARTMENT OF C OMPUTER S CIENCES Structured Concurrent Programming Jayadev Misra Department of Computer Science University of Texas at Austin Email: misra@cs.utexas.edu web: http://www.cs.utexas.edu/users/psp Collaborators: William Cook, David Kitchin U NIVERSITY OF T EXAS AT A USTIN 0

  2. D EPARTMENT OF C OMPUTER S CIENCES Example: Airline � Contact two airlines simultaneously for price quotes. � Buy ticket from either airline if its quote is at most $300. � Buy the cheapest ticket if both quotes are above $300. � Buy any ticket if the other airline does not provide a timely quote. � Notify client if neither airline provides a timely quote. U NIVERSITY OF T EXAS AT A USTIN 1

  3. D EPARTMENT OF C OMPUTER S CIENCES Wide-area Computing Acquire data from remote services. Calculate with these data. Invoke yet other remote services with the results. Additionally Invoke alternate services for failure tolerance. Repeatedly poll a service. Ask a service to notify the user when it acquires the appropriate data. Download an application and invoke it locally. Have a service call another service on behalf of the user. U NIVERSITY OF T EXAS AT A USTIN 2

  4. D EPARTMENT OF C OMPUTER S CIENCES The Nature of Distributed Applications Three major components in distributed applications: Persistent storage management databases by the airline and the hotels. Specification of sequential computational logic does ticket price exceed $300? Methods for orchestrating the computations We look at only the third problem. U NIVERSITY OF T EXAS AT A USTIN 3

  5. D EPARTMENT OF C OMPUTER S CIENCES � Orchestration language. Overview of Orc � A Program execution – Invoke services by calling sites – Manage time-outs, priorities, and failures � Simple – calls sites, – publishes values. – Language has only 3 combinators. – Semantics described by labeled transition system and traces. – Combinators are (monotonic and) continuous. U NIVERSITY OF T EXAS AT A USTIN 4

  6. D EPARTMENT OF C OMPUTER S CIENCES Structure of Orc Expression � Simple: just a site call, CNN ( d ) � composition of two Orc expressions: Publishes the value returned by the site. f and g in parallel f j g x from f do g f > x > g x from g do f f where x : 2 g do Symmetric composition for all Piping for some Asymmetric composition U NIVERSITY OF T EXAS AT A USTIN 5

  7. f j g D EPARTMENT OF C OMPUTER S CIENCES CNN j B B C : calls both CNN and B B C simultaneously. Symmetric composition: 0 , 1 or 2 values) � Evaluate f and g independently. Publishes values returned by both sites. ( � Publish all values from both. � No direct communication or interaction between f and g . They may communicate only through sites. U NIVERSITY OF T EXAS AT A USTIN 6

  8. f > x > g D EPARTMENT OF C OMPUTER S CIENCES f do g . Publish only the values from g . Pipe: � CNN > x > E mail ( addr ess; x ) CNN . Bind result (if any) to x . Call E mail ( addr ess; x ) . For all values published by E mail . � ( C N N j B B C ) > x > E mail ( addr ess; x ) Call E mail twice. Publishes up to two values from E mail . Publish the value, if any, returned by May call U NIVERSITY OF T EXAS AT A USTIN 7

  9. D EPARTMENT OF C OMPUTER S CIENCES f � g for f > x > g if x unused in g . Notation f > x > g j h > y > u ( f > x > g ) j ( h > y > u ) Write Precedence: U NIVERSITY OF T EXAS AT A USTIN 8

  10. D EPARTMENT OF C OMPUTER S CIENCES Schematic of piping f f > x > g g0 g1 g2 Figure 1: Schematic of U NIVERSITY OF T EXAS AT A USTIN 9

  11. ( f where x : 2 g ) D EPARTMENT OF C OMPUTER S CIENCES g do f . Publish only the values from f . Asymmetric parallel composition: E mail ( addr ess; x ) where x : 2 ( CNN j B B C ) x to the first value from CNN j B B C . For some value published by � Evaluate f and g in parallel. x are suspended; other site calls proceed. ( M j N ( x )) where x : 2 g Binds � When g returns a value, assign it to x and terminate g . Site calls that need � Values published by f are the values of ( f where x : 2 g ) . Resume suspended calls. U NIVERSITY OF T EXAS AT A USTIN 10

  12. D EPARTMENT OF C OMPUTER S CIENCES Some Fundamental Sites 0 : never responds. l et ( x; y ; � � � ) : returns a tuple of its argument values. if ( b ) : boolean b , b is true; remains silent if b is false. S ig nal returns a signal immediately. Same as if ( true ) . returns a signal if R timer ( t ) : integer t , t � 0 , returns a signal t time units later. U NIVERSITY OF T EXAS AT A USTIN 11

  13. D EPARTMENT OF C OMPUTER S CIENCES Centralized Execution Model � An expression is evaluated on a single machine (client). � Client communicates with sites by messages. � All fundamental sites are local to the client. R timer respond immediately. � Concurrent and distributed executions are derived from an expression. All except U NIVERSITY OF T EXAS AT A USTIN 12

  14. D EPARTMENT OF C OMPUTER S CIENCES MailOn e ( a ) � Expression Definition E mail ( a; m ) where m : 2 ( CNN j BBC ) MailL o op ( a; t ) � MailOn e ( a ) � R timer ( t ) � MailL o op ( a; t ) � Expression is called like a procedure. MailL o op does not publish a value. � Site calls are strict; expression calls non-strict. May publish many values. U NIVERSITY OF T EXAS AT A USTIN 13

  15. D EPARTMENT OF C OMPUTER S CIENCES Metronome Metr onome � S ig nal j ( R timer (1) � Metr onome ) Publish a signal at every time unit. S R n signals. S R BM (0) � 0 BM ( n ) � S ig nal j ( R timer (1) � BM ( n � 1)) Publish U NIVERSITY OF T EXAS AT A USTIN 14

  16. D EPARTMENT OF C OMPUTER S CIENCES Example of Expression call � Site Quer y returns a value (different ones at different times). � Site A ept ( x ) returns x if x is acceptable; � Produce all acceptable values by calling Quer y at unit intervals it is silent otherwise. Metr onome � Quer y > x > A ept ( x ) forever. U NIVERSITY OF T EXAS AT A USTIN 15

  17. D EPARTMENT OF C OMPUTER S CIENCES M ’s response if it arrives before t , and 0 otherwise. Time-out l et ( z ) Publish z : 2 M j R timer ( t ) � l et (0) where U NIVERSITY OF T EXAS AT A USTIN 16

  18. D EPARTMENT OF C OMPUTER S CIENCES M and N in parallel. Fork-join parallelism l et ( u; v ) Call u : 2 M v : 2 N Return their values as a tuple after both respond. where ( l et ( u; v ) u : 2 M ) v : 2 N This stands for: where where U NIVERSITY OF T EXAS AT A USTIN 17

  19. D EPARTMENT OF C OMPUTER S CIENCES Recursive definition with time-out tal l y ([ ℄) � l et (0) Call a list of sites. tal l y ( M : M S ) � u + v Count the number of responses received within 10 time units. u : 2 ( M � l et (1)) j ( R timer (10) � l et (0)) v : 2 tal l y ( M S ) where U NIVERSITY OF T EXAS AT A USTIN 18

  20. M � f j N � g D EPARTMENT OF C OMPUTER S CIENCES f and g start only after both M and N complete. Barrier Synchronization in l et ( u; v ) u : 2 M v : 2 N ) � ( f j g ) ( where U NIVERSITY OF T EXAS AT A USTIN 19

  21. D EPARTMENT OF C OMPUTER S CIENCES � :P + � :Q Arbitration In CCS/ Pi-Calculus: if ( b ) � P j if ( : b ) � Q b : 2 ( Al pha � l et ( true )) j ( B eta � l et ( false )) In Orc: where Orc does not permit non-deterministic internal choice. U NIVERSITY OF T EXAS AT A USTIN 20

  22. D EPARTMENT OF C OMPUTER S CIENCES Priority � Publish N ’s response asap, but no earlier than 1 unit from now. D el ay � ( R timer (1) � l et ( u )) where u : 2 N � Call M , N together. M responds within one unit, take its response. l et ( x ) where x : 2 ( M j D el ay ) If Else, pick the first response. U NIVERSITY OF T EXAS AT A USTIN 21

  23. f D EPARTMENT OF C OMPUTER S CIENCES f can not be directly interrupted. Interrupt � Interrupt :set : to interrupt f Evaluation of Introduce two sites: � Interrupt :g et : responds after Interrupt :set has been called. f , evaluate l et ( z ) where z : 2 ( f j Interrupt :g et ) Instead of U NIVERSITY OF T EXAS AT A USTIN 22

  24. D EPARTMENT OF C OMPUTER S CIENCES M and N return booleans. Compute their parallel or. ift ( b ) � if ( b ) � l et ( true ) : returns true if b is true ; silent otherwise. Parallel or ift ( x ) j ift ( y ) j or ( x; y ) Sites x : 2 M ; y : 2 N where l et ( z ) z : 2 ift ( x ) j ift ( y ) j or ( x; y ) To return just one value: x : 2 M y : 2 N where U NIVERSITY OF T EXAS AT A USTIN 23

  25. D EPARTMENT OF C OMPUTER S CIENCES A and B . Airline quotes: Application of Parallel or as soon as it is available, Contact airlines thr eshold ( x ) returns x if x < ; silent otherwise. Min ( x; y ) returns the minimum of x and y . Return any quote if it is below otherwise return the minimum quote. l et ( z ) z : 2 thr eshold ( x ) j thr eshold ( y ) j Min ( x; y ) x : 2 A y : 2 B where U NIVERSITY OF T EXAS AT A USTIN 24

  26. D EPARTMENT OF C OMPUTER S CIENCES Sequential Computing � ( S ; T ) is ( S � T ) � b then S T if ( b ) � S j if ( : b ) � T if else is � B ( x ) do x := S ( x ) l oop ( x ) � B ( x ) > b > ( if ( b ) � S ( x ) > y > l oop ( y ) j if ( : b ) � l et ( x )) while U NIVERSITY OF T EXAS AT A USTIN 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend