Think Stitch

Dynamic Creation of Processes 1

You can model a process which dynamically creates child processes at run time using the parallel composition par. For example, a process P described below creates two processes Q and R when it receives a request event c. After creating the child processes, the process P will get into a wait state for the termination of both Q and R.

(define-process P
  (! c
     (par '()

(define-process Q
  (! a SKIP))

(define-process R
  (! b SKIP))

The process Q and R will terminate after generating an event a and b respectively. Since those events are not synchronized, the order of the occurrences of the events can be arbitrary, that is to say, interleaved. You can see it from the diamond-shaped patterns on the computation tree. When both child processes terminate, the process P as a whole terminates.

You can see from the process trees that the child processes Q and R are created when the process shifts from the state labelled 0 to the state labelled 1. Similarly, you can see that the process tree is folded and the process terminates when the process shifts to the state labelled 6.

Parent and Child Processes

The parallel composition par is similar to fork in the UNIX-like operating systems in that they both have the parent-child relationships. However, the parallel composition is different from fork in that the processes created by a par are all child processes of the process performing the par and the process gets into the wait state for the created processes, while fork continues the execution of the parent process. In spite of the fact, you can use par as fork by thinking of one of the child processes as the continuation of the parent process.

In the next example, a process P creates a child process Q and another branch is considered as the continuation of the process P, which is called P1.

(define-process P
  (! c
     (par (list b)

The process Q notify the parent of its termination through an event b after doing its job (indicated with an event a), and then terminates.

(define-process Q
  (! a (! b SKIP)))

The process P1 waits for the event b, the notification of the termination of the process Q. When it is received, P1 also terminates. In order to synchronize on the event b, we specify the event b in the synchronization list of the parallel composition.

(define-process P1
  (! b SKIP))

The computation tree of the process P is as follows:

3 August, 2013