Concurrent Pascal

Last updated
Concurrent Pascal
Paradigms Imperative, structured, concurrent
Family Wirth Pascal
Designed by Per Brinch Hansen
First appearedApril 1974;47 years ago (1974-04)
Typing discipline Static and dynamic, strong, safe
Platform DEC PDP 11
Influenced by
ALGOL 60, Simula 67, 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. [1]

Contents

A separate language, Sequential Pascal, is used as the language for applications programs run by the operating systems written in Concurrent Pascal. Both languages are extensions of Niklaus Wirth's Pascal, and share a common threaded code interpreter. [2] The following describes how Concurrent Pascal differs from Wirth's Pascal.

Language description

Several constructs in Pascal were removed from Concurrent Pascal for simplicity and security: [2]

These omissions make it possible to guarantee, by a combination of compile-time checks and minimal run-time checking in the threaded-code interpreter, that a program can not damage itself or another program by addressing outside its allotted space.

Concurrent Pascal includes class, monitor, and process data types. Instances of these types are declared as variables, and initialized in an init statement.

Classes and monitors are similar: both package private variables and procedures with public procedures (called procedure entries). A class instance can be used by only one process, whereas a monitor instance may be shared by processes. Monitors provide the only mechanism for interprocess communication in a Concurrent Pascal program.

Only one process can execute within a given monitor instance at a time. A built in data type, the queue, together with operations delay and continue, are used for scheduling within monitors. Each variable of type queue can hold one process. If many processes are to be delayed in a monitor, multiple queue variables, usually organized as an array, must be provided. The single process queue variable gives a monitor full control over medium-term scheduling, but the programmer is responsible for unblocking the correct process.

A process, like a class or monitor, has local variables, procedures, and an initial statement, but has no procedure entries. The initial statement ordinarily executes forever, calling local procedures, class procedures, and monitor procedures. Processes communicate through monitor procedures. Language rules prevent deadlock by imposing a hierarchy on monitors. But nothing can prevent a monitor from erroneously forgetting to unblock a delayed process (by not calling continue) so the system can still effectively hang up through programming errors.

The configuration of processes, monitors, and classes in a Concurrent Pascal program is normally established at the start of execution, and is not changed thereafter. The communication paths between these components are established by variables passed in the init statements, since class and monitor instance variables cannot be used as procedure parameters.

Example

The following example shows the declaration of a simple monitor, and its use by two communicating processes.

type"Bounded buffer monitor"buffer=Monitorvarsaved:Integer;"saved item is an integer"fullq,emptyq:Queue;"used by only two processes"full:Boolean;"true if an item is saved:""Puts item in buffer"procedureentryput(item:Integer);beginiffullthendelay(fullq);"block if full"saved:=item;"save the item"full:=true;"mark as full"continue(emptyq)"unblock consumer"end;"Gets item from the buffer"procedureentryget(varitem:Integer);beginifnotfullthendelay(emptyq);"block if empty"item:=saved;"get the item"full:=false;"mark as not full"continue(fullq)"unblock producer"end;"Initialize the monitor"beginfull:=falseend;"Producer uses a buffer"producer=process(pass:Buffer);varitem:Integer;begincycle"execute in a loop forever""produce an item"pass.put(item)"pass an item to the monitor"endend;"Consumer uses a buffer"consumer=process(pass:Buffer);varitem:Integer;begincyclepass.get(item);"get an item from the monitor""consume the item"endend;"declare instances of the monitor, producer, and consumer""give the producer and consumer access to the monitor"varpass:Buffer;prod:Producer;cons:Consumer;begininitpass,"initialize the monitor"prod(pass),"start the producer process"cons(pass)"start the consumer process"end.

Related Research Articles

Oberon (programming language)

Oberon is a general-purpose programming language first published in 1987 by Niklaus Wirth and the latest member of the Wirthian family of ALGOL-like languages. Oberon was the result of a concentrated effort to increase the power of Modula-2, the direct successor of Pascal, and simultaneously to reduce its complexity. Its principal new feature is the concept of type extension of record types. It permits constructing new data types on the basis of existing ones and to relate them, deviating from the dogma of strictly static typing of data. Type extension is Wirth's way of inheritance reflecting the viewpoint of the parent site. Oberon was developed as part of the implementation of an operating system, also named Oberon at ETH Zurich in Switzerland. The name is from the moon of the planet Uranus, named Oberon.

Pascal (programming language) Programming language

Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named in honour of the French mathematician, philosopher and physicist Blaise Pascal.

Semaphore (programming) Variable used in a concurrent system

In computer science, a semaphore is a variable or abstract data type used to control access to a common resource by multiple processes and avoid critical section problems in a concurrent system such as a multitasking operating system. A trivial semaphore is a plain variable that is changed depending on programmer-defined conditions.

In object-oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created. This is in contrast to a mutable object, which can be modified after it is created. In some cases, an object is considered immutable even if some internally used attributes change, but the object's state appears unchanging from an external point of view. For example, an object that uses memoization to cache the results of expensive computations could still be considered an immutable object.

Modula-3

Modula-3 is a programming language conceived as a successor to an upgraded version of Modula-2 known as Modula-2+. While it has been influential in research circles it has not been adopted widely in industry. It was designed by Luca Cardelli, James Donahue, Lucille Glassman, Mick Jordan, Bill Kalsow and Greg Nelson at the Digital Equipment Corporation (DEC) Systems Research Center (SRC) and the Olivetti Research Center (ORC) in the late 1980s.

Coroutines are computer program components that generalize subroutines for non-preemptive multitasking, by allowing execution to be suspended and resumed. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes.

Oberon-2

Oberon-2 is an extension of the original Oberon programming language that adds limited reflection and object-oriented programming facilities, open arrays as pointer base types, read-only field export, and reintroduces the FOR loop from Modula-2.

Object Pascal is an extension to the programming language Pascal that provides object-oriented programming (OOP) features such as classes and methods.

Per Brinch Hansen

Per Brinch Hansen was a Danish-American computer scientist known for his work in operating systems, concurrent programming and parallel and distributed computing.

In class-based object-oriented programming, a constructor is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.

In concurrent programming, a monitor is a synchronization construct that allows threads to have both mutual exclusion and the ability to wait (block) for a certain condition to become false. Monitors also have a mechanism for signaling other threads that their condition has been met. A monitor consists of a mutex (lock) object and condition variables. A condition variable essentially is a container of threads that are waiting for a certain condition. Monitors provide a mechanism for threads to temporarily give up exclusive access in order to wait for some condition to be met, before regaining exclusive access and resuming their task.

The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.

IP Pascal is an implementation of the Pascal programming language using the IP portability platform, a multiple machine, operating system and language implementation system.

In computing, the producer–consumer problem is a classic example of a multi-process synchronization problem, the first version of which was proposed by Edsger W. Dijkstra in 1965 in his unpublished manuscript, in which the buffer was unbounded, and subsequently published with a bounded buffer in 1972. In the first version of the problem, there are two cyclic processes, a producer and a consumer, which share a common, fixed-size buffer used as a queue. The producer repeatedly generates data and writes it into the buffer. The consumer repeatedly reads the data in the buffer, removing it in the course of reading it, and using that data in some way. In the first version of the problem, with an unbounded buffer, the problem is how to design the producer and consumer code so that, in their exchange of data, no data is lost or duplicated, data is read by the consumer in the order it is written by the producer, and both processes make as much progress as possible. In the later formulation of the problem, Dijkstra proposed multiple producers and consumers sharing a finite collection of buffers. This added the additional problem of preventing producers from trying to write into buffers when all were full, and trying to prevent consumers from reading a buffer when all were empty.

Turbo51

Turbo51 is a compiler for the programming language Pascal, for the Intel MCS-51 (8051) family of microcontrollers. It features Borland Turbo Pascal 7 syntax, support for inline assembly code, source-level debugging, and optimizations, among others. The compiler is written in Object Pascal and produced with Delphi.

SuperPascal is an imperative, concurrent computing programming language developed by Per Brinch Hansen. 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.

Joyce is a secure programming language for concurrent computing designed by Per Brinch Hansen in the 1980s. It is based on the sequential language Pascal and the principles of communicating sequential processes (CSP). It was created to address the shortcomings of CSP to be applied as a programming language, and to provide a tool, mainly for teaching, for distributed computing system implementation.

Pic Micro Pascala.k.a. PMP is a free Pascal cross compiler for PIC microcontrollers. It is intended to work with the Microchip Technology MPLAB suite installed; it has its own IDE (Scintilla-based) and it is a highly optimized compiler.

Smart Pascal is a dialect of the Object Pascal computer language that is derived from Delphi Web Script, but is enhanced and adapted for Smart Mobile Studio, a commercial development suite that generates JavaScript rather than machine code.

PascalABC.NET is a Pascal programming language that implements classic Pascal, most Delphi language features, as well as a number of their own extensions. It is implemented on the .NET Framework platform and contains all the modern language features: classes, operator overloading, interfaces, exception handling, generic classes and routines, garbage collection, lambda expressions, parallel programming tools.

References

  1. Brinch Hansen, Per (June 1975). "The programming language Concurrent Pascal" (PDF). IEEE Transactions on Software Engineering (2): 199–207. doi:10.1109/tse.1975.6312840.
  2. 1 2 Brinch Hansen, Per (1977). The Architecture of Concurrent Programs. Prentice Hall. ISBN   978-0-13-044628-2.