Execution model: Difference between revisions

Content deleted Content added
Fjares (talk | contribs)
m Overview: Fix typo in the name of Brian Kernighan (not Kernihan)
added clarity to the wording
Line 3:
An '''execution model''' specifies how work takes place. Every programming language has an execution model, which is specified as part of the language specification, and is implemented as part of the language implementation. Execution models can also exist independently from programming languages, an example of which would be the [[POSIX Threads]] library. The details in the specification of an execution model cover things such as what is an indivisible unit of work and what are the constraints on the order in which those units of work 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.
 
In particular, the [[C (programming language)|C programming language]], defineshas statements,a whichconcept arecalled a statement. The spec says that a statement is a chunk of syntax that is terminated by a ";". ThisThe canlanguage bespec viewedthen assays definingthat one levelexecution of indivisiblethe unitprogram proceeds statement by statement, which tells us something about the execution model of workthe language. TheIt languagetells specus goesthat onstatements toare sayindivisible units of work and that statementsthey proceed in- the same order. as Thistheir cansyntactic beappearance viewedin the code (except when a control statement such as definingIF 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 those units of work. ItThe alsoC language actually has an additional level to its execution model, which specifiesis the order of precedence,. which canIt bestates viewedthe asrules definingfor anotherthe levelorder of indivisibleoperations workwithin unit,a whilesingle atstatement. the sameThe timeorder of precedence can be viewed as stating the constraints on performing the orderunits of performingwork thosethat workare unitswithin 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, andthese ";"parts coversof constraintsthe onC language specification are stating the orderexecution model of thosethe statementsC language.
 
An implementation of an execution model controls the order in which work takes place during execution. This order may be chosen ahead of time, in some situations, or it can be dynamically determined as the execution proceeds. Most execution models allow varying degrees of both. For example, the C language fixes the order of work within a statement and it fixes the order of all statements, except ones that involve an IF statement or a form of loop statement. Hence, most of the order of execution may be chosen statically, before execution begins, but a small portion must be chosen dynamically, as execution proceeds.