prio/Paper/Paper.thy
changeset 315 f05f6aeb32f4
parent 314 ccb6c0601614
child 316 0423e4d7c77b
equal deleted inserted replaced
314:ccb6c0601614 315:f05f6aeb32f4
  1126 
  1126 
  1127 section {* Conclusion *}
  1127 section {* Conclusion *}
  1128 
  1128 
  1129 text {* 
  1129 text {* 
  1130   The Priority Inheritance Protocol (PIP) is a classic textbook
  1130   The Priority Inheritance Protocol (PIP) is a classic textbook
  1131   algorithm used in real-time systems in order to avoid the problem of
  1131   algorithm used in real-time operating systems in order to avoid the problem of
  1132   Priority Inversion.  While classic and widely used, PIP does have its faults: for
  1132   Priority Inversion.  Although classic and widely used, PIP does have
  1133   example it does not prevent deadlocks where threads have circular
  1133   its faults: for example it does not prevent deadlocks where threads
  1134   lock dependencies.
  1134   have circular lock dependencies.
  1135 
  1135 
  1136   We had two aims in mind with our formalisation
  1136   We had two aims in mind with our formalisation of PIP: One is to
  1137   of PIP: One is to understand the relevant literature and to make the
  1137   make the notions in the correctness proof by Sha et al.~\cite{Sha90}
  1138   notions in its correctness proof precise so that they can be
  1138   precise so that they can be processed by a theorem prover, because a
  1139   processed by a theorem prover, because a mechanically checked proof
  1139   mechanically checked proof avoids the flaws that crept into their
  1140   avoids the flaws that crept into the informal reasoning by Sha et
  1140   informal reasoning. We achieved this aim: The correctness of PIP now
  1141   al.~\cite{Sha90}. We achieved this aim: The correctness of PIP now
  1141   only hinges on the assumptions behind our formal model. The reasoning, which is
  1142   hinges only on the assumptions behind our formal model, which can
       
  1143   now be debated and potentially be modified. The reasoning, which is
       
  1144   sometimes quite intricate and tedious, has been checked beyond any
  1142   sometimes quite intricate and tedious, has been checked beyond any
  1145   reasonable doubt by Isabelle. We can confirm that Paulson's
  1143   reasonable doubt by Isabelle/HOL. We can also confirm that Paulson's
  1146   inductive approach to protocol verification \cite{Paulson98} is
  1144   inductive method to protocol verification~\cite{Paulson98} is quite
  1147   quite suitable for our formal model and proof. The traditianal
  1145   suitable for our formal model and proof. The traditional application
  1148   application area of this approach are security protocols.
  1146   area of this method is security protocols.  The only other
  1149   The only other application of Paulson's approach outside this area we know of 
  1147   application of Paulson's method we know of outside this area is
  1150   is \cite{Wang09}.
  1148   \cite{Wang09}.
  1151 
  1149 
  1152   The second aim is to provide a specification for PIP so that it can
  1150   The second aim is to provide a specification for actually
  1153   actually be implemented. Textbooks, like \cite[Section
  1151   implementing PIP. Textbooks, like \cite[Section 5.6.5]{Vahalia96},
  1154   5.6.5]{Vahalia96}, explain how to use various implementations of PIP
  1152   explain how to use various implementations of PIP and abstractly
  1155   and abstractly discuss its properties, but surprisinly lack many
  1153   discuss its properties, but surprisingly lack most details for a
  1156   details for an implementor.  That this is an issue in practice is
  1154   programmer.  That this is an issue in practice is illustrated by the
  1157   illustrated by the email from Baker we cited in the
  1155   email from Baker we cited in the Introduction. We achieved also this
  1158   Introduction. The formalisation gives the first author enough data
  1156   aim: The formalisation gives the first author enough data to enable
  1159   to enable his undergraduate students to implement PIP on top of
  1157   his undergraduate students to implement as part of their OS course
  1160   PINTOS, an small operating system for teaching purposes.  Given the
  1158   PIP on top of PINTOS, a small operating system for teaching
  1161   results in Section~\ref{implement}, we also succeeded with this
  1159   purposes. A byproduct of our formalisation effort is that nearly all
  1162   aim. A byproduct of our formalisation effort is that nearly all
       
  1163   design choices for the PIP scheduler are backed up with a proved
  1160   design choices for the PIP scheduler are backed up with a proved
  1164   lemma.
  1161   lemma. We were also able to prove the property that the choice of
  1165 
  1162   the next thread taking over a lock is irrelevant for the correctness
  1166 
  1163   of PIP. Earlier model checking techniques
       
  1164   \cite{Faria08,Jahier09,Wellings07} were not able to provided this
       
  1165   kind of ``deep understanding'' into PIP.
       
  1166 
       
  1167   PIP is a scheduling algorithm for single-processor systems. We are
       
  1168   now living in a multi-processor world. So the question naturally arises 
       
  1169   whether PIP has nowadays any relevance beyond teaching. 
       
  1170   
       
  1171    The work in this paper only deals with single CPU configurations. The
       
  1172   "one CPU" assumption is essential for our formalisation, because the
       
  1173   main lemma fails in multi-CPU configuration. The lemma says that any
       
  1174   runing thead must be the one with the highest prioirty or already held
       
  1175   some resource when the highest priority thread was initiated. When
       
  1176   there are multiple CPUs, it may well be the case that a threads did
       
  1177   not hold any resource when the highest priority thread was initiated,
       
  1178   but that thread still runs after that moment on a separate CPU. In
       
  1179   this way, the main lemma does not hold anymore.
       
  1180 
       
  1181 
       
  1182   There are some works deals with priority inversion in multi-CPU
       
  1183   configurations[???], but none of them have given a formal correctness
       
  1184   proof. The extension of our formal proof to deal with multi-CPU
       
  1185   configurations is not obvious. One possibility, as suggested in paper
       
  1186   [???], is change our formal model (the defiintion of "schs") to give
       
  1187   the released resource to the thread with the highest prioirty. In this
       
  1188   way, indefinite prioirty inversion can be avoided, but for a quite
       
  1189   different reason from the one formalized in this paper (because the
       
  1190   "mail lemma" will be different). This means a formal correctness proof
       
  1191   for milt-CPU configuration would be quite different from the one given
       
  1192   in this paper. The solution of prioirty inversion problem in mult-CPU
       
  1193   configurations is a different problem which needs different solutions
       
  1194   which is outside the scope of this paper.
       
  1195 
       
  1196   no clue about multi-processor case according to \cite{Steinberg10} 
  1167 
  1197 
  1168  
  1198  
  1169 
       
  1170   no clue about multi-processor case according to \cite{Steinberg10} 
       
  1171 
       
  1172 
       
  1173   \begin{enumerate}
       
  1174   \item The correctness of the protocol model itself. A series of desirable properties is 
       
  1175     derived until we are fully convinced that the formal model of PI does 
       
  1176     eliminate priority inversion. And a better understanding of PI is so obtained 
       
  1177     in due course. For example, we find through formalization that the choice of 
       
  1178     next thread to take hold when a 
       
  1179     resource is released is irrelevant for the very basic property of PI to hold. 
       
  1180     A point never mentioned in literature. 
       
  1181   \item The correctness of the implementation. A series of properties is derived the meaning 
       
  1182     of which can be used as guidelines on how PI can be implemented efficiently and correctly. 
       
  1183   \end{enumerate} 
       
  1184 
       
  1185  
       
  1186    Contributions
       
  1187 
       
  1188   Despite the wide use of Priority Inheritance Protocol in real time operating
       
  1189   system, it's correctness has never been formally proved and mechanically checked. 
       
  1190   All existing verification are based on model checking technology. Full automatic
       
  1191   verification gives little help to understand why the protocol is correct. 
       
  1192   And results such obtained only apply to models of limited size. 
       
  1193   This paper presents a formal verification based on theorem proving. 
       
  1194   Machine checked formal proof does help to get deeper understanding. We found 
       
  1195   the fact which is not mentioned in the literature, that the choice of next 
       
  1196   thread to take over when an critical resource is release does not affect the correctness
       
  1197   of the protocol. The paper also shows how formal proof can help to construct 
       
  1198   correct and efficient implementation.\bigskip 
       
  1199 
  1199 
  1200 *}
  1200 *}
  1201 
  1201 
  1202 section {* An overview of priority inversion and priority inheritance \label{overview} *}
  1202 section {* An overview of priority inversion and priority inheritance \label{overview} *}
  1203 
  1203 
  1246   byproduct of such an effort, because everything has finally be reduced to the very 
  1246   byproduct of such an effort, because everything has finally be reduced to the very 
  1247   first principle to be checked mechanically. The former intuitive explanation of 
  1247   first principle to be checked mechanically. The former intuitive explanation of 
  1248   Priority Inheritance is just such a byproduct. 
  1248   Priority Inheritance is just such a byproduct. 
  1249   *}
  1249   *}
  1250 
  1250 
  1251 (*
       
  1252 section {* Formal model of Priority Inheritance \label{model} *}
       
  1253 text {*
       
  1254   \input{../../generated/PrioGDef}
       
  1255 *}
       
  1256 *)
       
  1257 
       
  1258 section {* General properties of Priority Inheritance \label{general} *}
  1251 section {* General properties of Priority Inheritance \label{general} *}
  1259 
  1252 
  1260 text {*
  1253 text {*
  1261  
  1254  
  1262   *}
  1255   *}
  1424 *}
  1417 *}
  1425 
  1418 
  1426 section {* Conclusions \label{conclusion} *}
  1419 section {* Conclusions \label{conclusion} *}
  1427 
  1420 
  1428 text {*
  1421 text {*
  1429   The work in this paper only deals with single CPU configurations. The
  1422  
  1430   "one CPU" assumption is essential for our formalisation, because the
       
  1431   main lemma fails in multi-CPU configuration. The lemma says that any
       
  1432   runing thead must be the one with the highest prioirty or already held
       
  1433   some resource when the highest priority thread was initiated. When
       
  1434   there are multiple CPUs, it may well be the case that a threads did
       
  1435   not hold any resource when the highest priority thread was initiated,
       
  1436   but that thread still runs after that moment on a separate CPU. In
       
  1437   this way, the main lemma does not hold anymore.
       
  1438 
       
  1439 
       
  1440   There are some works deals with priority inversion in multi-CPU
       
  1441   configurations[???], but none of them have given a formal correctness
       
  1442   proof. The extension of our formal proof to deal with multi-CPU
       
  1443   configurations is not obvious. One possibility, as suggested in paper
       
  1444   [???], is change our formal model (the defiintion of "schs") to give
       
  1445   the released resource to the thread with the highest prioirty. In this
       
  1446   way, indefinite prioirty inversion can be avoided, but for a quite
       
  1447   different reason from the one formalized in this paper (because the
       
  1448   "mail lemma" will be different). This means a formal correctness proof
       
  1449   for milt-CPU configuration would be quite different from the one given
       
  1450   in this paper. The solution of prioirty inversion problem in mult-CPU
       
  1451   configurations is a different problem which needs different solutions
       
  1452   which is outside the scope of this paper.
       
  1453 
  1423 
  1454 *}
  1424 *}
  1455 
  1425 
  1456 (*<*)
  1426 (*<*)
  1457 end
  1427 end