Runtime system
Program execution |
---|
General concepts |
Types of code |
Compilation strategies |
|
Notable runtimes |
|
Notable compilers & toolchains |
|
In
Most
Overview
Every programming language specifies an
By this definition, essentially every language has a runtime system, including
), have a runtime system that implements the execution model's behavior.Most scholarly papers on runtime systems focus on the implementation details of parallel runtime systems. A notable example of a parallel runtime system is Cilk, a popular parallel programming model.[2] The proto-runtime toolkit was created to simplify the creation of parallel runtime systems.[3]
In addition to execution model behavior, a runtime system may also perform support services such as
Type | Description | Examples |
---|---|---|
Runtime environment | Software platform that provides an environment for executing code | Node.js, .NET Framework |
Engine | Component of a runtime environment that executes code by compiling or interpreting it | Java Virtual Machine
|
Interpreter | Type of engine that reads and executes code line by line, without compiling the entire program beforehand | CPython interpreter, Ruby MRI, JavaScript (in some cases) |
JIT interpreter | Type of interpreter that dynamically compiles code into machine instructions at runtime, optimizing the code for faster execution | V8, PyPy interpreter |
Relation to runtime environments
The runtime system is also the gateway through which a running program interacts with the runtime environment. The runtime environment includes not only accessible state values, but also active entities with which the program can interact during execution. For example, environment variables are features of many operating systems, and are part of the runtime environment; a running program can access them via the runtime system. Likewise, hardware devices such as disks or DVD drives are active entities that a program can interact with via a runtime system.
One unique application of a runtime environment is its use within an operating system that only allows it to run. In other words, from boot until power-down, the entire OS is dedicated to only the application(s) running within that runtime environment. Any other code that tries to run, or any failures in the application(s), will break the runtime environment. Breaking the runtime environment in turn breaks the OS, stopping all processing and requiring a reboot. If the boot is from read-only memory, an extremely secure, simple, single-mission system is created.
Examples of such directly bundled runtime systems include:
- Between 1983 and 1984,
- Some stand-alone versions of
- In the late 1990s, batch jobs in order to create unmodifiable executables from batch scripts and run them on systems without 4DOS installed.[14]
Examples
The runtime system of the C language is a particular set of instructions inserted by the compiler into the executable image. Among other things, these instructions manage the process stack, create space for local variables, and copy function call parameters onto the top of the stack.
There are often no clear criteria for determining which language behaviors are part of the runtime system itself and which can be determined by any particular source program. For example, in C, the setup of the stack is part of the runtime system. It is not determined by the semantics of an individual program because the behavior is globally invariant: it holds over all executions. This systematic behavior implements the execution model of the language, as opposed to implementing semantics of the particular program (in which text is directly translated into code that computes results).
This separation between the semantics of a particular program and the runtime environment is reflected by the different ways of compiling a program: compiling source code to an
Another example is the case of using an
As an extreme example, the physical CPU itself can be viewed as an implementation of the runtime system of a specific assembly language. In this view, the execution model is implemented by the physical CPU and memory systems. As an analogy, runtime systems for higher-level languages are themselves implemented using some other languages. This creates a hierarchy of runtime systems, with the CPU itself—or actually its logic at the microcode layer or below—acting as the lowest-level runtime system.
Advanced features
Some compiled or interpreted languages provide an interface that allows application code to interact directly with the runtime system. An example is the Thread
class in the
Higher-level behaviors implemented by a runtime system may include tasks such as drawing text on the screen or making an Internet connection. It is often the case that operating systems provide these kinds of behaviors as well, and when available, the runtime system is implemented as an abstraction layer that translates the invocation of the runtime system into an invocation of the operating system. This hides the complexity or variations in the services offered by different operating systems. This also implies that the OS kernel can itself be viewed as a runtime system, and that the set of OS calls that invoke OS behaviors may be viewed as interactions with a runtime system.
In the limit, the runtime system may provide services such as a
A modern aspect of runtime systems is parallel execution behaviors, such as the behaviors exhibited by mutex constructs in Pthreads and parallel section constructs in OpenMP. A runtime system with such parallel execution behaviors may be modularized according to the proto-runtime approach.
History
Notable early examples of runtime systems are the interpreters for BASIC and Lisp. These environments also included a garbage collector. Forth is an early example of a language designed to be compiled into intermediate representation code; its runtime system was a virtual machine that interpreted that code. Another popular, if theoretical, example is Donald Knuth's MIX computer.
In C and later languages that supported dynamic memory allocation, the runtime system also included a library that managed the program's memory pool.
In the
See also
- Execution model
- Programming model
- Runtime (program lifecycle phase)
- Self-booter
- Static build
References
- ^ ISBN 978-0-321-48681-3.
The compiler must cooperate with the operating system and other systems software to support these abstractions on the target machine.
- S2CID 221936412.
- ^ Open Source Research Institute (2011). "Welcome to the Proto-Runtime Toolkit Home Page". The Proto-Runtime Toolkit (PRT). Archived from the original on 2020-02-11. Retrieved 2020-01-11.
- Appel, Andrew Wilson (May 1989). "A Runtime System" (PDF). Princeton University. Archived from the original(PDF) on 2013-12-30. Retrieved 2013-12-30.
- Concurrent CP/MOperating System. […]
- SpeedStart CP/M, an abridged version of CP/M that boots automatically when the system is turned on. […] [1]
- ISSN 0745-2500. Archived from the originalon 2020-02-11. Retrieved 2020-02-11.
- Concurrent CP/M. […]
- ^ ventura publisher. […]
- ^ Elliott, John C. (1999-05-09). "A comparison between GEM and ViewMAX". Seasip.info. Archived from the original on 2016-11-07. Retrieved 2016-11-07.
- ^ Paul, Matthias R. (1997-04-13) [1993]. DRDOS6UN.TXT — Zusammenfassung der dokumentierten und undokumentierten Fähigkeiten von DR DOS 6.0 (in German) (60 ed.). Archived from the original on 2016-11-07. Retrieved 2016-11-07.
{{cite book}}
:|work=
ignored (help) - ^ Paul, Matthias R. (1997-06-07) [1994]. NWDOS7UN.TXT — Zusammenfassung der dokumentierten und undokumentierten Fähigkeiten von Novell DOS 7 (in German) (85 ed.). Archived from the original on 2016-11-07. Retrieved 2016-11-07.
{{cite book}}
:|work=
ignored (help) - ^ Georgiev, Luchezar I. (2008-11-02). "Runtime version of 4DOS, BATCOMP and batch file encryption". Narkive Newsgroup Archive. Newsgroup: comp.os.msdos.4dos. Archived from the original on 2020-01-11. Retrieved 2020-01-11.
Further reading
- "NAME ENTX - Microsoft MS-DOS Computer Pascal runtime system control". 1.00. Microsoft Corp. 1981. Archivedfrom the original on 2018-09-23. Retrieved 2018-09-23.
External links
- The dictionary definition of run-time at Wiktionary