Benjamin/Cummings Pub. Co., 1991. (ch. 2-6)
The Nature of Concurrency (ch. 2)
Terminology and notation
This is the way programming started. The thread of execution is really associated
With the program-counter which is normally incrementing one by one and if we have
special constructs such as go-to, program-counter is adjusted accordingly.
possibly more than one thread of control. Processes/Threads typically interact with
Each other via shared data.
memory and we have no shared-memory.
Assume we have a block-structured language (variables have lexical scope) with
variable declarations which may be local or global to a context.
so now we can organize our program.
The program has to carry out some activity and that generally represents change in state.
The typical mechanism for representing a change in state of a program is a statement.
Most typically we have assignment to variables, which change values of variables.
One basic way of combining is sequential composition. Typically denoted by S1:S2
Where S1 and S2 are statements.
One the first models that was introduced was: Having multiple sequential programs that are Sharing data(variables). To describe two sequential programs being executed in parallel (whatever that means!) we use a parallel construct for example: co S1 || S2 oc
We now have a program which consists of two sequential programs that are combined
By the parallel operator || into a concurrent program. Now taking advantage of the fact
That we have a block-structured language, we will have the form:
begin declarations; Process-name1 :: code-body1; … end
n statements executed in parallel a[1] := 0, a[2] := 0, …, a[n] := 0
co x := x +1 || y := y + 1 oc
z := x + y
two statements executed in parallel (whatever parallel means!)
XPlus :: x := x + 1
YPlus :: y := y +1
end
z := z + y
Give name to two assignments (processes)
What does a program like above example mean?
There are many possible interpretations. For example what happens if x appears on the
left hand-side of two statements in a parallel construct?
Notation is not enough, We need semantics of concurrent program. We can not deal with
Concurrency unless we address two fundamental questions about the system the program
Runs on. One has to do with atomicity and the other with fairness of our system.
Atomicity and fairness assumptions of our system can change the semantics of our program significantly.
How have people historically assigned semantic to programming languages?
Do these semantics lead to verification and proof of correctness?
an abstract machine. We explain what a language does (statements of the language mean)
by inventing an abstract machine and showing all the effects of the language on the state
of this machine. For example if the abstract machine has memory locations for variables
and a program counter, we can define the meaning of the statement x := x +1 as a set of
operations on this machine that is: 1. Read the value of x into the accumulator, 2. increment the value in the accumulator by one, 3. Take the value in the accumulator and
put it back in the same memory location. We explain what the statements do in terms of
how they change the state of our abstract machine. Operational semantic models are used
for building simulators for the language.
A function that maps input into output. If we are given a program P, we can apply this
Denotational semantic transformation and get a function M. Now if we give the input of
P to M, the function M will give us the output that P would have produced had it finished
Execution. This model is also used for building simulator for languages.
On axioms and inference rules that allow us to prove properties of programs. These models are used for verification of correctness of our programs.
Atomicity
An operation is atomic if we can think of it as happening logically in an instance of time.
If two operations are atomic they can NOT happen at the same time. For a sequential program
Each action (statement execution) appears to be atomic because we only have one thread of
Execution and intermediate states are not visible.
for example: { x > 0} z := y + w { z = 3}
For example: {true} x:= 5 {x = 5}
{(x > 0) x3} x := 3 {x > 0}
{(y > 7) x3} x := 3 {y > 7}
| - {P} IF {Q}
| - {I} DO {I Ù Ø (B1 Ú …Ú Bn)}