1549 Because of these problems, we decided in our earlier paper |
1549 Because of these problems, we decided in our earlier paper |
1550 \cite{ZhangUrbanWu12} to leave out this property and let the |
1550 \cite{ZhangUrbanWu12} to leave out this property and let the |
1551 programmer assume the responsibility to program threads in such a |
1551 programmer assume the responsibility to program threads in such a |
1552 benign manner (in addition to causing no circularity in the |
1552 benign manner (in addition to causing no circularity in the |
1553 RAG). This was also the approach taken by Sha et al.~in their paper. |
1553 RAG). This was also the approach taken by Sha et al.~in their paper. |
1554 However, in this paper we can make an improvement: we can look |
1554 However, in this paper we can make an improvement: we can look at |
1555 at the \emph{events} that are happening once a Priority Inversion |
1555 the \emph{events} that are happening once a Priority Inversion |
1556 occurs. The events can be seen as a rough abstraction of the |
1556 occurs. The events can be seen as a rough abstraction of the |
1557 ``runtime behaviour'' of threads and also as an abstract notion of |
1557 ``runtime behaviour'' of threads and also as an abstract notion of |
1558 ``time''. We can then prove a more direct bound for the absence of |
1558 ``time''---when an event occured, some time must have passed. We |
1559 indefinite Priority Inversion. |
1559 can then prove a more direct bound for the absence of indefinite |
|
1560 Priority Inversion. This is what we shall show below. |
1560 |
1561 |
1561 What we will establish in this section is that there can only be a |
1562 What we will establish in this section is that there can only be a |
1562 finite amount of states after state @{term s} in which the thread |
1563 finite amount of states after state @{term s} in which the thread |
1563 @{term th} is blocked. For this to be true, Sha et al.~assume in |
1564 @{term th} is blocked. For this to be true, Sha et al.~assume in |
1564 their work that there is a finite pool of threads (active or |
1565 their work that there is a finite pool of threads (active or |
1565 hibernating). However, we do not have this concept of active or |
1566 hibernating). However, we do not have this concept of active or |
1566 hibernating threads in our model, but we can create or exit threads |
1567 hibernating threads in our model. Rather, in our model we can create |
1567 arbitrarily. Consequently, in our model the avoidance of indefinite |
1568 or exit threads arbitrarily. Consequently, the avoidance of |
1568 priority inversion we are trying to establish is not true, unless we |
1569 indefinite priority inversion we are trying to establish is in our |
1569 require that there number of threads created is bounded in every |
1570 model not true, unless we require that the number of threads |
1570 valid future state after @{term s}. So our first assumption |
1571 created is bounded in every valid future state after @{term s}. So |
1571 states |
1572 our first assumption states: |
1572 |
1573 |
1573 \begin{quote} {\bf Assumption on the number of threads created in |
1574 \begin{quote} {\bf Assumption on the number of threads created in |
1574 every valid state after the state {\boldmath@{text s}}:} Given the |
1575 every valid state after the state {\boldmath@{text s}}:} Given the |
1575 state @{text s}, in every ``future'' valid state @{text "t @ s"}, we |
1576 state @{text s}, in every ``future'' valid state @{text "t @ s"}, we |
1576 require that the number of created threads is less than |
1577 require that the number of created threads is less than |
1577 @{text "BC"}, that is @{text "len (filter isCreate (t @ s)) < |
1578 a bound @{text "BC"}, that is |
1578 BC"}. \end{quote} |
1579 |
1579 |
1580 \[@{text "len (filter isCreate (t @ s)) < BC"}\;.\] |
1580 \noindent Note that it is not enough for us to just to state that there |
1581 \end{quote} |
1581 are only finite number of threads created in the state @{text "s' @ s"}. Instead, we |
1582 |
1582 need to put a bound on the @{text "Create"} events for all valid |
1583 \noindent Note that it is not enough to just to state that there are |
1583 states after @{text s}. |
1584 only finite number of threads created in the state @{text "s' @ s"}. |
|
1585 Instead, we need to put a bound on the @{text "Create"} events for |
|
1586 all valid states after @{text s}. |
1584 |
1587 |
1585 For our second assumption about giving up resources after a finite |
1588 For our second assumption about giving up resources after a finite |
1586 amount of ``time'', let us introduce the following definition: |
1589 amount of ``time'', let us introduce the following definition about |
|
1590 threads that can potentially block @{text th}: |
1587 |
1591 |
1588 \begin{isabelle}\ \ \ \ \ %%% |
1592 \begin{isabelle}\ \ \ \ \ %%% |
1589 @{thm blockers_def} |
1593 @{thm blockers_def} |
1590 \end{isabelle} |
1594 \end{isabelle} |
1591 |
1595 |
1592 \noindent This set contains all treads that can potentially block |
1596 \noindent This set contains all treads that are not detached in |
1593 @{text th} after state @{text s}. We need to make the following |
1597 state @{text s} (i.e.~have a lock on a resource) and therefore can |
1594 assumption for the threads in this set: |
1598 potentially block @{text th} after state @{text s}. We need to make |
|
1599 the following assumption about the threads in this set: |
1595 |
1600 |
1596 \begin{quote} |
1601 \begin{quote} |
1597 {\bf Assumptions on the threads {\boldmath{@{term "th' \<in> blockers"}}}:} |
1602 {\bf Assumptions on the threads {\boldmath{@{term "th' \<in> blockers"}}}:} |
1598 For each @{text "th'"} there exists a finite bound @{text "BND(th')"} |
1603 For each @{text "th'"} there exists a finite bound @{text "BND(th')"} |
1599 such that for all future |
1604 such that for all future |
1600 valid states @{text "t @ s"}, |
1605 valid states @{text "t @ s"}, |
1601 we have that if @{term "\<not>(detached (t @ s) th')"}, then |
1606 we have that if @{term "\<not>(detached (t @ s) th')"}, then |
1602 @{text "len(actions_of th' (t @ s)) < BND(th')"}. |
1607 \[@{text "len(actions_of th' (t @ s)) < BND(th')"}\] |
1603 \end{quote} |
1608 \end{quote} |
1604 |
1609 |
1605 \noindent By this assumption we enforce that any thread blocking |
1610 \noindent By this assumption we enforce that any thread potentially |
1606 @{term th} must become detached (that is hold no resource) after a |
1611 blocking @{term th} must become detached (that is lock no resource) |
1607 finite number of events in @{text "t @ s"}. Again we have to require |
1612 after a finite number of events in @{text "t @ s"}. Again we have to |
1608 this bound to hold in all valid states after @{text s}. The bound |
1613 require this bound to hold in all valid states after @{text s}. The |
1609 reflects how each thread @{text "th'"} is programmed: Though we cannot |
1614 bound reflects how each thread @{text "th'"} is programmed: Though |
1610 express what instructions a thread is executing, the events correspond |
1615 we cannot express what instructions a thread is executing, the |
1611 to the system calls made by thread. Our @{text "BND(th')"} bounds |
1616 events in our model correspond to the system calls made by thread. Our @{text |
1612 the number of these calls. |
1617 "BND(th')"} binds the number of these calls. |
1613 |
1618 |
1614 The main reason for these two assumptions is that we can prove: |
1619 The main reason for these two assumptions is that we can prove: the |
|
1620 number of states after @{text s} in which the thread @{text th} is |
|
1621 is not running (that is where PI occurs) can be bounded by the |
|
1622 number of actions the threads in @{text blockers} perform and how |
|
1623 many threads are newly created. This bound can be stated for all |
|
1624 valid states @{term "t @ s"} that can happen after @{text s}. To |
|
1625 state our bound we use the definition @{term "Postfixes t \<equiv> {p. \<exists> s'. t = s' @ p}"}. |
|
1626 |
|
1627 |
|
1628 To state this we use the |
1615 |
1629 |
1616 |
1630 |
1617 \begin{isabelle}\ \ \ \ \ %%% |
1631 \begin{isabelle}\ \ \ \ \ %%% |
1618 @{thm bound_priority_inversion} |
1632 @{thm bound_priority_inversion} |
1619 \end{isabelle} |
1633 \end{isabelle} |