570 likes | 577 Views
This seminar presentation discusses the temporal semantics of concurrent programs, focusing on a simple model of concurrent programs and the use of temporal logic. Examples, proof systems, and the execution sequences of programs are also covered.
E N D
The Temporal Semantics Of Concurrent ProgramsAmir Pnueli (1981) Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013
Lecture outline • Goal • A simple model of concurrent programs • Introduction to Temporal logic • Examples • A proof system • The temporal semantics of programs • Summary • Questions
The notation • Giuseppe Peano - One of the founders of mathematical logic and set theory • Originally wrote for p is a consequence of q • Backwards: q is a consequence of p • denotes
Goal • Our goal is: given a program , assign a temporal formula which is true on all proper execution sequences of • To prove that a program possess a property one have to prove the implication
A simple model of concurrent programs • A concurrent program consists of disjoint processes • Which execute concurrently on processors • Under shared memory • And a set of initial conditions
A simple model of concurrent programs – a single process • Represented by a single entry transition graph • A directed labeled graph • The labels of process are denoted by • Edges are labels by commands of the form • is a condition, if is missing we interpret it as true • called a guard • May be true • is a statement which may be an assignment • is the vector of the program variables • may be empty
Process graph - Example Critical Section 2 Critical Section 1
A simple model of concurrent programs • Consider any program which may be run in parallel with another and contains: • 1. tests • 2. Unconditional transfers (go to’s) • 3. assignments statements • In the graph model: there will be a node for each statement representing the state • just before the execution of this statement
A simple model of concurrent programs • Corresponding to each statement which is the successor of this statement • i.e. may be reached by the execution of the statement • We draw an edge from the statement node to its successor • The labelof this edge depends on the type of the statement
A simple model of concurrent programs - tests • Case 1: test statements • For statements of the form :
A simple model of concurrent programs – unconditional transfers • Case 2: go to’s • For statements of the form :
A simple model of concurrent programs - assignments • Case 3: assignment • For statements of the form : • Explanation with the example : • Where are auxiliary variables local to
A simple model of concurrent programs - synchronization primitives • Examples of synchronization primitives: • 1. • 2. • 3. is represented as • With a corresponding at the end of the block
A simple model of concurrent programs – a single process • A state is a pair • is a vector of labels • is a set of values currently assigned to the program variables
Execution sequences (informally) • An execution sequence for a program is any sequence satisfying the following conditions : • 1. The initial stateis “correct” • 2. Satisfies the Multiprogramming assumption • One processor does one step and updates the values of the variables accordingly • 3. Satisfies the Fair scheduling assumption • If you can exit a node infinitely many times then you will be able to do so
Execution sequences • An execution sequence for a program is any sequence satisfying the following conditions : • 1. The initial state is where are the entry labels and are the initial values of the y’s • 2. Multiprogramming assumption: A successive state is obtained from its predecessor by exactly one processor executing one transition which is enabled.
Multiprogramming assumption • If the processor i contains an edge from the node to the node which is labeled by and is true, then is a possible successor of • We allow idling - • Every command is considered atomic … …
Fair scheduling assumption • – denotes the exit condition of a node of process • E is the disjunction ( ) of all guards on all edges departing from • What is in most of the cases ?
Fair scheduling assumption • A sequence is fairif whenever processor is stuck at then is true only at a finite number of states thereafter • negatively: no processor whose exit condition is true infinitely often may be deprived forever
Fair scheduling assumption • How does the statements on the edges affect the exit condition ? • Assignments, tests, go to’s –the exit condition is identically true! • For the statements of the other type (with synchronization) - the exit condition can be NOTidentically true!
Fair scheduling assumption • An important note: it is NOT sufficient to require that the processor will eventually be scheduled • it might always get scheduled when the condition is false and no transition is possible • We will need to express the stronger condition that it will eventually be scheduled when the exit condition is true
Temporal logic • Used to describe a system of rules for reasoning about propositions qualified in terms of time • Something alwaysoccurs • Something occurs now • Something will occur eventually • etc.
Reasoning about sequences • We will talk about an integer like time • We will reason about execution sequences which are deterministic • Each state having exactly one successor • Although that the program generating them is non- deterministic
Temporal operators • X – the proposition is true in the neXtinstant • F – the proposition will be true in the Future • existential truth • G – the proposition will always be true in the future • universaltruth • Stands for Globally
Temporal operators • neXt: • Future: • Globally
Validity of a temporal formula on a sequence • Denote and
Validity of a temporal formula on a sequence • A formula W is validif for all sequences • Example • Some expressions:
Examples of expressing properties with Temporal formulas • Recall: • A state is a pair • is a vector of labels • In our formulas: If then the proposition will be true in a state if • We start off with properties which can be expressed as formulas of the form where contains no temporal operators • Those are Invariance properties
Partial correctness • Consider a single sequential program • Entry • Exit • is a formula specifying the correctness of the program • That is: is to hold on termination • Partial correctness can be stated as What does this formula does NOTguarantee us ? • We can also add an input restriction
Clean behavior • For every instruction we can write a condition which ensure a lawful termination of the instruction • Examples: • If the instruction contains division - we include a claim that the divisor does not equal to zero • If the instruction contains array reference - we include a claim that the subscript expression is within the array bounds • - The legality condition for the statement departing from • Clean behavior can be stated as
Mutual Exclusion • Assume contain a critical section • For simplicity assume they consists of the single nodes • To claim that the critical sections are never simultaneously accessed we write
Deadlock Freedom • Deadlock – all processors are locked and none can move • In our model – we can only get stuck in a node if the exit condition is not identically true • Let be any set of nodes with exit conditions none of which is identically true • The statement that deadlocknever occurs at can be stated as • What can we do to exclude deadlock (not only for a given set of nodes) ?
Temporal formulas: Now A bit more complicated ones • We now advance to a class of properties which require a more complicated expressions • Expressible by expressions of the types:
Total correctness • Same setting as the partial correctness: • a single sequential program • Entry • Exit • is a formula specifying the correctness of the program • That is: is to hold on termination • expresses the initial input restrictions • Total correctness with respect to can be expressed as • Compare it to partial correctness:
Accessibility • In the context of critical sections • Expressing that if a process wishes to enter its critical section he will be granted permission to do so • m – a location (node) just before the entrance to the critical section • Of a process showing its wish to enter the critical section • m’ – a location inside thecritical section • The property of accessibilityis
Responsiveness • Suppose we receives requests from many external agents • For example: A Client-Server model • A request from agent i is signaled by a variable tuning true • The program deals with the request (for example it allocates the resource) and signals that the request to agent i has been granted by setting a variable to true • Responsivenesscan be expressed as
Coming up: A proof system! • We saw that the Temporal Logic language is useful for expressing and formulating interesting properties • We now present an axiomatic system in which we can provethese properties
The system DX - Axioms • Axioms:
The system DX – Inference rules • Inference rules: • R1: (TAU) if is an instance of a classical tautology then • R2: (MP) If and then • R3: (GEN) If then
The temporal semantics of programs • Consider a nodein any of the processes • The exit condition:
Clauses definitions (1) • For a node we define :
Clauses definitions (2) • Fair scheduling: • Exit node – a node with no outgoing transitions • If is an exit node then, by definition, and is identically true • allowing execution of the relevant program to remain at the exit node
Notation • For formulas : claims that exactlyone of the is true, while the others are false
Clauses definitions (3) • Consider process with label set : • Recall: • The expression expresses the situation that process is active • That is: some transition in it is taking place
Clauses definitions (4-6) • The expression Expresses the situation that process is idle • Now define
Clauses definitions (7) • Consider now a complete program • Define first
Defining W(P) • Assume that the initial labels in all programs are • And that the initial values of the variables are
Defining W(P) • The formula expressing the semantics of the program is:
Defining W(P) • The formula expressing the semantics of the program is: • - is active • - if all processes are idle then the values of the variables remain