Communicating Sequential Processes - C A R Hoare ------------------------------------------------ Basic idea: multiple concurrent processes can synchronize with each other by synchronizing their I/O i.e., I/O happens only when process A specifically states that it is ready to send data to process B and when process B specifically states that it is ready to recieve data from A. If only one happens without the other, the corresponding process is put on a wait queue. Guarded commands: normal program statement + guard (Boolean expr). Executed only if guard evaluates to true. Alternative guarded command; repeated guarded commands; guard with input from a specific process; Producer-Consumer Problem: Producer(P) --> Buffer(X) --> Consumer(C) X is bounded. P sends output command to X when it is ready to send data. P will wait if X did not issue an input command. C issues an input command when it wants more data. X has multiple guarded commands which check whether there is anything in the buffer and if so sends an output command to C, and issues an input command for P if P is ready with data. Dining Philosophers Problem CSP seems to be similar to blocking message passing Advantages: Conceptually simple, and works for many synchronization problems Disadvantages: Explicit naming of processes needed, and no buffering (always blocking)