Using the Process Ring Simulator

This document was last modified on February 26, 2002 and reflects changes made in version 0.57.


Table of Contents

Overview
System and User Requirements
Starting the Simulator
Basic Operation
Simple Program Modifications
Scheduling
Displaying Information
Program Format
Changing The Program
Creating Programs
Local Logging
Other Buttons
Configuration
Widget List
Enhanced Program Structure


Overview

The Process Ring Simulator simulates a program consisting of pipe, dup2, close, fork, read, write, and print instructions. As originally written it was designed to follow the structures of the ring example of Chapter 7 of UNIX Systems Programming, Concurrency, Communication, and Threads. It has been significantly enhanced to allow other types of program structure. The first part of the document describes the use of the program as a process ring simulator. The enhancement are described at the end of the document.

The simulator allows you to design a program and single step through it, displaying pictorially the processes and pipes and their relationship.

The program can send data through the pipes and trace the operation of the program.

The simulator is a Java program that uses the JELI package. Many of the parts of the simulator use this standard interface.


System and User Requirements

System requirements:

User requirements:

If you are only interested in this simulator, you can download a zip file ring.zip that contains all of the files that you need.

Running in a non-Windows environment:
If you installed the simulator by copying the files from a CD, the scripts may not have the correct permissions to run. The convert and runring files should be executable.
The ASCII files distributed with this distribution are in the Windows format in which lines end in a carriage return followed by a line feed. It may be more convenient to have the carriage returns removed. If you are running under UNIX, Linux, or Mac OSX, it may be more convenient to have the carriage returns removed. You can remove all of the carriage returns from these files by executing the convert script.


Starting the Simulator

If you are running from an image of the simulator CD, start in the ring subdirectory of the run directory. If you unzipped the Ring.zip file in a single directory, start in that directory. In either case, you can start the simulator from a command window by executing typing runring. In a Windows environment you can also just click on the file runring.bat.

If you do a custom installation, you can put the jar files anywhere you want. Modify the runring.bat (Windows) or runring (Unix, Linux, Mac OSX) file so that the JARDIR1 or JARDIR2 variables points to the location of the jar files.

If the simulator does not start, make sure you have the Java runtime executables in your path. In a command window, execute:
java -version
and make sure this displays a version later than 1.0.


Basic Operation

Start the simulator. If all goes well the simulator will start up and look something like Figure 1.

Figure 1: The main simulator window.

The figure shows one process with arrows representing standard input and standard output.

Push the green Run Until Done button on the right side of the window and the program will step through its execution. After a few seconds the program will terminate and the screen will look like Figure 2. The rectangles represent pipes.

Figure 2: The main simulator window.

This figure illustrates why this is called the Process Ring Simulator. The processes can communicate by sending messages in a ring,writing to standard output and reading from standard input.

To exit the simulator, push the pink Quit button that is in the upper right corner of the the yellow ring diagram.

To start the program from the beginning, find the Reset button in the second column of buttons under the diagram.

Figure 1 shows a diagram of the simulator window when the simulator first starts up, or after the Reset button has been pushed. The large yellow area in the upper left part of the window is used for a diagram of the processes.

Each process is represented by a circle with its process ID in the center. The first process ID is always 100 and as processes are created by executing fork calls, the process IDs are incremented, assuming no other processes are created in the system. Arrows out of the process represent file descriptors that can be used for output. Arrows into the process represent file descriptors that can be used for input. By default, standard error is not displayed since it clutters the diagram.

When a pipe call is executed, a rectangle representing the pipe is displayed with two new file descriptors connected to the process. A dup2 call moves the file descriptor arrows appropriately and the fork call creates a new process. When processes and pipes are created, they are positioned so that when the standard program is run, the processes and pipes will appear in a ring. The processes and pipes can be moved around on the screen by dragging them with the mouse. The pipes can be rotated by dragging close to the corner of the pipe rectangle. The numbers that represent the file descriptors can also be dragged.

To the right of the diagram is the program window. This is a Jeli Text Display which shows the program being executed. The arrow that starts out at the top is above the instruction to be executed next. The process ID of the active process is shown in the Execute: pid button at the top of this window. Clicking on this button will cycle through the active processes. Just below the program window are 5 labels showing the name of the program (if it has one, the default program being called Ring of Processes) and the values of the local program variables. These include the integers childpid and i, the fd and fd1 arrays and the contents of the buffer, buf.

Below the diagram and the program are 6 columns of buttons for controlling the simulation.

There are two basic ways of running the program.

The green Run Until Done button on the rightmost column of buttons will start the program running and automatically step through the program at a given rate. The rate can be modified using the light green slider labeled Delay that is located below the button. The delay is in milliseconds and represent the amount of time the simulator pauses after each step is displayed. The limiting factor on the speed of execution is the time it takes to redisplay after each step. The slider is a standard Jeli slider. When the Run Until Done button is pushed, it changed to a Stop Running button which can be used to stop the execution. In this mode of operation, the scheduling of the processes is controlled by the third column of buttons as described later.

The green Execute button executes one line of code. This can be used to single-stop through the program. After each instruction is executed, you may push the Execute: pid button at the top of the program to change which process will be executed next.


Simple Program Modifications

The second column of buttons can be used to make simple modifications to the program. The Onedirectional button loads the standard default ring program. The Bidirectional button loads a more complicated version that creates a bidirectional ring of processes.

The Change Program button uses a Jeli Popup List to present a list of loadable programs. The standard programs normally distributed with the simulator include the ring, a process fan, and a process chain. Choosing one of these resets the program to the chosen one. It is possible to have your own programs listed here. Each program listed corresponds to one line in the configuration file ringconfig. Adding lines to this file allows you to choose additional programs. Programs can be created using a standard text editor or by the simulator. Information on the format is in the section Creating Programs.

The break button allows you to cycle through possibilities for breaking out of the main for loop of the program. The table below gives the relationship between the Break button and the code that is used:

Button Break: parent Break: child Break: parent and child Break: none
Code if (childpid)
    break;
if (!childpid)
    break;
break; none

The Reset button starts the program from the beginning again.


Scheduling

The simulator allows control over several aspects of the scheduling of the processes using the purple buttons in the third and fourth column.

The After fork: button controls which process executes after a fork. The possibilities are parent, child, either, and random. Either means that either the child or parent will execute and the choice is made randomly with equal probability. Random means that any ready process can execute and the choice will be made among the ready processes with equal probability.

The Choose Process button controls which process will execute next when the running process loses the CPU. A process can lose the CPU by having its quantum expire, by blocking on a wait for child call, by blocking on a read from a pipe, or by terminating. The choices are FCFS (the process that entered the ready queue first is chosen), Next (the ready process with the next highest PID is chosen) and Random (a random ready process is chosen). The Scheduling button controls the process scheduling algorithm. The default is no preempt in which a process runs until it blocks or terminates. When RR is chosen, round robin scheduling is used and a slider appears below the scheduling button allowing am integer quantum to be set. The quantum represents the number of instructions to be executed before the process loses the CPU. When Random is chosen, a slider appears below the scheduling button allowing a probability to be set. This represents the probability that a process will lose the CPU after executing an instruction.

To the right of the Scheduling button is the Print button. The default is Print Atomic in which the output of fprintf is assumed to be atomic. If Print Not Atomic is chosen, a probability slider appears which gives the probability of losing the CPU after each character of the fprintf is output.


Displaying Information

There are several ways to display information about the state and history of the simulation. Most of these are controlled by the Display Info button at the top of the 5th column of buttons. Clicking on this brings up a Jeli Popup List to list some items that can be displayed. Some of these items may be disabled if the corresponding information is not available.

The list of display options includes:

You can show information about a particular process by clicking on the circle representing that process in the yellow display window. This pops up two windows, one showing the history (instructions executed) of that process and one showing the current values of the variables for that process.

In addition, a frame containing information about a given pipe can be displayed by clicking on the pipe in the diagram. Two Jeli Text Displays appear, the upper one containing the current contents of the pipe and the lower containing a history of everything that has been read from the pipe.


Program Format

The simulator allows a fairly general program that creates a collection of processes and pipes. The original version of the program was intended to simulator a process ring and has the format given below. A more general format is described later. The ring format is as follows:

<instructions>
for (i=1;i<nprocs;i++) {
    <instructions>
    if (childpid = fork()) {
         <instructions>
    }
    else {
         <instructions>
    }
    <instructions>
    <optional conditional break instruction>
}
<instructions>

The program assumes the following data:

int i;
int childpid;
int fd[2];
int fd1[2];
char buf[BUFSIZE];
where BUFSIZE is assumed to be large enough to handle anything generated by the program. In addition, a constant called nprocs is used in the for loop.

A subset of the supported instructions that can be added on the fly from inside the simulator is given below:

pipe(fd);
pipe(fd1);
dup2(fd[0],0);
dup2(fd[1],1);
dup2(fd1[0],3);
dup2(fd1[1],4);
close(0);
close(1);
close(fd[0]);
close(fd[1]);
close(fd1[0]);
close(fd1[1]);
wait(null);
fprintf(stderr,"This is Process %d with parent %d\n",getpid(),getppid());
sprintf(buf,xxx);
sprintf(buf+strlen(buf),xxx);
fprintf(stderr,"%s",buf);
write(1,buf,strlen(buf)+1);
read(0,buf,BUFSIZE);
read(0,buf+strlen(buf).BUFSIZE);
The two sprintf instructions prompt for the entry of a format string that can contain up to 4 %d specifications. For each of these the user is prompted to specify one of the values:
i
nprocs
childpid
getpid()
getppid()
Assumptions:


Changing The Program

The program can be modified from inside the simulator and saved for later use.

The first button in the third column is the Mode button. It starts with Mode: Execute which allows for the running of the program. Clicking on this button changes it to Mode: Program and 6 new buttons appear below it. The first two buttons can be used to move the pointer up and down. The pointer is shown as an arrow in the program window in the upper right part of the main display. The next two buttons can be used to add a new instruction to the program after the pointer or to delete the instruction after the pointer.

The Add Instruction pops up a menu listing the possible instructions to add. The Delete Instruction button is active only when there is a valid instruction after the pointer. Some instructions cannot be deleted such as the for loop, the if (childpid=fork()) and the else.

The next button allows most instructions to be modified by conditionals such as if (i==1) or if (i!=1). These are most relevant after the for loop because at this point only the original parent has i=1.

To run the modified program, click on the Mode button again to return to execute mode.

The current program can be saved using the yellow Save Program button in the first column of buttons. This saves the program using the file name given in the button below. You can change the name of the file to be used by clicking on this Name: button which is a Jeli Value Button.

By adding a program line to the ringconfig file, these programs can be accessible to later runs of the simulator.


Creating Programs

This section describes the original ring interface. Information about the enhanced interface can be found here.

A program file can be created using the simulator with the Save Program button discussed above. The ringconfig file should contain a program line for each file that can be chosen from the Change Program menu. These files can be created or modified using a standard text editor. When such a file is read into the simulator, it encodes each line of the file using an internal format representing the type of instruction represented by that line. It is not necessary for each line to be a faithful representation of the corresponding instruction. In fact, the simulator looks for key phrases in the instruction to determine which of the allowed instructions it is.

If you want to create a program using a text editor rather than from the simulator, the simulator may not interpret it exactly as you intend. It is best to start with a simulator-created program similar to the one you want and modify it. Loading it into the simulator and saving it will put it into a correct format and tell you how the simulator interpreted your input. Look at the results and make sure that the program generated is the one you want. You can use the following information as a guideline for creating your program.

The format of a program file is as follows:
<pseudocode lines each beginning with #>
<instructions>
<a for loop instruction>
<instructions>
<an if(childpid = fork) instruction>
<instructions>
<an end group instruction>
<an else instruction>
<instructions>
<an end group instruction>
<instructions>
<an optional break instruction>
<an end group instruction>
<instructions>

General instructions are interpreted as follows: The following pseudoinstructions are for creating variables: The following pseudoinstructions are supported and will change the corresponding simulator parameters:


Local Logging

The simulator can display information in a log file. Log files are in HTML format and can be displayed by or printed from a standard browser. The first column of light blue buttons controls the logging functions of the simulator.

Initially, these buttons are used to control the logging functions before the log file is open or after it is closed. The first button opens the log. When the log file is successfully opened most of the buttons change their function to control the log functions appropriate when logging is in progress.

While the log is closed, the second button toggles between the modes Replace Old Log and Append to Log. In the former case, opening the log file overwrites any file with the same name that already exists. In the latter case, the new log is appended to the old one. The third button can be used to change the name and directory used for storing the log file. Pushing this button pops up a dialogue box in which the user can change the directory and log file names. The names of the files for storing the graph image files created by the simulator can also be changed.

The Show Remote Log button can be used to pop up a browser window containing the log file generated when the log is stored remotely.

After the log is successfully opened, the Open Log button changes to Close Log, the second button changes to Log Comment, and the third button changes to Stop Log.

Close Log terminates logging and closes the log file. Stop Log temporarily stops adding information to the log file but keeps the log file open. When pushed, this button changes to Start Log which resumes the logging.

The Log Comment button pops up a window which allows the user to enter comments into the log file.

The Log Image button puts a copy of the currently displayed diagram in the log file.

Most of the frames that display history information have there own Log buttons which becomes active when the log is open and stores the information displayed in the log file. The program window on the right side of the main simulator window also has a Log button which can put a copy of the program in the log file. The Gantt charts can also be logged.


Configuration

Configuration is controlled by default by the file ringconfig. The simulator can be started with an optional command line parameter giving the name of the configuration file.

The configuration file contains lines which can be used to set values for various simulator parameters.

The following configuration parameters are supported:


Widget List

Widget Locations Description
Main
Diagram
Upper
left
corner
This contains the main diagram of the processes and pipes. Each process is represented as a circle containing a number that is its process ID. The process can be moved by dragging it. Clicking on the process brings up a Process History Frame giving a list of all instructions executed by this process.
Pipes are represented by rectangles. They can be moved by dragging or rotated by dragging a point close to one of their corners. Clicking on a pipe brings up a Pipe History Frame giving the current and past contents of the pipe.
New processes and pipes are put at a position around a circle so that under the default program they form a ring. The number of positions around the circle can be set using the npositions button. File descriptors are displayed as arrows from source to destination. The standard error file descriptor is normally not displayed. The display of file descriptor arrows can be changed using the Show FD button. Processes are displayed as black circles by default. Pushing the Black/Color button located in the lower right corner of the diagram can cause each process to be displayed in a unique color, the same color as used for output by that process as shown in the Output Frame.
Two sizes are available for the processes and pipes controlled by the size: large/small button. The large size allows about 6 processes and 6 pipes to fit around the standard size circle. The small size allows about 20. The size of the main diagram window can be changed by adjusting the size of the simulator frame.
Quit
Button
Upper
right
corner
of the
main
diagram
Pushing this button exits the simulator.
Black/
Color
Button
Lower
right
corner
of the
main
diagram
Pushing this button changes the color mode of the main diagram. When black, the processes and pipes are displayed in black. When color, each process is displayed in a distinctive color which is the same as the color of the output in the output frame.
Frame
Button
Upper
left
corner
of the
main
diagram
Pushing this button changes pops up a frame containing the current image in the diagram. This copy will not change when the main diagram changes.
Program
Area
Upper
right
corner
This area contains five buttons across the top, an area of text showing the program, and 5 labels with information about the program on the bottom.
The end buttons at the top are labeled < and > and will decrease or increase the size of the font. The Clr will temporarily clear the text displayed but the text will reappear. The Log button will be active when the log is open and puts a copy of the program in the log file.
The center button is marked Execute n when the simulator is in execute mode. The value of n is the process ID of the active process. Clicking on this button will make the next process active. When in program mode, this button is marked Program.
Button
Area
Below
the
main
diagram
and the
program
area
This area has seven rows of 6 buttons. The buttons are grouped by function with related buttons having the same light background color.
Background ColorFunction
Light BlueLogging
Light YellowSaving the program
Light PurpleModifying the scheduling or
Modifying the program
Light MagentaPopping up information frames
GreenRunning the program
Light GreenAdjusting the speed of program executing
The individual buttons are described below.
Information
Area
Bottom
of the
main
window
This label shows the current version number and acknowledges NSF for supporting the project.
History
Popup
Popup
This frame appears when the Display History option of the Display Info button in the 5th row of buttons is pushed. The frame shows all the instructions executed by all processes. Each instruction is preceded by the process ID of the process that execute it. The buttons at the top of the frame can be used to change the size of the font, to clear the text and to log the text.
Process
History
Popup
Popup
This frame appears when you click on an individual process in the main diagram. It shows all of the instructions executed by a given process. The buttons at the top of the frame can be used to change the size of the font, to clear the text and to log the text.
Variables
Popup
Popup
This frame appears when you click on an individual process in the main diagram. It shows all of the variables for the process and the values of these variables.
Pipe
History
Popup
Popup
This frame appears when you click on an individual pipe in the main diagram. The frame contains two text areas. The upper one shows the current contents of the pipe and the lower one shows the past contents. The buttons at the top of each text area can be used to change the size of the font, to clear the text and to log the text.
Output
Popup
Popup
This frame appears when the Display Output option of the Display Info button in the 5th row of buttons is chosen. The frame displays the output (to standard error) generated by the program. The output from each process is in a distinct color by default. Pushing the Color button at the bottom of the frame will change it to Black and White and the output will appear only in black.
Commentary
Popup
Popup
This frame appears when the Display Commentary option of the Display Info button in the 5th row of buttons is chosen. The option is only available if a commentary has been defined for the current program. Commentary paragraphs are set with the #com pseudoinstruction.
Process
Information
Popup
Popup
This frame appears when you choose the Display Process Info option of the Display Info button in the 5th column of buttons. It contains one line of information for each process giving its process ID, its original parent (the process that created it), it current parent (which may be init), and its process state: one of running, ready, read blocked n (blocked trying to read pipe n), waiting for child, zombie, or done. The number of initial lines for the processes is controlled by the Info Size button.
Semaphore
Information
Popup
Popup
This frame appears when you choose the Display Semaphores option of the Display Info button in the 5th column of buttons if the program has any semaphores defined. It contains one line of information for each semaphore giving the name of the semaphore. If there are no processes waiting for this semaphore to increase, the value of the semaphore is given. If there are processes waiting for this semaphore to increase, a list of PIDs of the waiting processes is given.
Gantt
Chart
Popup
Popup
This frame appears when you choose the Display Gantt Chart option of the Display Info button in the 5th column of buttons. The Gantt chart shows a graphical history of the states of each process.

Individual Buttons
ButtonrowcolDescription
Logging ButtonsThese 5 multiuse buttons have a light blue background and are located in the first column of buttons. The log file is in HTML format and can be displayed and printed from a standard browser.
Open Log11Open the log file. After the log is opened, the button changes to a Close Log button.
Close Log11Close the log file. After the log is closed, the button changes to an Open Log button.
Replace/Append Old Log21This button is available when the log file is not open. It toggled between the two modes for opening a log file. When in the replace mode, opening the log file will replace an older log file with the same name. When in append mode, the new log information is appended to the old file. This button changes to Log Comment when the log file is opened.
Log Comment21Pop up a frame allowing you to put a comment into the log file. The frame contains two windows. You can type into the bottom window to enter text to be placed into the log file. Pushing the Log button at the bottom of the frame enters the text into the log file. The upper window displays all comments previously logged. This button is available only when the log file is open. It changes to the Replace/Append Old Log button when the log file is closed.
Change Log Filename31Pop up a window allowing the user to enter a name for the log file. You can change the name of the log file, the directory for storing the log file, and the name used for storing images created, such as the diagram and Gantt chart. Click on one of the entries to change it. Push return when done editing the entry. The mouse must be inside of the entry while it is being edited (the background becomes cyan). When finished making the changes, push the red Done button. This button is available only when the log file is closed. It changes to the Stop/Start Log button when the log file is opened.
Stop/Start Log31This button toggle between two modes which allow automatic logging to occur. This simulation does not support automatic logging, so this button should not be used. This button is available only when the log file is open. It changes to the Change Log Filename button when the log file is opened.
Show Remote Log41This button is only active when remote logging is used. This is only the case when the simulator is run from a browser with the log file placed on a remote web site.
Log Image51Put a copy of the main diagram into the log file. This may take a while depending on the size of the diagram and the speed of the machine it is running on. This button is only active when the log file is open.
Program Save ButtonsThese 2 buttons have a light yellow background and are used for saving a copy of the current program on disk. They are located in the first column of buttons.
Save Program61Save a copy of the current program in a disk file. The name of the file is set with the Name: button below it. The program is saved in a readable format and can be loaded back into the program the next time it is run by placing a program filename line in the configuration file.
Name: filename71 Show and change the name of the file used for saving the current program. To change the name, click on this button. A cursor will appear at the end of the name. Keep the mouse pointer inside the button (the background becomes cyan) while changing the name. Only the printing character keys and the backspace key can be used. When done, push return and the cursor should disappear. To abort, click on the button with the mouse.
Miscellaneous ButtonsThese 6 buttons in the second column generally relate to the program.
Onedirectional12Replace the current program with a standard one-directional ring program. This program is always available independent of the contents of the configuration file.
Bidirectional22Replace the current program with a two-directional ring program. This button may be disabled in some versions of the program.
Change Program32This pops up a window giving giving a list of programs that have been loaded from disk files. Each entry corresponds to a program filename line in the configuration file. At the bottom of the list are two additional choices. Make Persistent keeps the list active even after a choice is made. Cancel aborts changing the program.
Break: which42 Change the last lines in the for loop. These lines determine which process breaks out of the loop. The possibilities are:
break: parent (the parent breaks out using if (childpid) break;
break: child (the child breaks out using if (!childpid) break;
break: both (both parent and child break out of the loop using break;
break: neither (neither parent nor child break out of the loop)
Reset52Reset the program so that it will start from the beginning.
Refresh14Refresh the display of the diagram. This should automatically occur when necessary, so this button might never have to be used.
Reset Positions24Reset the positions of the processes and pipes to their standard position for the ring of processes. It uses the current value of nprocs to place the processes and pipes in a circle.
Reset Positions Center34 This is identical to Reset Positions except that the first pipe created is put in the center of the display.
Mode: Execute/Program13This button toggles between execute mode (in which the program can be run) and program mode (in which the program can be modified). A number of buttons in the third and fourth column change their function in these two modes. In execute mode the buttons control the process scheduling. In program mode they allow modification of individual lines of the program.
Execute Mode ButtonsThese buttons are active when the simulator is in execute mode.
After fork: which23 This button controls which process executes after a fork occurs. Pushing the button cycles through 4 possibilities. The possibilities are:
parent: the parent continues executing after the fork. The child is ready.
child: the child executes after the fork and the parent is ready.
either: one of the parent or child is chosen at random to execute and the other is ready.
random: both the parent and child become ready and a random ready process is chosen to execute.
Choose Process: how33 This button controls which process executes when the current process loses the CPU. Pushing the button cycles through 3 possibilities. The possibilities are:
FCFS: the process that entered the ready queue first is chosen.
Next: the process in the ready queue with the next highest process ID after the current process is chosen.
Random: a random process is chosen from the ready queue.
Scheduling: which43 This button controls when a process loses the CPU. Pushing the button cycles through 3 possibilities. The possibilities are: nopreempt, RR, and random.
RR refers to round robin scheduling and when this is chosen, an additional slider widget appears below this button. The slider controls the quantum. Here the quantum refers to the number of instructions executed before the process is preempted from the CPU. The slider widget consists of three parts. The first part is three buttons controlling the values and range of the slider. Next is a label giving the value of the quantum. Finally there is the slider for changing the quantum value.
Random scheduling refers to having the running process lose the CPU with a given probability after executing an instruction. When this is chosen a similar slider appears, this on controlling the probability.
Print Atomic44 This button controls the atomic nature of the fprintf instruction. When the mode is print atomic, this printing is done atomicly so the process will not lose the CPU during printing. Pushing this button changes the mode to print not atomic. A probability widget appears below that controls the probability that a process will lose the CPU after each character is output by the fprintf statement.
Program Mode ButtonsThese buttons are active when the simulator is in program mode. In program mode the arrow in the program display points to the instruction below the arrow.
Pointer Up23 Move the pointer up one instruction.
Pointer Down33 Move the pointer down one instruction.
Add Instruction43 Bring up a menu of instructions that can be added below the arrow. Click on one of the instructions to add it. For the sprintf instructions you will be prompted to enter a string. This string may contain up to 4 %d format specifications. For each one you will be prompted for a variable to print.
Delete Instruction53 Delete the instruction below the pointer arrow. This button will be active only if the instruction after the pointer can be deleted.
Change if(...)63 Allows you to change the conditional on the given instruction, either by adding a conditional or removing one.
New Variable73 Allows you to create a new integer variable.
Diagram Modification ButtonsThese buttons are located in the 3rd and 4th rows of the 5th column. They control the diagram display.
Show FD:25 This button cycles through three states:
not 2: Show file descriptor arrows except for standard error
all: Show all file descriptor arrows
none: Show no file descriptor arrows
Show: Pipes and Procs
Show: All
Show: Parent-Child
Show: Processes only
35 This button cycles through these four states.
size:65 This button toggles between large and small. It controls the size of the circles and rectangles used for the processes and pipes. The small setting is appropriate when more than 6 processes are displayed.
Execute Program ButtonsThese buttons in the 6th column have a a green background and are used for running the program.
Run Until Done16 Start running the program and continue until there are no processes ready. When this button is pushed it is changed to a Stop Running button which stops the execution.
Execute26 Execute one instruction of the program.
Delay Slider3-56 Set the delay between executing one instruction to another. The delay is measured in milliseconds.
Miscellaneous Parameter Buttons These buttons in the 6th column.
nprocs:55 Click on this button to change the value of the nprocs program variable.
positions65 Click on this button to change the number of process positions around the circle containing the processes and pipes.
info size75 Click on this button to change the initial number of process lines displayed int the Process Info frame.


Enhanced Program Structure

This sections describes the enhanced program structure that is not restricted to the format of the process ring. If a program contains the #noring pseudo instruction, then the ring program structure is not used and the program is just a sequence of instructions.

A number of additional instructions are available including nested while loops and conditionals.

Any number of integer or character variables can be declared with the #int and #char pseudo instructions. Currently there is no distinction made between integer and character variables. The following instructions can be used with variables. Here, var and var1 refer to the predefined variables (childpid, i) and any variable explicitly declared. In addition, the constant nprocs can be used in places where it is not modified, as in the right side of an assignment or in a write statement. Also, const refers to a numeric constant such as 0 or 17.

Shared variables may be declared using
#shared int varname val or
#shared char varname val. The initial value, val is required for shared variables.

When var++ or var-- is used with a shared variable, it is expanded into three instructions, illustrating that this is not an atomic operation. First the variable is moved into a register (local to the process), then the register is incremented or decremented, and finally the register is stored in the shared variable. These operations are not safe unless protected, for instance by a semaphore. The assignment of a variable either from another variable or a constant is always treated as an atomic operation.

The read and write are meant to be only used for character variables. Only the low byte is written and the variable is set to the byte read.

The var=random(x,y) instruction sets the variable to a random integer between x and y inclusive. The x and y can be either variables or constants.

In addition, any variable can be written as a string into buf using the %d specification in an instruction. At most 4 integers can be used in a single sprintf.

Counting semaphores are also supported. Each semaphore must be declared and initialized with a pseudo instruction before any program code. If sem is the name of such a semaphore then the instructions wait(sem) and signal(sem) are supported.

Program Control Any statement (except a while) can be preceded by an arbitrary number of conditionals in one of the following forms:

where var is the name of a variable and x is either the name of a variable or a constant.

Blocks can be created by putting an open brace at the beginning of a line. These may be preceded by an arbitrary number of conditionals. Blocks are closed by a closed brace on a line be itself. Any statement except a while(1), including a block, can be preceded by any number of conditionals.

The only looping structure is while(1), but since the following statement can be a conditional break, a while(condition) statement can be simulated.