422 advantages in practice. On the contrary, according to their work having a policy |
422 advantages in practice. On the contrary, according to their work having a policy |
423 like our FIFO-scheduling of threads with equal priority reduces the number of |
423 like our FIFO-scheduling of threads with equal priority reduces the number of |
424 tasks involved in the inheritance process and thus minimises the number |
424 tasks involved in the inheritance process and thus minimises the number |
425 of potentially expensive thread-switches. |
425 of potentially expensive thread-switches. |
426 |
426 |
427 {\bf NEEDED?} We will also need counters for @{term P} and @{term V} events of a thread @{term th} |
427 \endnote{{\bf NEEDED?} We will also need counters for @{term P} and @{term V} events of a thread @{term th} |
428 in a state @{term s}. This can be straightforwardly defined in Isabelle as |
428 in a state @{term s}. This can be straightforwardly defined in Isabelle as |
429 |
429 |
430 \begin{isabelle}\ \ \ \ \ %%% |
430 \begin{isabelle}\ \ \ \ \ %%% |
431 \mbox{\begin{tabular}{@ {}l} |
431 \mbox{\begin{tabular}{@ {}l} |
432 @{thm cntP_def}\\ |
432 @{thm cntP_def}\\ |
433 @{thm cntV_def} |
433 @{thm cntV_def} |
434 \end{tabular}} |
434 \end{tabular}} |
435 \end{isabelle} |
435 \end{isabelle} |
436 |
436 |
437 \noindent using the predefined function @{const count} for lists. |
437 \noindent using the predefined function @{const count} for lists.} |
438 |
438 |
439 Next, we introduce the concept of \emph{waiting queues}. They are |
439 Next, we introduce the concept of \emph{waiting queues}. They are |
440 lists of threads associated with every resource. The first thread in |
440 lists of threads associated with every resource. The first thread in |
441 this list (i.e.~the head, or short @{term hd}) is chosen to be the one |
441 this list (i.e.~the head, or short @{term hd}) is chosen to be the one |
442 that is in possession of the |
442 that is in possession of the |
567 \noindent Note that forests can have trees with infinte depth and |
567 \noindent Note that forests can have trees with infinte depth and |
568 containing nodes with infinitely many children. A \emph{finite |
568 containing nodes with infinitely many children. A \emph{finite |
569 forrest} is a forest which is well-founded and every node has |
569 forrest} is a forest which is well-founded and every node has |
570 finitely many children (is only finitely branching). |
570 finitely many children (is only finitely branching). |
571 |
571 |
|
572 \endnote{ |
572 \begin{isabelle}\ \ \ \ \ %%% |
573 \begin{isabelle}\ \ \ \ \ %%% |
573 @{thm rtrancl_path.intros} |
574 @{thm rtrancl_path.intros} |
574 \end{isabelle} |
575 \end{isabelle} |
575 |
576 |
576 \begin{isabelle}\ \ \ \ \ %%% |
577 \begin{isabelle}\ \ \ \ \ %%% |
577 @{thm rpath_def} |
578 @{thm rpath_def} |
578 \end{isabelle} |
579 \end{isabelle}} |
579 |
580 |
580 |
581 |
581 {\bf Lemma about overlapping paths} |
582 \endnote{{\bf Lemma about overlapping paths}} |
582 |
583 |
583 |
584 |
584 We will design our PIP-scheduler |
585 We will design our PIP-scheduler |
585 so that every thread can be in the possession of several resources, that is |
586 so that every thread can be in the possession of several resources, that is |
586 it has potentially several incoming holding edges in the RAG, but has at most one outgoing |
587 it has potentially several incoming holding edges in the RAG, but has at most one outgoing |
1072 |
1074 |
1073 %% HERE |
1075 %% HERE |
1074 |
1076 |
1075 Given our assumptions (on @{text th}), the first property we can |
1077 Given our assumptions (on @{text th}), the first property we can |
1076 show is that any running thread, say @{text "th'"}, has the same |
1078 show is that any running thread, say @{text "th'"}, has the same |
1077 precedence of @{text th}: |
1079 precedence as @{text th}: |
1078 |
1080 |
1079 \begin{lemma}\label{runningpreced} |
1081 \begin{lemma}\label{runningpreced} |
1080 @{thm [mode=IfThen] running_preced_inversion} |
1082 @{thm [mode=IfThen] running_preced_inversion} |
1081 \end{lemma} |
1083 \end{lemma} |
1082 |
1084 |
1083 \begin{proof} |
1085 \begin{proof} |
1084 By definition the running thread has as current precedence the maximum of |
1086 By definition, the running thread has as current precedence the maximum of |
1085 all ready threads, that is |
1087 all ready threads, that is |
1086 |
1088 |
1087 \begin{center} |
1089 \begin{center} |
1088 @{term "cp (t @ s) th' = Max (cp (t @ s) ` readys (t @ s))"} |
1090 @{term "cp (t @ s) th' = Max (cp (t @ s) ` readys (t @ s))"} |
1089 \end{center} |
1091 \end{center} |
1090 |
1092 |
1091 \noindent |
1093 \noindent |
1092 We also know that this is equal to all threads, that is |
1094 We also know that this is equal to the current precedences of all threads, |
|
1095 that is |
1093 |
1096 |
1094 \begin{center} |
1097 \begin{center} |
1095 @{term "cp (t @ s) th' = Max (cp (t @ s) ` treads (t @ s))"} |
1098 @{term "cp (t @ s) th' = Max (cp (t @ s) ` treads (t @ s))"} |
1096 \end{center} |
1099 \end{center} |
1097 |
1100 |
1098 \noindent |
1101 \noindent |
|
1102 This is because each ready thread, say @{text "th\<^sub>r"}, has the maximum |
|
1103 current precedence of the subtree located at @{text "th\<^sub>r"}. All these |
|
1104 subtrees together form the set of threads. |
1099 But the maximum of all threads is the @{term "cp"} of @{text "th"}, |
1105 But the maximum of all threads is the @{term "cp"} of @{text "th"}, |
1100 which is the @{term preced} of @{text th}. |
1106 which is equal to the @{term preced} of @{text th}.\qed |
1101 \end{proof} |
1107 \end{proof} |
1102 |
1108 |
|
1109 \endnote{ |
1103 @{thm "th_blockedE_pretty"} -- thm-blockedE?? |
1110 @{thm "th_blockedE_pretty"} -- thm-blockedE?? |
1104 |
1111 |
1105 |
|
1106 @{text "th_kept"} shows that th is a thread in s'-s |
1112 @{text "th_kept"} shows that th is a thread in s'-s |
1107 |
1113 } |
1108 |
1114 |
1109 |
1115 Next we show that a running thread @{text "th'"} must either wait for or |
1110 |
1116 hold a resource in state @{text s}. |
1111 \begin{proof}[of Theorem 1] |
1117 |
1112 If @{term "th \<in> running (s' @ s)"}, then there is nothing to show. So let us |
1118 \begin{lemma}\label{notdetached} |
1113 assume otherwise. By Lem.~\ref{thblockedE} we know there exists a thread |
1119 If @{term "th' \<in> running (s' @ s)"} then @{term "\<not>detached s th'"}. |
1114 @{text "th'"} that is an acestor of @{text th} in the @{text "RAG"} |
1120 \end{lemma} |
1115 and @{text "th'"} is running, that is we know |
1121 |
1116 |
1122 \begin{proof} Let us assume @{text "th'"} is detached in state |
1117 \begin{center} |
1123 @{text "s"}, then, according to the definition of detached, @{text |
1118 @{term "th' \<in> nancestors (tG (s' @ s)) th"} \quad and \quad |
1124 "th’"} does not hold or wait for any resource. Hence the @{text |
1119 @{term "th' \<in> running (s' @ s)"} |
1125 cp}-value of @{text "th'"} in @{text s} is not boosted, that is |
1120 \end{center} |
1126 @{term "cp s th' = prec th s"}, and is therefore lower than the |
1121 |
1127 precedence (as well as the @{text "cp"}-value) of @{term "th"}. This |
1122 \noindent We have that @{term "th \<noteq> th'"} since we assumed |
1128 means @{text "th'"} will not run as long as @{text "th"} is a |
1123 @{text th} is not running. By Lem.~\ref{thkept}, we know that |
1129 live thread. In turn this means @{text "th'"} cannot acquire a reseource |
1124 @{text "th'"} is also running in state @{text s} and by |
1130 and is still detached in state @{text "s' @ s"}. Consequently |
1125 Lem.~\ref{detached} that @{term "\<not>detached s th'"}. |
1131 @{text "th'"} is also not boosted in state @{text "s' @ s"} and |
1126 By Lem.~\ref{runningpreced} we have |
1132 would not run. This contradicts our assumption.\qed |
|
1133 \end{proof} |
|
1134 |
|
1135 |
|
1136 \begin{proof}[of Theorem 1] If @{term "th \<in> running (s' @ s)"}, |
|
1137 then there is nothing to show. So let us assume otherwise. Since the |
|
1138 @{text "RAG"} is well-founded, we know there exists an ancestor of |
|
1139 @{text "th"} that is the root of the corrsponding subtree and |
|
1140 therefore is ready. Let us call this thread @{text "th'"}. We know |
|
1141 that @{text "th'"} has the highest precedence of all ready threads. |
|
1142 Therefore it is running. We have that @{term "th \<noteq> th'"} |
|
1143 since we assumed @{text th} is not running. By |
|
1144 Lem.~\ref{notdetached} we have that @{term "\<not>detached s th'"}. |
|
1145 If @{text "th'"} is not detached in @{text s}, that is either |
|
1146 holding or waiting for a resource, it must be that @{term "th' \<in> |
|
1147 threads s"}. By Lem.~\ref{runningpreced} we have |
1127 |
1148 |
1128 \begin{center} |
1149 \begin{center} |
1129 @{term "cp (t @ s) th' = preced th s"} |
1150 @{term "cp (t @ s) th' = preced th s"} |
1130 \end{center} |
1151 \end{center} |
1131 |
1152 |
1132 \noindent |
1153 \noindent |
1133 This concludes the proof of Theorem 1. |
1154 This concludes the proof of Theorem 1.\qed |
1134 \end{proof} |
1155 \end{proof} |
1135 |
1156 |
1136 |
1157 |
1137 |
1158 \endnote{ |
1138 |
|
1139 In what follows we will describe properties of PIP that allow us to |
1159 In what follows we will describe properties of PIP that allow us to |
1140 prove Theorem~\ref{mainthm} and, when instructive, briefly describe |
1160 prove Theorem~\ref{mainthm} and, when instructive, briefly describe |
1141 our argument. Recall we want to prove that in state @{term "s' @ s"} |
1161 our argument. Recall we want to prove that in state @{term "s' @ s"} |
1142 either @{term th} is either running or blocked by a thread @{term |
1162 either @{term th} is either running or blocked by a thread @{term |
1143 "th'"} (@{term "th \<noteq> th'"}) which was alive in state @{term s}. We |
1163 "th'"} (@{term "th \<noteq> th'"}) which was alive in state @{term s}. We |
1144 can show that |
1164 can show that |
1145 |
1165 |
1146 |
|
1147 |
1166 |
1148 \begin{lemma} |
1167 \begin{lemma} |
1149 If @{thm (prem 2) eq_pv_blocked} |
1168 If @{thm (prem 2) eq_pv_blocked} |
1150 then @{thm (concl) eq_pv_blocked} |
1169 then @{thm (concl) eq_pv_blocked} |
1151 \end{lemma} |
1170 \end{lemma} |
1152 |
1171 |
1153 \begin{lemma} |
1172 \begin{lemma} |
1154 If @{thm (prem 2) eq_pv_persist} |
1173 If @{thm (prem 2) eq_pv_persist} |
1155 then @{thm (concl) eq_pv_persist} |
1174 then @{thm (concl) eq_pv_persist} |
1156 \end{lemma} |
1175 \end{lemma}} |
1157 |
1176 |
1158 \subsection*{\bf OUTLINE} |
1177 \endnote{{\bf OUTLINE} |
1159 |
1178 |
1160 Since @{term "th"} is the most urgent thread, if it is somehow |
1179 Since @{term "th"} is the most urgent thread, if it is somehow |
1161 blocked, people want to know why and wether this blocking is |
1180 blocked, people want to know why and wether this blocking is |
1162 reasonable. |
1181 reasonable. |
1163 |
1182 |