You are on page 1of 35

Topic name:-

Completeness of
Specification and fairness
Group members name:-
1...AQSA B-24107
2…ATIQA B-24227
3…SAMEEN B-24649
4…ALVINA B-24697
5…SHABANA B-23383
Dekker's Algorithm:-
What Does Dekker's Algorithm
Mean?
Dekker’s algorithm is the first known
algorithm that solves the mutual
exclusion problem in concurrent
programming.
History and use:-
It is credited to Th. J. Dekker, a
Dutch mathematician who created the
algorithm for another context.
Dekker's algorithm is used in process
queuing, and allows two different
threads to share the same single-use
resource without conflict.
1..Dekkers Algorithum gives
software solution to cs programe
2..Dekkers Algorithum handles
two process mutual exclusion.
3..He took four attempts to solve
the two process problem.
NOTE:-
1st attempt:-
if one process fail other can get into the
critical section.
2nd attempt:-
violate critical section.
3rd attempt:-
Give rise to Deadlock.
4th attempt:-
Tries to solve the issue of deadlock.
Boolean turn:-
globel variable which defines the turn of
process to get into CS(Each process and
access and modify turn).
Boolean Flag:-
Indicates the wish of process to
get into CS (processes and modify
their flag but can only view flag of
other process)
FIRST ATTEMPT:-
PROCESS 0 PROCESS 1
 While (turn ! =0)  While (turn !=1)
 /*do nothing*/  /*do nothing */
 Critical section  Critical section
 Turn =1;  Turn=0;
 Draw Back:-
 Process examines their
own turn to enter their CS
and depends on other to
get turn If one process
fails other will not get a
chance to enter the critical
section.
Second Attempt:-
Flag is a global array of boolean type It TRUE indicates that process Want to
Enter CS.

PROCESS 0 PROCESS 1
 While (flag [1] )  While (flag[0])
 /*do nothing */  /*do nothing*/
 Flag [0] = TRUE  Flag [1] = TRUE
 Critical section  Critical section
 Flag[0] = False  Flag[1] = False
 Draw Back:-both the process
can evaluate their while loop
and find that flag is false both
can set their flag to TRUE and
get into CS violating the
mutual exclusion.
Third Attempt:-
PROCESS 0 PROCESS 1
 Flag [0] = True  Flag [1]= True
 While (flag [1])  While (Flag[0])
 /*do nothing*/  /*do nothing */
 Critical section  Critical section
 Flag [0] = FALSE  Flag [1] = False
 Draw back:-
 Both the process can set
their flag to TRUE and due
to their polite nature wait
for other one Hence will get
stuck into busy waiting.
Fourth Attempt:-
PROCESS 0 PROCESS 1
 Flag[0]= TRUE  Flag [1]= TRUE
 While (Flag [1])  While (Flag[0])
 {  {
 Flag [0]= False  Flag [1] = False
 /*delay*/  /*delay*/
 Flag [0] = TRUE  Flag[1] = TRUE
 }  }
 Critical section  Critical section
 Flag [0] = FALSE  Flag [1] = FALSE
Advantages of Dekker’s algorithm
1…Dekker’s algorithm helps in process
synchronization.
2…Dekker’s algorithm is the first correct
solution to the critical section problem that
can be proved.
3…Dekker’s algorithm is the ideal solution
for the mutual exclusion problem,
especially in concurrent programming.
.
Disadvantages of Dekkers
Algoritham:-
One disadvantage is that it is limited
to two processes and makes use of
busy waiting instead of process
suspension. (The use of busy waiting
suggests that processes should spend
a minimum amount of time inside
the critical section.)
Some fairness definitions:-
1... Weak transition fairness
2... Weak process fairness
3... Strong transition fairness
4... Strong process fairness
1... Weak transition fairness:-
It cannot happen that a transition is
enabled indefinitely, but is never
executed.
2...Weak process fairness:
It cannot happen that a process is
enabled indefinitely, but non of its
transitions is ever executed
3...Strong transition
fairness:
If a transition is infinitely often
enabled, it will get executed.
Strong process fairness:
If at least one transition of a process
is infinitely often enabled, a
transition of this process will be
executed
How to use fairness
constraints?
1..Assume in the negative that some
property (e.g., termination) does not hold,
because of some transitions or processes
prevented from execution.
2..Show that such executions are impossible,
as they contradict fairness assumption.
3..We sometimes do not know in reality
which fairness constraint is guaranteed.
Weak transition fairness
P1::x=1  Initially: x=0; y=0;
 Under weak transition P2: do
fairness, P1 would assign :: y==0 ->
1 to x, but this does not if
guarantee that 1 is
:: true
:: x==1 -> y=1
assigned to y and thus the if
P2 loop will terminates, do
since the transition for Weak process fairness
checking x==1 is not only guarantees P1 to
continuously enabled execute, but P2 can still
(program counter not choose the true guard.
Strong process
always there). fairness: same.
Strong
Initially: x=0; y=0;
transition

P2: do
fairness
:: y==0 ->
P1::x=1

Under strong if
transition fairness, P1 :: true
would assign 1 to x. If :: x==1 -> y=1
the execution was
infinite, the transition if
checking x==1 was do
infinitely often
enabled. Hence it
would be eventually
selected. Then
assigning y=1, the
main loop is not
enabled anymore.
Specifying fairness
conditions:-
Express properties over an
alternating sequence of states and
transitions:
s0 1 s1 1 s2 …
Use transition predicates exec.
 Weak transition fairness:
Some fairness /\ T (<>[]en []<>exec).
definitions Equivalently: /\aT ¬<>[]
exec  is
executed. (en /\¬exec)
execPi some
 Weak process fairness:
transition of Pi is /\Pi (<>[]enPi []<>execPi )
executed.  Strong transition fairness:
en  is enabled.
/\ T ([]<>en []<>exec )
enPi some
transition of
 Strong process fairness:
process Pi is /\Pi ([]<>enPi []<>execPi )
enabled.
enPi = \/ Pi en
execPi = \/ Pi exec
 1..A is weaker than B if B
Weaker fairness A.
condition (Means A has more
executions than B.)
 2..Consider the executions
L(A) and L(B). Then L(B) 
L(A).
Strong
transitio
 3..If an execution is strong
n {process/transition} fair, then
fair execs it is also weak
{process/transition} fair.
Weak
Weak  4...There are fewer strong
transitio
process
n {process,transition} fair
fair execs
fair execs executions.
Model Checking under fairness:-
1..Instead of verifying that the program
satisfies , verify it satisfies fair
2..Problem: may be inefficient. Also fairness
formula may involves special arrangement for
specifying what exec means.
3..May specialize model checking algorithm
instead.
Model Checking under Fairness:-
Specialize model checking. For weak process
fairness: search for a reachable strongly
connected component, where for each process
P either.
1..It contains on occurrence of a transition
from P, or
2..It contains a state where P is disabled.
Weak transition fairness: similar.
Strong fairness: much more difficult
algorithm.
completeness of specification
A specification is a statement expressed in a
language whose vocabulary, syntax, and semantics
are formally defined. The need for a formal
semantic definition means that the specification
languages cannot be based on natural language; it
must be based on mathematics,

.
 
 formal specification and informal
specification?
The formal specification
of a programming language is written in a
form ready for machine execution or written
using a formal mathematical notation,
On the other hand, an informal
specification can be expressed through a
model such as UML or in natural language
Formal Specification Methods
Formal Specification
Formal Proofs
Model Checking
Abstraction
 Formal Specifications
Translation of a non mathematical
description (diagrams, tables,
English text) into a formal
specification language Concise
description of high-level behavior
and properties of a system
Well-defined language semantics
support formal deduction about
specification
Formal Proofs
 Complete and convincing argument
for validity of some property of the
system description
 Constructed as a series of steps,
each of which is justified from a
small set of rules
 Eliminates ambiguity and
subjectivity inherent when drawing
informal conclusions
 May be manual but usually
constructed with automated
assistance
Model Checking
 State machine model of a system is expressed
in a suitable languages

 Model checker determines if the given finite


state machine model satisfies requirements
expressed as formulas in a given logic

 Basic method is to explore all reachable paths


Abstraction
 Simplify and ignore irrelevant details

 Focus on and generalize important central


properties and characteristics

 Avoid premature commitment to design and


implementation choices

You might also like