NextPrevUpTopContentsIndex

16.2.7 Stopping and unstopping processes

This section describes a typical way of using mp:process-stop and mp:process-unstop .

Suppose a pool of "worker" processes is managed by a "manager" process. A process in the worker pool marks itself as available for work, and then calls mp:process-stop . The manager process later finds a worker process that is marked as available for work, puts the work in a place known to the worker process, and then calls mp:process-unstop on the worker process.

For this scheme to work properly, the check of whether the worker is available needs to include a call to mp:process-stopped-p . Otherwise, it is possible for the following sequence of events to occur:

  1. A worker marks itself as available.
  2. The manager process finds the worker and gives it the work.
  3. The manager process calls mp:process-unstop on the worker.
  4. The worker process proceeds and calls mp:process-stop , and never wakes up.

To guard against this possibility, then the manager should call mp:process-stopped-p when finding the worker in the second step above. Alternatively, it could check the result of mp:process-unstop .


LispWorks User Guide - 11 Mar 2008

NextPrevUpTopContentsIndex