Execution model: Difference between revisions

Content deleted Content added
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{short description|Behavioral rules for all elements of a programming language}}
{{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 the execution model, one can derive the behavior of a program that was written in terms of that programming language. For example, when a programmer "reads" code, in their mind, they walk through what each line of code does. In effect they simulate the behavior inside their mind. What the programmer is doing is applying the execution model to the code, which results in the behavior of the code.
 
AIn [[computing]], a [[programming language]] consists of a grammar/[[Syntax (programming languages)|syntax]] plus an '''execution model'''. The execution model specifies the behavior of elements of the language. By applying the execution model, one can derive the behavior of a [[Computer program|program]] that was written in terms of that programming language. For example, when a programmer "reads" code, in their mind, they walk through what each line of code does. In effect they simulate the behavior inside their mind. What the programmer is doing is applying the execution model to the code, which results in the behavior of the code.
Each and every programming language has an execution model, which determines the manner in which the units of work (that are indicated by program [[Syntax (programming languages)|syntax]]) are [[Scheduling (computing)|scheduled]] for [[Execution (computing)|execution]]. Detailed examples of the specification of execution models of a few popular languages include those of [[Python (programming language)|Python]],<ref>
 
Each and every programming language has an execution model, which determines the manner in which the units of work (that are indicated by program [[Syntax (programming languages)|syntax]]) are [[Scheduling (computing)|scheduled]] for [[Execution (computing)|execution]]. Detailed examples of the specification of execution models of a few popular languages include those of [[Python (programming language)|Python]],<ref>
{{cite web
| url=https://docs.python.org/3/reference/executionmodel.html
Line 22 ⟶ 24:
| publisher=Springer US
}}</ref>
and an article discussing execution models for [[Real-time computing|real-time embedded]] languages.<ref>{{cite journal
{{cite journal
| url=http://pertsserver.cs.uiuc.edu/~mcaccamo/papers/PREM_rtas11.pdf
| title=A Predictable Execution Model for COTS-based Embedded Systems
Line 37 ⟶ 38:
| publisher=IEEE
| journal=Real-Time and Embedded Technology and Applications Symposium
| access-date=2015-05-20
| archive-date=2017-08-12
| archive-url=https://web.archive.org/web/20170812100818/http://pertsserver.cs.uiuc.edu/~mcaccamo/papers/PREM_rtas11.pdf
| url-status=dead
}}</ref>
 
Line 77 ⟶ 82:
The complication comes from the fact that the execution model does not have any means for the execution of "give up ownership of the lock" to have any influence over which execution of "gain ownership of the lock" in some other timeline (thread) follows. Very often, only certain handoffs give valid results. Thus, the programmer must think of all possible combinations of one thread giving up a lock and another thread getting it next, and make sure their code only allows valid combinations.
 
Note that theThe only effect is that A-post-gain-lock statements come before B-post-gain-lock statements. No other effect happens, and no other relative ordering can be relied upon. Specifically, A-post-give-up-lock and B-post-gain-lock have ''no relative ordering'' defined, which surprises many people. But thread A may have been swapped out after giving up ownership, so A-post-give-up-lock statements may happen long after many B-post-gain-lock statements have finished. That is one of the possibilities that must be thought about when designing locks, and illustrates why multi-threaded programming is difficult.
 
Note that modernModern parallel languages have much easier to use execution models. The thread model was one of the original parallel execution models, which may account for why it has persisted despite being difficult to use.
 
== See also ==