Execution model: Difference between revisions

Content deleted Content added
Bluelinking 1 books for verifiability.) #IABot (v2.1alpha3
Kshalle (talk | contribs)
No edit summary
Line 1:
{{Program execution}}
 
A programming language consists of a grammar/syntax plus an '''execution model'''. The execution model specifies the behavior of elements of the language. By applying itthe execution model, one can derive the behavior of a program that was written in terms of that programming language. For example, [[Operational_semantics| Operational Semantics]] is one method of specifyingwhen a language'sprogrammer execution"reads" model.code, Thein observedtheir behaviormind, ofthey awalk running program must match the behavior derived from the execution model. An execution model covers things such asthrough what iseach an indivisible unitline of work,code anddoes. what areIn theeffect constraintsthey onsimulate the orderbehavior ininside whichtheir those units of work take placemind. For example,What the additionprogrammer operationis doing is anapplying indivisiblethe unitexecution ofmodel workto inthe many languagescode, andwhich results in sequentialthe languages such unitsbehavior of work are constrained to take place one after the othercode.
 
[[Operational_semantics| Operational Semantics]] is one method of specifying a language's execution model. The observed behavior of a running program must match the behavior derived from the operational semantics (which define the execution model of the language).
In particular, the [[C (programming language)|C programming language]], has a concept called a statement. The language specification defines a statement as a chunk of syntax that is terminated by a ";". The language spec then says that execution of the program proceeds statement by statement, which tells us something about the execution model of the language. It tells us that statements are indivisible units of work and that they proceed in the same order as their syntactic appearance in the code (except when a control statement such as IF or WHILE modifies the order). By stating the order in which statements are executed, the language spec has stated constraints on the order of performing units of work. The C language actually has an additional level to its execution model, which is the order of precedence. It states the rules for the order of operations within a single statement. The order of precedence can be viewed as stating the constraints on performing the units of work that are within a single statement. So, ";" and "IF" and "WHILE" cover constraints on the order of statements, while order of precedence covers constraints on work within a statement. Hence, these parts of the C language specification are stating the execution model of the C language.
 
An execution model covers things such as what is an indivisible unit of work, and what are the constraints on the order in which those units of work may take place. For example, the addition operation is an indivisible unit of work in many languages, and in sequential languages such units of work are constrained to take place one after the other.
 
InTo particularillustrate this, consider the [[C (programming language)|C programming language]], which has a concept called a statement. The language specification defines a statement as a chunk of syntax that is terminated by a ";". The language spec then says that "execution of the program proceeds one statement byafter the other, in sequence". Those words: "execution of the program proceeds one statement after the other, whichin tellssequence" usare somethingone aboutpiece of the execution model of theC! language. ItThose words tells us that statements are indivisible units of work and that they proceed in the same order as their syntactic appearance in the code (except when a control statement such as IF or WHILEFOR modifies the order). By stating the order in which statements are executed, the language spec has stated constraints on the order of performing units of work. The C language actually has an additional level to itsthat "execution model, which is the order of precedence. It states the rulesprogram forproceeds the order of operations within a singleone statement. The order of precedence can be viewed as statingafter the constraintsother, onin performingsequence", the unitsprogramming ofmodel workhas that are within a single statement. So, ";" and "IF" and "WHILE" coverstated constraints on the order of statements,performing while orderunits of precedence covers constraints on work within a statement. Hence, these parts of the C language specification are stating the execution model of the C language.
 
The C language actually has an additional level to its execution model, which is the order of precedence. Order of precedence states the rules for the order of operations within a single statement. The order of precedence can be viewed as stating the constraints on performing the units of work that are within a single statement. So, ";" and "IF" and "WHILE" cover constraints on the order of statements, while order of precedence covers constraints on work within a statement. Hence, these parts of the C language specification are also part of the execution model of the C language.
 
Execution models can also exist independently from programming languages, examples of which would be the [[POSIX Threads]] library, and Hadoop's Map-Reduce [[programming model]]. The implementation of an execution model can be via [[compiler]], or [[Interpreter_(computing)|interpreter]], and often includes a [[runtime system]].
Line 50 ⟶ 56:
| format=PDF
}}</ref>
 
== Execution model of assembly language versus implementation by micro-architectures ==
 
Assembly languages also have execution models, the same as any other language. Such an execution model is implemented by a CPU micro-architecture. For example, both a 5 stage in-order pipeline and a large out of order CPU implement the same assembly language execution model. The execution model is the definition of the behavior, so all implementations, whether in-order or out-of-order or interpreted or JIT'd etc.. must all give the exact same result, and that result is defined by the execution model.
 
== Overview ==