PIPDefs.thy
changeset 65 633b1fc8631b
parent 64 b4bcd1edbb6d
child 67 25fd656667a7
equal deleted inserted replaced
64:b4bcd1edbb6d 65:633b1fc8631b
     1 chapter {* Definitions *}
     1 chapter {* Definitions *}
     2 (*<*)
     2 (*<*)
     3 theory PIPDefs
     3 theory PIPDefs
     4 imports Precedence_ord Moment
     4 imports Precedence_ord Moment RTree Max
     5 begin
     5 begin
     6 (*>*)
     6 (*>*)
     7 
     7 
     8 text {*
     8 text {*
     9   In this section, the formal model of  Priority Inheritance Protocol (PIP) is presented. 
     9   In this section, the formal model of  Priority Inheritance Protocol (PIP) is presented. 
   605   The following observation @{text "cntV s"} returns the number of operation @{text "V"} happened 
   605   The following observation @{text "cntV s"} returns the number of operation @{text "V"} happened 
   606   before reaching state @{text "s"}.
   606   before reaching state @{text "s"}.
   607   *}
   607   *}
   608 definition cntV :: "state \<Rightarrow> thread \<Rightarrow> nat"
   608 definition cntV :: "state \<Rightarrow> thread \<Rightarrow> nat"
   609   where "cntV s th = count (\<lambda> e. \<exists> cs. e = V th cs) s"
   609   where "cntV s th = count (\<lambda> e. \<exists> cs. e = V th cs) s"
       
   610 
       
   611 text {* @{text "the_preced"} is also the same as @{text "preced"}, the only
       
   612        difference is the order of arguemts. *}
       
   613 definition "the_preced s th = preced th s"
       
   614 
       
   615 text {* @{term "the_thread"} extracts thread out of RAG node. *}
       
   616 fun the_thread :: "node \<Rightarrow> thread" where
       
   617    "the_thread (Th th) = th"
       
   618 
       
   619 text {* The following @{text "wRAG"} is the waiting sub-graph of @{text "RAG"}. *}
       
   620 definition "wRAG (s::state) = {(Th th, Cs cs) | th cs. waiting s th cs}"
       
   621 
       
   622 text {* The following @{text "hRAG"} is the holding sub-graph of @{text "RAG"}. *}
       
   623 definition "hRAG (s::state) =  {(Cs cs, Th th) | th cs. holding s th cs}"
       
   624 
       
   625 text {* 
       
   626   The following @{text "tRAG"} is the thread-graph derived from @{term "RAG"}.
       
   627   It characterizes the dependency between threads when calculating current
       
   628   precedences. It is defined as the composition of the above two sub-graphs, 
       
   629   names @{term "wRAG"} and @{term "hRAG"}.
       
   630  *}
       
   631 definition "tRAG s = wRAG s O hRAG s"
       
   632 
       
   633 text {* The following lemma splits @{term "RAG"} graph into the above two sub-graphs. *}
       
   634 lemma RAG_split: "RAG s = (wRAG s \<union> hRAG s)"
       
   635   by (unfold s_RAG_abv wRAG_def hRAG_def s_waiting_abv 
       
   636              s_holding_abv cs_RAG_def, auto)
       
   637 
       
   638 definition "cp_gen s x =
       
   639                   Max ((the_preced s \<circ> the_thread) ` subtree (tRAG s) x)"
       
   640 
   610 (*<*)
   641 (*<*)
   611 
   642 
   612 end
   643 end
   613 (*>*)
   644 (*>*)
   614 
   645