Safety and Liveness
Prabhaker Mateti
matetiSafetyLiveness.pptx
A ``safety'' property is defined thus: Let BAD be a predicate
characterizing any arbitrary condition or state of program code
segment S that you consider is ``bad''. Assume that {P} S {Q}
holds. Assume that I is a {global invariant}. If I ⇒
$\neg$ BAD, we say that $\neg$ BAD is a safety property
for S.
Our Andrews' text book unfortunately uses the subjective words
"good" and "bad" in defining Safety and Liveness. Instead think
of (i) safety as a property that is true from the beginning of the
process to its end of life, and (ii) liveness as a property that
will become true at a future moment in time, perhaps just once or
many many times. So, safety is an invariant property -- good or
bad subjectively. Obviously, in a real enough context, we do not
want a "bad" thing to ever happen, i.e., not-bad should be true at
all times.
Safety examples
-
Variable x is always non-negative.
-
Two processes are never in their critical sections.
-
A message is received only after it is sent.
-
No sent message is lost.
-
A philosopher remains hungry until it eats.
-
Liveness examples
-
Variable x will become divisible by 7.
-
Even in the presence of contentions, one of the processes will enter
its critical section.
-
A sent message is eventually received.
-
A philosopher will eat.
-
Exercises
-
``Every philosopher will eventually get hungry.'' is a safety, not
liveness, property. True/False? Explain.
-
A safety property states that nothing ``bad'' will ever happen,
whereas a liveness property states that something ``good'' will
happen in the next minute.
-
Often there is no difference between safety and liveness properties.
- The negation of a safety property is a liveness property.
- "Some day, if not at the end of CEG 7370, you will appreciate
and marvel at the book Concurrent Programming by Andrews."
Explain if this is a safety, or liveness property, or perhaps
neither.
Copyright © 2012
pmateti@wright.edu