Avoid using specific `G` classes for locks, always use the projection `lockG` of `lock`.
4 unresolved threads
This MR is a follow up of !979 (merged).
Always preferring the projections is similar to the way we use acquire
/release
/etc.
This MR also adjusts the subG
instance to use lockG
instead of spin_lockG
, and tests that the conditions are resolved automatically when using adequacy.
TODO: I have only done this for spin lock, the same remains to be done for ticket lock, rw lock, atomic heap.
Merge request reports
Activity
101 97 lock.newlock_spec _ _ _ _ := newlock_spec; 102 98 lock.acquire_spec _ _ _ _ := acquire_spec; 103 99 lock.release_spec _ _ _ _ := release_spec |}. 100 101 Definition spin_lockΣ : gFunctors := #[GFunctor (exclR unitO)]. 102 103 Global Instance subG_spin_lockΣ {Σ} : subG spin_lockΣ Σ → @lockG spin_lock Σ. 538 eauto. 537 wp_smart_apply (release_spec with "[$Hlock $Hlocked Hloc]"); by eauto. 539 538 Qed. 540 End lock. 541 Section spin_lock. 542 Local Existing Instance spin_lock. 539 End lock_gen. 543 540 544 Definition spin_lock_client : val := 545 λ: "loc" "lock", 546 acquire "lock";; 547 "loc" <- #42;; 548 release "lock". 541 (** Make sure the lock type class works to write clients and 542 specifications for specific locks (here: spin lock). *) 543 Section lock_gen. 559 wp_smart_apply (acquire_spec with "Hislock") as "[Hlocked [%v Hloc]]". 556 unfold lock_client_spin. wp_alloc l as "Hl". 557 wp_smart_apply (newlock_spec (∃ n : Z, l ↦ #n) with "[Hl]") 558 as (lk γ) "#Hlock"; first by eauto. 559 wp_smart_apply (acquire_spec with "Hlock") as "(Hlocked & %v & Hloc)". 560 560 wp_store. 561 wp_smart_apply (release_spec with "[$Hlocked Hloc]"). 562 { iFrame "Hislock". eauto. } 563 eauto. 561 wp_smart_apply (release_spec with "[$Hlock $Hlocked Hloc]"); by eauto. 562 Qed. 563 End lock_gen. 564 565 (** Making sure we the [lockG] conditions are resolved when using adequacy. For 566 the generic client, we need to instantiate it with a specific lock for that to 567 make sense. *) 305 305 Tactic failure: wp_cmpxchg_suc: cannot find 'CmpXchg' in 306 306 (#() #()). 307 "wp_spin_lock_client" 308 : string 309 1 goal 310 311 Σ : gFunctors 312 heapGS0 : heapGS Σ 313 spin_lockG0 : spin_lockG Σ 314 loc : locations.loc 315 lock : val 316 γ : lock_name 317 ============================ 318 "Hislock" : is_lock γ lock (∃ v : val, loc ↦ v) 319 --------------------------------------□ 320 WP let: "lock" := lock in acquire "lock";; #loc <- #42;; release "lock" mentioned in merge request !981 (merged)
Please register or sign in to reply