CS452 - Real-Time Programming - Fall 2011

Lecture 32 - Communicating Sequential Processes (CSP)

Public Service Annoucements

  1. Final demo: Tuesday, 6 December, 2011; Wednesday, 7 December, 2011
  2. Final exam: 10.30, Friday, 9 December, 2011 to 13.30, Saturday, 10 December, 2011.

Can Message Passing be Made Type Safe?

Dynamically

Yes, even including type extension and polymorphism, but

Statically

No,

CSP

To formal methods people CSP is a calculus for reasoning about the correctness of multi-process/threaded/tasking (MPTT) systems. Active research has been ongoing for forty years with several goals

For programmers the claim has been and is made that CSP provides a superior method for structuring MPTT systems. (`Superior' in the sense of `easier to design, implement and understand'.)

Primitives

In CSP there are two communication primitives. In the notation of occam 2/Go, they are

  1. read
    keyboard ? ch
    ch = <- keyboard
  2. write
    keyboard ! duh
    keyboard <- duh

The communication primitives require something new, called a channel.

CHAN OF CHAR keyboard
keyboard chan char

The Transputer

Use many co-operating, medium capability microCPUs to do a big job.

Problem is communication

Communication requires either

What about real-time?

The transputer was an early, now vanished, example of a real-time system based on plentiful small granularity communication. Your kernel is another example.

Transputer hardware

Occam 2

Basic idea

  1. processes (tasks)
  2. CSP channels
  3. time

Combining processes

  1. sequential
  2. conditional
  3. looping
  4. parallel
  5. alternation

Time

Can you Build a Server with Type-Checking?

Outer
Scope
|
| CHAN OF REQUEST request
|
| Server 
| Scope
| |
| | REQUEST sreq
| | CHAN OF REPLY srep
| |
| | request ? sreq
| | srep := sreq.reply
| |
| | srep ! sresult
| |
| |
| |
| Client
| Scope
| |
| | REQUEST creq
| | CHAN OF REPLY crep
| |
| | creq.reply := crep
| | request ! creq
| |
| | crep ? cresult
| |
 

The Result

You can write a type-safe server, BUT

BUT


Return to: