Execution (computing): Difference between revisions

Content deleted Content added
m Minor formatting fix
Citation bot (talk | contribs)
Removed URL that duplicated identifier. | Use this bot. Report bugs. | #UCB_CommandLine
 
(26 intermediate revisions by 16 users not shown)
Line 2:
{{Program execution}}
 
'''Execution''' in [[computer engineering|computer]] and software engineering is the process by which a [[computer]] or [[virtual machine]] readsinterprets 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.
Line 10:
== 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 ==
Line 25:
{{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 systemssystem]] 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 processesprocess'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.
Line 44:
== 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"/>