SuperPascal
   HOME

TheInfoList



OR:

SuperPascal is an imperative, concurrent computing
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
developed by
Per Brinch Hansen Per Brinch Hansen (13 November 1938 – 31 July 2007) was a Danish-American computer scientist known for his work in operating systems, concurrent programming and parallel and distributed computing. Biography Early life and education Per B ...
. It was designed as a ''publication language'': a thinking tool to enable the clear and concise expression of concepts in parallel programming. This is in contrast with implementation languages which are often complicated with machine details and historical conventions. It was created to address the need at the time for a parallel publication language. Arguably, few languages today are expressive and concise enough to be used as thinking tools.


History and development

SuperPascal is based on
Niklaus Wirth Niklaus Emil Wirth (born 15 February 1934) is a Swiss computer scientist. He has designed several programming languages, including Pascal, and pioneered several classic topics in software engineering. In 1984, he won the Turing Award, generally ...
's sequential language Pascal, extending it with features for safe and efficient concurrency. Pascal itself was used heavily as a publication language in the 1970s. It was used to teach structured programming practices and featured in text books, for example, on
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
s and programming languages. Hansen had earlier developed the language
Concurrent Pascal Concurrent Pascal is a programming language designed by Per Brinch Hansen for writing concurrent computing programs such as operating systems and real-time computing monitoring systems on shared memory computers. A separate language, ''Sequenti ...
, one of the earliest concurrent languages for the design of
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s and
real-time Real-time or real time describes various operations in computing or other processes that must guarantee response times within a specified time (deadline), usually a relatively short time. A real-time process is generally one that happens in defined ...
control systems. The requirements of SuperPascal were based on the experience gained by Hansen over three years in developing a set of model parallel programs, which implemented methods for common problems in
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includi ...
. This experimentation allowed him to make the following conclusions about the future of scientific parallel computing: * Future parallel computers will be ''general-purpose'', allowing programmers to think in terms of ''problem-oriented'' process configurations. This was based on his experience programming networks of
transputer The transputer is a series of pioneering microprocessors from the 1980s, intended for parallel computing. To support this, each transputer had its own integrated memory and serial communication links to exchange data with other transputers. T ...
s, which were general-purpose
processors A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, ...
able to be connected in ''
arrays An array is a systematic arrangement of similar objects, usually in rows and columns. Things called an array include: {{TOC right Music * In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
'', ''
trees In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are u ...
'' or ''
hypercubes In geometry, a hypercube is an ''n''-dimensional analogue of a square () and a cube (). It is a closed, compact, convex figure whose 1-skeleton consists of groups of opposite parallel line segments aligned in each of the space's dimensions, perp ...
''. * Regular problems in computational science require only ''deterministic parallelism'', that is, expecting communication from a particular
channel Channel, channels, channeling, etc., may refer to: Geography * Channel (geography), in physical geography, a landform consisting of the outline (banks) of the path of a narrow body of water. Australia * Channel Country, region of outback Austral ...
, rather than from several. * Parallel scientific algorithms can be developed in an ''elegant publication language'' and tested on a
sequential In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is called th ...
computer. When it is established an
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
works, it can easily be implemented in a parallel implementation language. These then led to the following requirements for a parallel publication language: * The language should extend a widely used standard language with ''deterministic parallelism'' and ''message communication''. The extensions should be in the spirit of the standard language. * The language should make it possible to program ''arbitrary configurations'' of parallel processes connected by communication channels. These configurations may be defined iteratively or recursively and created dynamically. * The language should enable a single-pass compiler to check that parallel processes do not interfere in a time-dependent manner.


Features

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 In computer programming, a runtime system or runtime environment is a sub-system that exists both in the computer where a program is created, as well as in the computers where the program is intended to be run. The name comes from the compile t ...
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 Recursion (adjective: ''recursive'') occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics ...
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 < max then begin open(middle); parallel node(min, left, middle) , pipeline(min + 1, max, middle, right) end end else node(min, left, right) end; 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

The most difficult aspect of concurrent programming is ''unpredictable'' or ''non-reproducible'' behaviour caused by ''time-dependent'' errors. Time-dependent errors are caused by ''interference'' between parallel processes, due to variable updates or channel conflicts. If processes sharing a variable, update it at unpredictable times, the resulting behaviour of the program is time-dependent. Similarly, if two processes simultaneously try to send or receive on a shared channel, the resulting effect is time-dependent. SuperPascal enforces certain restrictions on the use of variables and communication to minimise or eliminate time-dependent errors. With variables, a simple rule is required: parallel processes can only update disjoint sets of variables. For example, in a parallel statement a ''target'' variable cannot be updated by more than a single process, but an ''expression'' variable (which can't be updated) may be used by multiple processes. In some circumstances, when a variable such as an array is the ''target'' of multiple parallel processes, and the programmer knows its element-wise usage is ''disjoint'', then the disjointness restriction may be overridden with a preceding ic/code> statement.


Structure and syntax

SuperPascal is a block structured language, with the same basic syntax as Pascal. A program consists of a ''header'', ''global variable definitions'', ''function'' or ''procedure'' definitions and a ''main'' procedure. Functions and procedures consists of ''blocks'', where a block is a set of ''statements''. Statements are ''separated'' by semicolons, as opposed to languages like C or
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
, where they are ''terminated'' by semicolons. The following is an example of a complete SuperPascal program, which constructs a ''pipeline'' communication structure with 100 nodes. A master node sends an integer token to the first node, this is then passed along the pipeline and incremented at each step, and finally received by the master node and printed out. program pipeline; const len = 100; type channel = *(integer); var left, right: channel; value: integer; procedure node(i: integer; left, right: channel); var value: integer; begin receive(left, value); send(right, value+1) end; procedure create(left, right: channel); type row = array ..lenof channel; var c: row; i: integer; begin c := left; c en:= right; for i := 1 to len-1 do open(c ; forall i := 1 to len do node(i, c -1 c end; begin open(left, right); parallel send(left, 0) , create(left, right) , receive(right, value) end; writeln('The resulting value is ', value) end.


Implementation

The SuperPascal software can be accessed freely from the Brinch Hansen Archive. It consists of a compiler and interpreter, which are both written in normal, sequential Pascal (ISO Level 1 standard Pascal). This is supported by the GNU Pascal compiler and newer versions of the
Free Pascal Free Pascal Compiler (FPC) is a compiler for the closely related programming-language dialects Pascal and Object Pascal. It is free software released under the GNU General Public License, witexception clausesthat allow static linking against its ...
compiler (2.7.1+) with the -Miso switch, with the following respective small modifications to the code. For GPC, the file interpret.p uses the non-standard clock function (line 1786), which is used to obtain the system time. Instead, the Extended Pascal getTimeStamp function can be used (which is supported by the GNU Pascal compiler), by declaring a variable of type TimeStamp, setting that with the current time using getTimeStamp and assigning the Second field of the TimeStamp to the variable t. Regarding GPC on
64-bit In computer architecture, 64-bit integers, memory addresses, or other data units are those that are 64 bits wide. Also, 64-bit CPUs and ALUs are those that are based on processor registers, address buses, or data buses of that size. A compu ...
operating systems; the GNU Pascal compiler must be compiled and installed from
source code In computing, source code, or simply code, is any collection of code, with or without comments, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the w ...
. Free Pascal also needs a solution to the above "clock" problem (On windows, just declare gettickcount as external with "clock" as name). Further, the reset/rewrites that are marked as non-standard in the source code must be changed to assign/reset (or rewrite) pairs. (GPC probably only errors on this if you enable strict flags), and the C preprocessor commands #include 'xx' must be changed to .
Function FpTime(var tloc : integer): integer; external name 'FPC_SYSC_TIME'; procedure readtime( var t: integer); begin t:=fptime(t); end;


References


External links

* , Brinch Hansen Archive, a set of his papers and the SuperPascal software which can be downloaded in a compressed file; contains the full language specification and useful documentation. * , Christopher Long's modified version of the original SuperPascal implementation; compiles and runs under modern Free Pascal; program execution is faster than Perl 5 or 6, nearly as fast as Python 3 {{Pascal programming language family Concurrent programming languages Procedural programming languages Pascal programming language family Programming languages created in 1993