Definition blocked_at_external (state : cm_state) (ef : external_function) :=
match state with
(m, (tr, sch, tp)) =>
exists j cntj sch' c args,
sch = j :: sch' /\
@getThreadC _ _ _ j tp cntj = Kblocked c /\
cl_at_external c = Some (ef, args)
end.
Definition state_bupd P (state : cm_state) := let '(m, (tr, sch, tp)) := state in
tp_bupd (fun tp' => P (m, (tr, sch, tp'))) tp.

Lemma state_bupd_intro : forall (P : _ -> Prop) m tr sch tp phi, join_all tp phi ->
joins (ghost_of phi) (Some (ext_ref tt, NoneP) :: nil) ->
P (m, (tr, sch, tp)) -> state_bupd P (m, (tr, sch, tp)).