Runtime system

Source: Wikipedia, the free encyclopedia.

In

runtime division from compiled languages, which similarly distinguishes the computer processes involved in the creation of a program (compilation) and its execution in the target machine (the runtime).[1]

Most

procedures, interfacing with the operating system (OS), and otherwise. The compiler makes assumptions depending on the specific runtime system to generate correct code. Typically the runtime system will have some responsibility for setting up and managing the stack and heap, and may include features such as garbage collection, threads or other dynamic features built into the language.[1]

Overview

Every programming language specifies an

I/O
.

By this definition, essentially every language has a runtime system, including

API-invoked standalone execution models, such as Pthreads (POSIX threads
), 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

optimization.[4]

comparison between concepts similar to runtime system
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:

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

linking. On the other hand, the code in the object file still depends on assumptions in the runtime system; for example, a function may read parameters from a particular register or stack location, depending on the calling convention
used by the runtime environment.

Another example is the case of using an

software library
, however at some point during the call the execution model changes. The runtime system implements an execution model different from that of the language the library is written in terms of. A person reading the code of a normal library would be able to understand the library's behavior by just knowing the language the library was written in. However, a person reading the code of the API that invokes a runtime system would not be able to understand the behavior of the API call just by knowing the language the call was written in. At some point, via some mechanism, the execution model stops being that of the language the call is written in and switches over to being the execution model implemented by the runtime system. For example, the trap instruction is one method of switching execution models. This difference is what distinguishes an API-invoked execution model, such as Pthreads, from a usual software library. Both Pthreads calls and software library calls are invoked via an API, but Pthreads behavior cannot be understood in terms of the language of the call. Rather, Pthreads calls bring into play an outside execution model, which is implemented by the Pthreads runtime system (this runtime system is often the OS kernel).

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

resource management
are not accessible in this fashion.

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

interpreted languages such as AWK, and some languages like Java, which are meant to be compiled into some machine-independent intermediate representation code (such as bytecode). This arrangement simplifies the task of language implementation and its adaptation to different machines, and improves efficiency of sophisticated language features such as reflective programming. It also allows the same program to be executed on any machine without an explicit recompiling step, a feature that has become very important since the proliferation of the World Wide Web. To speed up execution, some runtime systems feature just-in-time compilation
to machine code.

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

object-oriented programming languages
, the runtime system was often also responsible for dynamic type checking and resolving method references.

See also

References

  1. ^ . The compiler must cooperate with the operating system and other systems software to support these abstractions on the target machine.
  2. .
  3. ^ 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.
  4. Appel, Andrew Wilson (May 1989). "A Runtime System" (PDF). Princeton University. Archived from the original
    (PDF) on 2013-12-30. Retrieved 2013-12-30.
  5. Concurrent CP/M
    Operating System. […]
  6. SpeedStart CP/M, an abridged version of CP/M that boots automatically when the system is turned on. […] [1]
  7. BYTE (Advertisement). Vol. 9, no. 2. pp. 216–217. Retrieved 2013-10-22. [2][3]
  8. ISSN 0745-2500. Archived from the original
    on 2020-02-11. Retrieved 2020-02-11.
  9. Concurrent CP/M
    . […]
  10. ^
    ventura publisher
    . […]
  11. ^ 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.
  12. ^ 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)
  13. ^ 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)
  14. ^ Georgiev, Luchezar I. (2008-11-02). "Runtime version of 4DOS, BATCOMP and batch file encryption". Narkive Newsgroup Archive. Newsgroupcomp.os.msdos.4dos. Archived from the original on 2020-01-11. Retrieved 2020-01-11.

Further reading

External links

  • The dictionary definition of run-time at Wiktionary