ForkOps.mesa
Copyright Ó 1993 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, April 13, 1993 5:27:03 pm PDT
Christian Jacobi, April 16, 1993 6:53 pm PDT
Useful primitives for multi-threaded operations
ForkOps: CEDAR DEFINITIONS ~
Fork:
PROC [proc:
PROC[
REF], data:
REF ¬
NIL, priority:
CARD32 ¬ 2];
Forks a call of proc[data].
ForkDelayed:
PROC [ms:
INT ¬ 0, proc:
PROC[
REF], data:
REF ¬
NIL, priority:
CARD32 ¬ 2];
Delayed fork of proc[data] after approximately ms milliseconds.
ForkPeriodically:
PROC [ms:
INT, proc:
PROC[
REF], data:
REF ¬
NIL, priority:
CARD32 ¬ 2];
Periodically forks proc once every approximate ms milliseconds.
Aborting a periodical procedure will stop further calls of this procedure.
More accurate: The time is the delay between return from previous call to the next fork.
Stop:
PROC [proc:
PROC[
REF], data:
REF ¬
NIL, abort:
BOOL ¬
FALSE];
Stops pending delayed or periodic forks of proc[data].
abort: If true, also calls Process.Abort on process executing proc[data].
Stop is quite expensive (much more expensive then Fork).
Fine points
Like using the language FORK:
This module is no absolute guarantee against forking too many processes.
No nested procedures. However, this module would crash more friendly.
For priorities use the numerical values as defined in Process.mesa.
Rationale
Fork is fast, maybe even faster then the language FORK primitive.
ForkDelayed and ForkPeriodically avoid permanent allocation of process resources.
END.