CS322: Concurrent Processes and Programming

Programming language constructs for expressing parallelism

  1. Traditional programming languages are oriented toward sequential programming, since the assumption is that S1; S2 means that S1 is done before S2. To write programs that use concurrency, we must either:

  2. One of the earliest proposed programming primitives for concurrency was fork .. join. This primitive has the advantage of being able to specify any possible parallel computation.

  3. Dijkstra's primitive: PARBEGIN .. PAREND, also known as COBEGIN .. COEND:

    PARBEGIN      or:      COBEGIN
      S1;                    S1;
      S2;                    S2;
      ...  	                 ...
      Sn                     Sn 
    PAREND;                COEND;
    

  4. Tasking. Several programming languages - notably PL/1 and Ada - include the concept of a task. A task looks syntactically like a (parameterless) procedure; but if a program consists of a number of tasks then each task is able to execute concurrently with all the others.

  5. Java Threads. Java is a true multi-threaded language. It is difficult to do any substantial GUI-based work with Java without using threads. In many cases threads are used to avoid what would be a more complicated interrupt scheme and little inter-thread communication is required. However it is possible to have threads interact with each other in an arbitrarily complex way.

  6. Note that all of these constructs simply indicate to the compiler that certain statements may be done in parallel.

  7. Note that we have now established a distinction between a program and the process(es) executing it. This is terribly important.


$Id: concurrency3.html,v 1.5 1998/03/03 23:42:04 senning Exp $

These notes were written by Prof. R. Bjork of Gordon College. In February 1998 they were edited and converted into HTML by J. Senning of Gordon College.