Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Execution (computing)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Running of a program by a computer}} {{Program execution}} '''Execution''' in [[computer engineering|computer]] and software engineering is the process by which a [[computer]] or [[virtual machine]] interprets and acts on the instructions of a [[computer program]]. Each instruction of a program is a description of a particular action which must be carried out, in order for a specific problem to be solved. Execution involves repeatedly following a "[[Instruction cycle|fetch–decode–execute]]" cycle for each instruction done by the [[control unit]]. As the executing machine follows the instructions, specific effects are produced in accordance with the [[Formal semantics of programming languages|semantics]] of those instructions. Programs for a computer may be executed in a [[Batch processing|batch process]] without human interaction or a [[User (computing)|user]] may type [[Command (computing)|commands]] in an [[Session (computer science)|interactive session]] of an [[Interpreter (computing)|interpreter]]. In this case, the "commands" are simply program instructions, whose execution is chained together. The term '''run''' is used almost synonymously. A related meaning of both "to run" and "to execute" refers to the specific action of a user starting (or ''launching'' or ''invoking'') a program, as in "Please run the application." == Process == {{see|Program lifecycle phase}} Prior to execution, a program must first be written. This is generally done in [[source code]], which is then compiled at [[compile time]] (and statically linked at [[link time]]) to produce an executable. This executable is then invoked, most often by an operating system, which loads the program into memory ([[load time]]), possibly performs [[dynamic linking]], and then begins execution by moving control to the [[entry point]] of the program; all these steps depend on the [[Application Binary Interface]] of the operating system. At this point execution begins and the program enters [[run time (program lifecycle phase)|run time]]. The program then runs until it ends, either in a normal [[termination (computer science)|termination]] or a [[crash (computing)|crash]]. == Executable == {{main|Executable}} ''Executable code'', an ''executable file'', or an ''executable program'', sometimes simply referred to as an ''executable'' or ''binary'', is a list of instructions and data to cause a computer "to perform indicated tasks according to encoded [[instruction (computer science)|instructions]]",<ref>{{cite web |url=http://www.merriam-webster.com/dictionary/executable |title=executable |access-date=2008-07-19 |work=Merriam-Webster's Online Dictionary |publisher=[[Merriam-Webster]]}}</ref> as opposed to a [[Data (computing)|data file]] that must be interpreted ([[parser|parsed]]) by a program to be meaningful. The exact interpretation depends upon the use. "Instructions" is traditionally taken to mean [[machine code]] instructions for a physical [[Central processing unit|CPU]].<ref>{{Cite web|url=https://www.geeksforgeeks.org/machine-instructions/|title=Machine Instructions|date=2015-11-03|website=GeeksforGeeks|language=en-US|access-date=2019-09-18}}</ref> In some contexts, a file containing scripting instructions (such as [[bytecode]]) may also be considered executable. == Context of execution == The context in which execution takes place is crucial. Very few programs execute on a [[bare machine]]. Programs usually contain implicit and explicit assumptions about resources available at the time of execution. Most programs execute within [[Computer multitasking|multitasking]] [[operating system]] and [[Runtime library|run-time libraries]] specific to the source language that provide crucial services not supplied directly by the computer itself. This supportive environment, for instance, usually decouples a program from direct manipulation of the computer peripherals, providing more general, abstract services instead. === Context switching === {{Main|Context switch}} In order for programs and [[interrupt handler]]s to work without interference and share the same hardware memory and access to the I/O system, in a [[Computer multitasking|multitasking operating system]] running on a digital system with a single CPU/MCU, it is required to have some sort of software and hardware facilities to keep track of an executing process's data (memory page addresses, registers etc.) and to save and recover them back to the state they were in before they were suspended. This is achieved by a context switching.<ref name=":0">{{Cite book |last=Bovet |first=Daniel P. |url=https://www.worldcat.org/oclc/64549743 |title=Understanding the Linux Kernel |date=2005 |publisher=O'Reilly |others=Marco Cesati |isbn=0-596-00565-2 |edition=3 |location=Sevastopol, CA |oclc=64549743}}</ref>{{Rp|location=3.3}}<ref>{{Cite web |date=2021-06-10 |title=Difference between Swapping and Context Switching |url=https://www.geeksforgeeks.org/difference-between-swapping-and-context-switching/ |access-date=2022-08-10 |website=GeeksforGeeks |language=en-us}}</ref> The running programs are often assigned a [[Process-context identifier|Process Context IDentifiers]] (PCID). In Linux-based operating systems, a set of data stored in [[Processor register|registers]] is usually saved into a process descriptor in memory to implement switching of context.<ref name=":0" /> PCIDs are also used. ==Runtime== '''Runtime''', '''run time''', or '''execution time''' is the final phase of a [[computer program]]{{'}}s [[Program lifecycle phase|life cycle]], in which the code is being executed on the computer's [[central processing unit]] (CPU) as [[machine code]]. In other words, "runtime" is the running phase of a program. A [[Runtime error detection|runtime error is detected]] after or during the execution (running state) of a program, whereas a [[Compile time|compile-time]] error is detected by the [[compiler]] before the program is ever executed. [[Type checking]], [[register allocation]], [[code generation (compiler)|code generation]], and code optimization are typically done at compile time, but may be done at runtime depending on the particular language and compiler. Many other runtime errors exist and are handled differently by different [[Programming language|programming languages]], such as [[division by zero]] errors, domain errors, [[Bounds checking|array subscript out of bounds]] errors, [[arithmetic underflow]] errors, several types of underflow and [[overflow (disambiguation)|overflow]] errors, and many other runtime errors generally considered as software bugs which may or may not be caught and handled by any particular computer language. === Implementation details === When a program is to be executed, a [[loader (computing)|loader]] first performs the necessary [[memory (computers)|memory]] setup and links the program with any [[dynamic linking|dynamically linked]] [[software library|libraries]] it needs, and then the execution begins starting from the program's [[entry point]]. In some cases, a language or implementation will have these tasks done by the language runtime instead, though this is unusual in mainstream languages on common consumer operating systems. Some program debugging can only be performed (or is more efficient or accurate when performed) at runtime. [[Logic error]]s and [[array data structure|array]] bounds checking are examples. For this reason, some programming [[software bug|bugs]] are not discovered until the program is tested in a [[production environment]] with real data, despite sophisticated compile-time checking and pre-release testing. In this case, the end-user may encounter a "runtime error" message. === Application errors (exceptions) === [[Exception handling]] is one language feature designed to handle runtime errors, providing a structured way to catch completely unexpected situations as well as predictable errors or unusual results without the amount of inline error checking required of languages without it. More recent advancements in runtime engines enable [[automated exception handling]] which provides "root-cause" debug information for every exception of interest and is implemented independent of the source code, by attaching a special software product to the runtime engine. == Runtime system == {{main|Runtime system}} A ''runtime system'', also called ''runtime environment'', primarily implements portions of an [[execution model]].{{what|date=May 2020|reason=<!-- please provide reason if after this Jan-2021-update clarification is still needed -->}} This is not to be confused with the [[Run time (program lifecycle phase)|runtime]] lifecycle phase of a program, during which the runtime system is in operation. <!--Jan-2021-update begin attempting to clarify the {{what}} template-->When treating the ''runtime system'' as distinct from the ''runtime environment'' (RTE), the first may be defined as a specific part of the [[Integrated development environment|application software (IDE) used for programming]], a piece of software that provides the programmer a more convenient environment for running programs during their production ([[Software testing|testing]] and similar), while the second (RTE) would be the very [[Instance (computer science)|instance]] of an execution model being applied to the developed program which is itself then run in the aforementioned ''runtime system''.<!--hope this and previous sentence from Jan-2021-update helps (if true): "Some computer systems for security or other reasons have just the runtime environment, allowing to run just one application during the entire course of power-on cycle, so even though their algorithm might include the code of a complete operating system, such a computer - with a huge OS which is then booted in its entirety and afterwards executes this single application - such a computer system is actually without a runtime system and thus in effect performing a single program but considered having or being a runtime environment" Jan-2021-update end--> Most [[programming language]]s have some form of runtime system that provides an environment in which programs run. This environment may address a number of issues including the [[memory management|management]] of application [[computer memory|memory]], how the program accesses [[variable (computer science)|variable]]s, mechanisms for passing parameters between [[subroutine|procedure]]s, interfacing with the [[operating system]], 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 (abstract data type)|stack]] and [[heap (data structure)|heap]], and may include features such as [[garbage collection (computer science)|garbage collection]], [[thread (computing)|thread]]s or other [[dynamic programming language|dynamic]] features built into the language.<ref name="Aho_2007"/> ==Instruction cycle== {{main|Instruction cycle}} The ''instruction cycle'' (also known as the ''fetch–decode–execute cycle'', or simply the ''fetch-execute cycle'') is the cycle that the [[central processing unit]] (CPU) follows from [[booting|boot-up]] until the computer has shut down in order to process instructions. It is composed of three main stages: the fetch stage, the decode stage, and the execute stage. [[File:Fetch-Decode-Execute Cycle.png|thumb|This is a simple diagram illustrating the individual stages of the fetch-decode-execute cycle.]] In simpler CPUs, the instruction cycle is executed sequentially, each instruction being processed before the next one is started. In most modern CPUs, the instruction cycles are instead executed [[concurrent computing|concurrently]], and often in [[parallel computing|parallel]], through an [[instruction pipeline]]: the next instruction starts being processed before the previous instruction has finished, which is possible because the cycle is broken up into separate steps.<ref>{{cite web |title=Pipelining |url=https://cs.stanford.edu/people/eroberts/courses/soco/projects/risc/pipelining/index.html |author=Crystal Chen, Greg Novick and Kirk Shimano |year=2000 |access-date=2019-06-26}}</ref> == Interpreter == {{Main|Interpreter (computing)}} A system that executes a program is called an [[Interpreter (computing)|interpreter]] of the program. Loosely speaking, an interpreter directly executes a program. This contrasts with a language [[Translator (computing)|translator]] that converts a program from one language to another before it is executed. == Virtual machine == {{main|Virtual machine}} A ''virtual machine'' (''VM'') is the [[virtualization]]/[[emulator|emulation]] of a [[computer system]]. Virtual machines are based on [[computer architecture]]s and provide functionality of a physical computer. Their implementations may involve specialized hardware, software, or a combination. Virtual machines differ and are organized by their function, shown here: * '''[[System virtual machine]]s''' (also termed [[full virtualization]] VMs) provide a substitute for a real machine. They provide functionality needed to execute entire [[operating system]]s. A [[hypervisor]] uses [[native code|native execution]] to share and manage hardware, allowing for multiple environments which are isolated from one another, yet exist on the same physical machine. Modern hypervisors use [[hardware-assisted virtualization]], virtualization-specific hardware, primarily from the host CPUs. * '''Process virtual machines''' are designed to execute computer programs in a platform-independent environment. Some virtual machine emulators, such as [[QEMU]] and [[video game console emulator]]s, are designed to also emulate (or "virtually imitate") different system architectures thus allowing execution of software applications and operating systems written for another [[CPU]] or architecture. [[OS-level virtualization]] allows the resources of a computer to be partitioned via the [[Kernel (operating system)|kernel]]. The terms are not universally interchangeable. == See also == * [[Executable]] * [[Run-time system]] * [[Run time (program lifecycle phase)|Runtime program phase]] * [[Program counter]] ==References== {{Reflist|refs= <ref name="Aho_2007">{{cite book |author-last1=Aho |author-first1=Alfred V. |author-link1=Alfred V. Aho |author-last2=Lam |author-first2=Monica Sin-Ling |author-link2=Monica Sin-Ling Lam |author-last3=Sethi |author-first3=Ravi |author-link3=Ravi Sethi |author-last4=Ullman |author-first4=Jeffrey David |author-link4=Jeffrey David Ullman |title=Compilers: Principles, Techniques and Tools |date=2007 |publisher=[[Pearson Education]] |location=Boston, MA, US |isbn=978-0-321-48681-3 |page=[https://archive.org/details/compilers00alfr_0/page/427 427] |edition=2nd |url-access=registration |url=https://archive.org/details/compilers00alfr_0/page/427}}</ref>}} {{CPU_technologies}} {{DEFAULTSORT:Execution (Computing)}} [[Category:Computing terminology]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:'
(
edit
)
Template:CPU technologies
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Main
(
edit
)
Template:Program execution
(
edit
)
Template:Reflist
(
edit
)
Template:Rp
(
edit
)
Template:See
(
edit
)
Template:Short description
(
edit
)
Template:What
(
edit
)