Topics:
A Process is an object with its own thread of control. i.e. a CO-ROUTINE
Processes run "concurrently", on a conventional processor this means that control is swapped between them. In a simulation, processes persist over time, with their actions interleaved.
A process may be in these states:
Up to top of this document
Comments, etc, send to
HERE IS WHAT PROCESSES CAN DO:
SLEEP_UNTIL (clock time in the future)
---- put self on the time-ordered "sleep queue"
Semaphores provide synchronization by "guarding" critical sections,
only the designated number of processes can be between WAIT and
SIGNAL at any one time:
See MESSAGE.PAS
HOW TO DEFINE A PROCESS:
TYPE
GIANTptr = ^ GIANT;
GIANT = OBJECT (procdescr)
field1: )
..... ) Globally accessible variables of this process type
fieldN: )
constructor init (name:pname, index:integer, ..[specific inits] ) ;
{--- OPTIONAL may beef up standard init --
IF SO, MUST CALL ProcDescr.Init (name, index) !!}
procedure lifecycle; VIRTUAL; {MUST define a life cycle}
[ other special methods ]
end;
The minimum requirement is:
Giant = object (procdescr)
procedure lifecycle; VIRTUAL;
end;
procedure GIANT.LifeCycle;
var
[any private local variables]
begin
[do this ...]
....
[... do that]
end;
{processes may exhaust life cycle, in which case
they terminate themselves, and are removed by the
monitor}
VAR
bigboy : GiantPtr;
NEW (bigboy, init('Rumble-Buffin', 42, ... ));
RESUME (bigboy); { to put on ready queue }
HOW the "MONITOR" WORKS:
A simulation starts (or continues), after at least one process has
been created and resumed (made ready), by a call to
Monitor.RunSimulation (time_to_simulate, number_of_samples)
The monitor maintains 3 queues: ready, deferred, and sleep.
The first process on the ready queue starts running. When a context
switch is called for (by one of the above mechanisms), the monitor
switches context to either:
Is this DISCRETE OR CONTINUOUS simulation?
Well,
The choice is yours, combined simulation is a snap!
Last updated 17 October 1996
Back to Simulation notes.