Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

SuperPascal

From Wikipedia, the free encyclopedia
Programming language
icon
This articlerelies excessively onreferences toprimary sources. Please improve this article by addingsecondary or tertiary sources.
Find sources: "SuperPascal" – news ·newspapers ·books ·scholar ·JSTOR
(June 2018) (Learn how and when to remove this message)
SuperPascal
Paradigmconcurrent,imperative,structured
FamilyWirthPascal
Designed byPer Brinch Hansen
First appeared1993; 33 years ago (1993)
Stable release
1 / 1993; 33 years ago (1993)
Typing disciplineStrong
Websitebrinch-hansen.net
Influenced by
Communicating sequential processes,Pascal,Concurrent Pascal,Joyce,occam

SuperPascal is an imperative,concurrent computingprogramming language developed byPer Brinch Hansen.[1] It was designed as apublication 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

[edit]

SuperPascal is based onNiklaus Wirth's sequential languagePascal, 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 teachstructured programming practices and featured in text books, for example, oncompilers[2] and programming languages.[3] Hansen had earlier developed the languageConcurrent Pascal,[4] one of the earliest concurrent languages for the design ofoperating systems andreal-time 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 incomputer science.[5] This experimentation allowed him to make the following conclusions about the future of scientificparallel computing:

  • Future parallel computers will begeneral-purpose, allowing programmers to think in terms ofproblem-oriented process configurations. This was based on his experience programming networks oftransputers, which were general-purposeprocessors able to be connected inarrays,trees orhypercubes.
  • Regular problems in computational science require onlydeterministic parallelism, that is, expecting communication from a particularchannel, rather than from several.
  • Parallel scientific algorithms can be developed in anelegant publication language and tested on asequential computer. When it is established analgorithm 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 withdeterministic parallelism andmessage communication. The extensions should be in the spirit of the standard language.
  • The language should make it possible to programarbitrary configurations of parallel processes connected by communication channels. These configurations may be defined iteratively or recursively and created dynamically.
  • The language should enable asingle-pass compiler to check that parallel processes do not interfere in a time-dependent manner.

Features

[edit]

The key ideas in the design of SuperPascal was to provide asecure programming, with abstract concepts for parallelism.[6][7]

Security

[edit]
Further information:Defensive programming

SuperPascal issecure in that it should enable its compiler andruntime system to detect as many cases as possible in which the language concepts break down and produce meaningless results.[8] 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 andgoto statements, pointers and forward declarations.[6]

Parallelism

[edit]

The parallel features of SuperPascal are a subset ofoccam 2, with the added generality of dynamic process arrays and recursive parallel processes.[7]

Aparallel statement denotes that the fixed number of statements it contains must be executed in parallel. For example:

parallel    source() |    sink()end

Aforall 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

[edit]

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 thechannel reference, which are held bychannel variables. A channel is declared, for example, by the declaration

typechannel=*(boolean,integer);varc:channel;

which defines a new (mixed) type namedchannel and a variable of this type namedc. A mixed type channel is restricted to transmitting only the specified types, in this case boolean and integer values. The channelc is initialised by theopen statement:

open(c)

Message communication is then achieved with thesend(channel, value) andreceive(channel, variable) statements. The expression or variable providing the value forsend, and the variable inreceive, 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 theleft channel and outputs it on theright one.

varleft,right:channel;a:number;receive(left,a);send(right,a)

The functionssend andreceive can both take multiple input and output arguments respectively:

send(channel, e1, e2,..., en);receive(channel, v1, v2,..., vn)

The followingruntime communication errors can occur:

  • Channel contention occurs when two parallel processes both attempt to send or receive on the same channel simultaneously.
  • Amessage 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

[edit]
Further information:Recursion (computer science)

Recursive procedures can be combined withparallel andforall statements to create parallel recursive processes. The following example shows how apipeline of processes can be recursively defined using aparallel statement.

procedurepipeline(min,max:integer;left,right:channel);varmiddle:channel;beginifmin<maxthenbeginopen(middle);parallelnode(min,left,middle)|pipeline(min+1,max,middle,right)endendelsenode(min,left,right)end;

Another example is the recursive definition of a processtree:

proceduretree(depth:integer,bottom:channel);varleft,right:channel;beginifdepth>0thenbeginopen(left,right);paralleltree(depth-1,left)|tree(depth-1,right)|root(bottom,left,right)endendelseleaf(bottom)

Interference control

[edit]

The most difficult aspect of concurrent programming isunpredictable ornon-reproducible behaviour caused bytime-dependent errors. Time-dependent errors are caused byinterference 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.[1] For example, in aparallel statement atarget variable cannot be updated by more than a single process, but anexpression variable (which can't be updated) may be used by multiple processes. In some circumstances, when a variable such as an array is thetarget of multiple parallel processes, and the programmer knows its element-wise usage isdisjoint, then the disjointness restriction may be overridden with a preceding[sic] statement.

Structure and syntax

[edit]

SuperPascal is ablock structured language, with the same basic syntax as Pascal. A program consists of aheader,global variable definitions,function orprocedure definitions and amain procedure. Functions and procedures consists ofblocks, where a block is a set ofstatements. Statements areseparated by semicolons, as opposed to languages likeC orJava, where they areterminated by semicolons.

The following is an example of a complete SuperPascal program, which constructs apipeline 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.

programpipeline;constlen=100;typechannel=*(integer);varleft,right:channel;value:integer;procedurenode(i:integer;left,right:channel);varvalue:integer;beginreceive(left,value);send(right,value+1)end;procedurecreate(left,right:channel);typerow=array[0..len]ofchannel;varc:row;i:integer;beginc[0]:=left;c[len]:=right;fori:=1tolen-1doopen(c[i]);foralli:=1tolendonode(i,c[i-1],c[i])end;beginopen(left,right);parallelsend(left,0)|create(left,right)|receive(right,value)end;writeln('The resulting value is ',value)end.

Implementation

[edit]

The SuperPascal software can be accessed freely from the Brinch Hansen Archive.[9] 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 theFree Pascal compiler (2.7.1+) with the-Miso switch, with the following respective small modifications to the code.

For GPC, the fileinterpret.p uses the non-standardclock function (line 1786), which is used to obtain the system time. Instead, the Extended PascalgetTimeStamp function can be used (which is supported by the GNU Pascal compiler), by declaring a variable of typeTimeStamp, setting that with the current time usinggetTimeStamp and assigning theSecond field of theTimeStamp to the variablet.

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 {$include 'xx'}.

{ Time code for readtime in Freepascal on unix systems }FunctionFpTime(vartloc:integer):integer;externalname'FPC_SYSC_TIME';procedurereadtime(vart:integer);begin{ A nonstandard function reads    the processor time in ms }t:=fptime(t);end;

References

[edit]
  1. ^abHansen, Per Brinch (1993),SuperPascal: a publication language for parallel scientific computing
  2. ^Welsh, Jim (1980).Structured System Programming. Upper Saddle River, NJ, USA: Prentice-Hall.ISBN 0-13-854562-6.
  3. ^Tennent, R. D. (1981).Principles of Programming Languages. Upper Saddle River, NJ, USA: Prentice-Hall.ISBN 0-13-709873-1.
  4. ^Hansen, Brinch (1977).The Architecture of Concurrent Programs. Prentice-Hall.ISBN 978-0130446282.
  5. ^Hansen, Brinch (May 1993), "Model programs for computational science: A programming methodology for multicomputers",Concurrency: Practice and Experience, pp. 407–423
  6. ^abHansen, Brinch (1994). "The programming language SuperPascal".Software: Practice and Experience.24, 5:399–406.
  7. ^abHansen, Brinch (1977).The invention of concurrent programming. New York: Springer-Verlag.ISBN 0-387-95401-5.
  8. ^Hoare, C. A. R. (1974). "Hints on programming language design".Computer System Reliability:505–534.
  9. ^Hayden, C.C. (2008-06-11)."Per Brinch Hansen Archive". Retrieved2020-03-03.

External links

[edit]
  • Official website, 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.
  • superpascal onGitHub, 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
Dialects
Compilers
Current
Discontinued
API
Microcomputer
Comparisons
Designer
Related to
ALGOL (1958)
Modula-2 (1977)
Ada (1983)
Oberon (1986)
Modula-3 (1988)
Oberon-2 (1991)
Component Pascal (1991)
Retrieved from "https://en.wikipedia.org/w/index.php?title=SuperPascal&oldid=1207422957"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp