OEP

124

Title

MOBILE process types

Summary

Add first-class suspendable mobile processes.

Owner

Fred Barnes <F.R.M.Barnes@kent.ac.uk>

Status

Accepted

Date-Accepted

2004-05-05

Keywords

language mobiles mobile-processes

This extension adds support for MOBILE processes in "occam-pi" (the new name for the evolving occam-originating language). Mobile processes have an associated process-type that characterises the interface to the process. Mobile processes encapsulate code and data, like any other occam process, but may be moved around a process network. The main restriction is that a mobile process may not be moved whilst it is active. Activations of a mobile process are implemented using an "instance-style" syntax. A mobile process ceases to be active when it terminates or "SUSPEND"s. Once it has terminated, a mobile process may not be reactivated.

The following code defines a fairly simple mobile process (and associated process-type):

PROC TYPE PT IS (CHAN INT in?, out!):

MOBILE PROC integrate (CHAN INT in?, out!) IMPLEMENTS PT
  INT total:
  SEQ
    total := 0
    WHILE TRUE
      INT v:
      SEQ
        in ? v
        total := total + v
        out ! total
        SUSPEND
:

This implements the familiar "integrate" component. When activated, the process will complete one cycle of input and output then suspend. Allocation of a mobile process is done in a similar way as it is for other dynamic mobile types -- with a slightly special form of assignment. For example:

MOBILE PT x:
INT v:
SEQ
  x := MOBILE integrate

  CHAN INT to.int, from.int:
  PAR
    x (to.int?, from.int!)
    to.int ! 42
    from.int ? v

After the activation has finished (because "integrate" SUSPENDed), the mobile process in "x" may be assigned or communicated. When it is next activated, the process may have a completely different environment.

Due to the somewhat special nature of a mobile process activation, there are several restrictions on what parameters may appear in a "`PROC TYPE`" definition -- only synchronisation "objects" may be used as parameters. This currently includes channels, fixed-size arrays of channels and mobile channel-bundle ends.

If a mobile process goes parallel internally, all parallel processes must SUSPEND in order to suspend the mobile process as a whole. This example program demonstrates this using a parallel version of the "integrate" process. Rather than suspending once per cycle, the process interprets "MOSTNEG INT" on its input channel as "suspend". This is one way of handling the suspend -- it could just as easily be supported using dedicated channels (that may be more desirable for clarity).

OEP/124 (last edited 2007-10-19 14:58:57 by ats)