Concurrent Euclid


Concurrent Euclid Concurrency Features

Following is a brief description of the Concurrent Euclid notation used to express concurrency. Concurrent Euclid utilizes processes, monitors, condition variables, wait and signal statements, and priority conditions to specify and control concurrent execution. A process is written as in Figure 1.

var ModuleName:
module
include ...
...

process ProcessName1
imports ...
begin
...
end ProcessName1

process ProcessName2
imports ...
begin
...
end ProcessName2
end module

Figure 1. Concurrent Euclid Processes

The example shown in Figure 1 declares two processes within the module ModuleName. Any module may contain processes. They appear as above following the module's initially procedure if present. The processes execute in parallel at undetermined relative speeds. The processes may import procedures declared in the module. Monitors are declared in Concurrent Euclid in a manner similar to a module declaration. Figure 2 gives an outline form for a Concurrent Euclid monitor declaration.

var ModuleName:
module
include ...
var MonitorName:
monitor
imports ...
exports (Procedure1, Procedure2)
var ... {these are the variables housed in the
monitor }

procedure Procedure1 =
imports ...
begin
...
end Procedure1

Procedure2 =
imports ...
begin
...
end Procedure2
end monitor
process Process1
imports (var MonitorName)
begin
...
MonitorName.Procedure1
...
end Process1

process Process2
imports (var MonitorName)
begin
...
MonitorName.Procedure2
...
end Process2

end module

Figure 2. Concurrent Euclid Monitors

In Figure 2, a monitor, MonitorName is declared. The monitor contains variables and procedures. Two procedures are exported from the monitor, Procedure1 and Procedure2. Two processes are declared, Process1 and Process2. Each process contains an import statement which imports the monitor MonitorName. The procedures declared in the monitor are made accessible to the processes by the import statement. Process1 is shown calling Procedure1 in the monitor. Procedure1 will access the variables declared in the monitor. A monitor cannot contain modules, monitors, or processes. A monitor may not export variables, only procedures. Nothing declared within the monitor is visible outside the monitor unless it is explicitly exported in an export statement. A monitor may contain an initially procedure which is executed prior to any procedure entering the monitor. Of course, only one procedure at a time is allowed to execute in the monitor.

Concurrent Euclid provides synchronization through condition variables and call of wait and signal. Condition variables must be declared inside a monitor. Wait and signal operate on condition variables. Wait and signal may only be called from within a monitor. A condition variable may be thought of as a queue of processes. A call to wait(c) places the calling process on the queue, c. The calling process is then removed from the monitor. A signal(c) removes one waiting process from the queue c. The signaling process, then, is removed from the monitor and may resume only when there are no more processes in the monitor. If a call of signal(c) is made and there are no processes on the queue c, then the caller may continue without interruption. The order in which processes are removed from a queue associated with a condition variable is unspecified. Thus, it should not be assumed that the order is FIFO. The word queue is used loosely in this context and is not necessarily managed as a true queue. In addition to signal and wait, Concurrent Euclid implements an empty function. Empty is a Boolean function which operates on condition variables and returns true if there are any processes currently waiting on the queue for that condition; otherwise, it returns false.

Concurrent Euclid also provides priority conditions. When a wait is called on a priority condition, a non-negative integer priority is given, as in wait(c,3). When a signal of a priority condition is issued, the process with the lowest priority on the queue is awakened. This completes the discussion of the concurrency features of Concurrent Euclid. Although brief, this should be sufficient to follow the notation used in the examples in class. For a more complete discussion of the concurrency facilities of Concurrent Euclid and how to use them, refer to "Concurrent Euclid, the UNIX System, and Tunis," Holt.

Using the Concurrent Euclid Compiler

The Concurrent Euclid compiler may be used in two ways. One way is to write your source file using any editor you are familiar with. Save the file with an extension of ".e" Then invoke the compiler with "cec filename.e" If there are errors you will need to look in filename.lst to determine what they are. The other method is to use the integrated development environment known as TTV (Toronto Teaching enVironment). To invoke this environment enter "TTV". You may use the TTV editor to construct your program and can also compiler and execute your program from within the TTV environment without leaving the editor. The advantage of this method is that if there are compiler errors, you will be placed in the editor and can inspect the compiler error message, correct the mistakes and try again. The disadvantage of this method is ,of course, that you must learn to use yet another set of editor commands. Since the TTV editor has a screen editing mode (move the cursor where you want to be and type) this isn't so bad. An introduction to the TTV editing modes and commands is summarized below for your reference. You may also obtain this information from TTV by entering the appropriate help commands. Information on how to use the Concurrent Euclid compiler can be obtained by typing HOW at the operating system prompt. Also, if you enter "cec -h" you will get a list of cec command line options.

TTV - CONCURRENT EUCLID PROGRAMMING ENVIRONMENT

TTV is an integrated Concurrent Euclid program development environment consisting of the Concurrent Euclid Compiler, paragrapher and run-time system integrated with a powerful visual editor. The TTV editor has three modes of operation. Information on the commands for each mode can be obtained interactively or by looking here.