The key ideas in the design of SuperPascal was to provide a
secure programming, with abstract concepts for parallelism.
Security SuperPascal is
secure in that it should enable its compiler and
runtime system to detect as many cases as possible in which the language concepts break down and produce meaningless results. SuperPascal imposes restrictions on the use of variables that enable a single-pass compiler to check that parallel processes are disjoint, even if the processes use procedures with global variables, eliminating time-dependent errors. Several features in Pascal were ambiguous or insecure and were omitted from SuperPascal, such as labels and goto statements, pointers and forward declarations.
Parallelism The parallel features of SuperPascal are a subset of
occam 2, with the added generality of dynamic process arrays and recursive parallel processes. A parallel statement denotes that the fixed number of statements it contains must be executed in parallel. For example: parallel source() | sink() end A forall statement denotes the parallel execution of a statement by a dynamic number of processes, for example: forall i := 0 to 10 do something()
Channels and communication Parallel processes communicate by sending typed messages through channels created dynamically. Channels are not variables in themselves, but are identified by a unique value known as the
channel reference, which are held by
channel variables. A channel is declared, for example, by the declaration type channel = *(boolean, integer); var c: channel; which defines a new (mixed) type named
channel and a variable of this type named
c. A mixed type channel is restricted to transmitting only the specified types, in this case boolean and integer values. The channel
c is initialised by the open statement: open(c) Message communication is then achieved with the send(channel, value) and receive(channel, variable) statements. The expression or variable providing the value for send, and the variable in receive, must both be of the same type as the first channel argument. The following example shows the use of these functions in a process that receives a value from the
left channel and outputs it on the
right one. var left, right: channel; a: number; receive(left, a); send(right, a) The functions send and receive can both take multiple input and output arguments respectively: send(channel, e1, e2,..., en); receive(channel, v1, v2,..., vn) The following
runtime communication errors can occur: •
Channel contention occurs when two parallel processes both attempt to send or receive on the same channel simultaneously. • A
message type error occurs when two parallel processes attempt to communicate through the same channel and the output expression and input variable are of different types. •
Deadlock occurs when a send or receive operation waits indefinitely for completion.
Parallel recursion Recursive procedures can be combined with parallel and forall statements to create parallel recursive processes. The following example shows how a
pipeline of processes can be recursively defined using a parallel statement. procedure pipeline(min, max: integer; left, right: channel); var middle: channel; begin if min Another example is the recursive definition of a process
tree: procedure tree(depth: integer, bottom: channel); var left, right: channel; begin if depth > 0 then begin open(left, right); parallel tree(depth - 1, left) | tree(depth - 1, right) | root(bottom, left, right) end end else leaf(bottom) == Interference control ==