176 example on Page 254 the authors write: ``{\it Upon releasing the |
178 example on Page 254 the authors write: ``{\it Upon releasing the |
177 lock, the [low-priority] thread will revert to its original |
179 lock, the [low-priority] thread will revert to its original |
178 priority.}'' The same error is also repeated later in this textbook. |
180 priority.}'' The same error is also repeated later in this textbook. |
179 |
181 |
180 |
182 |
181 While \cite{Laplante11,Liu00,book,Sha90,Silberschatz13} are the only formal publications we have |
183 While \cite{Laplante11,Liu00,book,Sha90,Silberschatz13} are the only |
182 found that specify the incorrect behaviour, it seems also many |
184 formal publications we have found that specify the incorrect |
183 informal descriptions of PIP overlook the possibility that another |
185 behaviour, it seems also many informal descriptions of PIP overlook |
184 high-priority might wait for a low-priority process to finish. |
186 the possibility that another high-priority might wait for a |
185 A notable exception is the texbook \cite{buttazzo}, which gives the correct |
187 low-priority process to finish. A notable exception is the texbook |
186 behaviour of resetting the priority of a thread to the highest remaining priority of the |
188 \cite{buttazzo}, which gives the correct behaviour of resetting the |
187 threads it blocks. This textbook also gives an informal proof for |
189 priority of a thread to the highest remaining priority of the |
188 the correctness of PIP in the style of Sha et al. Unfortunately, this informal |
190 threads it blocks. This textbook also gives an informal proof for |
189 proof is too vague to be useful for formalising the correctness of PIP |
191 the correctness of PIP in the style of Sha et al. Unfortunately, |
190 and the specification leaves out nearly all details in order |
192 this informal proof is too vague to be useful for formalising the |
191 to implement PIP efficiently.\medskip\smallskip |
193 correctness of PIP and the specification leaves out nearly all |
|
194 details in order to implement PIP efficiently.\medskip\smallskip |
192 % |
195 % |
193 %The advantage of formalising the |
196 %The advantage of formalising the |
194 %correctness of a high-level specification of PIP in a theorem prover |
197 %correctness of a high-level specification of PIP in a theorem prover |
195 %is that such issues clearly show up and cannot be overlooked as in |
198 %is that such issues clearly show up and cannot be overlooked as in |
196 %informal reasoning (since we have to analyse all possible behaviours |
199 %informal reasoning (since we have to analyse all possible behaviours |
197 %of threads, i.e.~\emph{traces}, that could possibly happen). |
200 %of threads, i.e.~\emph{traces}, that could possibly happen). |
198 |
201 |
199 \noindent |
202 \noindent {\bf Contributions:} There have been earlier formal |
200 {\bf Contributions:} There have been earlier formal investigations |
203 investigations into PIP \cite{Faria08,Jahier09,Wellings07}, but they |
201 into PIP \cite{Faria08,Jahier09,Wellings07}, but they employ model |
204 employ model checking techniques. This paper presents a formalised |
202 checking techniques. This paper presents a formalised and |
205 and mechanically checked proof for the correctness of PIP. For this |
203 mechanically checked proof for the correctness of PIP. For this we |
206 we needed to design a new correctness criterion for PIP. In contrast |
204 needed to design a new correctness criterion for PIP. In contrast to model checking, our |
207 to model checking, our formalisation provides insight into why PIP |
205 formalisation provides insight into why PIP is correct and allows us |
208 is correct and allows us to prove stronger properties that, as we |
206 to prove stronger properties that, as we will show, can help with an |
209 will show, can help with an efficient implementation of PIP. We |
207 efficient implementation of PIP in the educational PINTOS operating |
210 illustrate this with an implementation of PIP in the educational |
208 system \cite{PINTOS}. For example, we found by ``playing'' with the |
211 PINTOS operating system \cite{PINTOS}. For example, we found by |
209 formalisation that the choice of the next thread to take over a lock |
212 ``playing'' with the formalisation that the choice of the next |
210 when a resource is released is irrelevant for PIP being correct---a |
213 thread to take over a lock when a resource is released is irrelevant |
211 fact that has not been mentioned in the literature and not been used |
214 for PIP being correct---a fact that has not been mentioned in the |
212 in the reference implementation of PIP in PINTOS. This fact, however, is important |
215 literature and not been used in the reference implementation of PIP |
213 for an efficient implementation of PIP, because we can give the lock |
216 in PINTOS. This fact, however, is important for an efficient |
214 to the thread with the highest priority so that it terminates more |
217 implementation of PIP, because we can give the lock to the thread |
215 quickly. We were also being able to generalise the scheduler of Sha |
218 with the highest priority so that it terminates more quickly. We |
216 et al.~\cite{Sha90} to the practically relevant case where critical |
219 were also being able to generalise the scheduler of Sha et |
217 sections can overlap; see Figure~\ref{overlap} \emph{a)} below for an example of |
220 al.~\cite{Sha90} to the practically relevant case where critical |
218 this restriction. %In the existing literature there is no |
221 sections can overlap; see Figure~\ref{overlap} \emph{a)} below for |
219 %proof and also no proving method that cover this generalised case. |
222 an example of this restriction. In the existing literature there is |
|
223 no proof and also no proving method that cover this generalised |
|
224 case. |
220 |
225 |
221 \begin{figure} |
226 \begin{figure} |
222 \begin{center} |
227 \begin{center} |
223 \begin{tikzpicture}[scale=1] |
228 \begin{tikzpicture}[scale=1] |
224 %%\draw[step=2mm] (0,0) grid (10,2); |
229 %%\draw[step=2mm] (0,0) grid (10,2); |
379 ``time-slicing'' threads with equal priority, but found that it does not lead to |
384 ``time-slicing'' threads with equal priority, but found that it does not lead to |
380 advantages in practice. On the contrary, according to their work having a policy |
385 advantages in practice. On the contrary, according to their work having a policy |
381 like our FIFO-scheduling of threads with equal priority reduces the number of |
386 like our FIFO-scheduling of threads with equal priority reduces the number of |
382 tasks involved in the inheritance process and thus minimises the number |
387 tasks involved in the inheritance process and thus minimises the number |
383 of potentially expensive thread-switches. |
388 of potentially expensive thread-switches. |
|
389 |
|
390 We will also need counters for @{term P} and @{term V} events of a thread @{term th} |
|
391 in a state @{term s}. This can be straightforwardly defined in Isabelle as |
|
392 |
|
393 \begin{isabelle}\ \ \ \ \ %%% |
|
394 \mbox{\begin{tabular}{@ {}l} |
|
395 @{thm cntP_def}\\ |
|
396 @{thm cntV_def} |
|
397 \end{tabular}} |
|
398 \end{isabelle} |
|
399 |
|
400 \noindent using the predefined function @{const count} for lists. |
384 |
401 |
385 Next, we introduce the concept of \emph{waiting queues}. They are |
402 Next, we introduce the concept of \emph{waiting queues}. They are |
386 lists of threads associated with every resource. The first thread in |
403 lists of threads associated with every resource. The first thread in |
387 this list (i.e.~the head, or short @{term hd}) is chosen to be the one |
404 this list (i.e.~the head, or short @{term hd}) is chosen to be the one |
388 that is in possession of the |
405 that is in possession of the |