Processes represent the active entities in a CSIM model. For example, in a model of a bank, customers might be modeled as processes (and tellers as facilities). In CSIM, a process is a C (or C++) procedure which executes a create statement. A CSIM process should not be confused with a UNIX process (which is an entirely different thing). The create statement is similar to a UNIX “fork" statement. A process can be invoked with input arguments, but it cannot return a value to the invoking process. There can be several simultaneously "active" instances of the same process. Each of these instances appears to be executing in parallel (in simulated time) even though they are in fact executing sequentially on a single processor. The CSIM runtime package guarantees that each instance of every process has its own runtime environment. This environment includes local (automatic) variables and input arguments. All processes have access to the global variables of a program.
A CSIM process, just like a real process, can be in one of four states:
When an instance of a process terminates, either explicitly or via a procedure exit, it is deleted from the CSIM system. Each process has a unique process id and each has a priority associated with it.
To initiate a process:
proc(arg1, ..., argn);
proc_id = proc(arg1,...,argn);
Where:
Notes:
To create a process:
create("name");
Where:
Notes:
Notes:
A process terminates when it either executes a terminate statement or when it does a normal procedure exit.
To explicitly terminate a process:
terminate();
Notes:
The initial priority of a process is inherited from the initiator of that process. For the sim (main) process, the default priority is 1 (low priority).
To change the priority of a process:
set_priority(p);
Where:
These functions each return some information the process issuing the statement. The type of the returned
value for each of these functions is as indicated. The syntax conventions for these statements are as follows:
a - is a returned value of type char*.
n is a returned value of type long.
Statement Returned Value a = process_name(); pointer to name of process issuing inquiry n = identity(); identifier (process number) of process issuing inquiry n = priority(); priority of process issuing inquiry
To print the status each active process in a model:
status_processes();
Notes:
To print the status of processes with pending state changes (the “next evet list)
Notes: