Skip to content
Snippets Groups Projects
Commit 41d72be6 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Remove namespaces from lock API.

parent 365095a0
No related branches found
No related tags found
No related merge requests found
...@@ -10,31 +10,31 @@ Structure lock Σ `{!heapG Σ} := Lock { ...@@ -10,31 +10,31 @@ Structure lock Σ `{!heapG Σ} := Lock {
(* -- predicates -- *) (* -- predicates -- *)
(* name is used to associate locked with is_lock *) (* name is used to associate locked with is_lock *)
name : Type; name : Type;
is_lock (N: namespace) (γ: name) (lock: val) (R: iProp Σ) : iProp Σ; is_lock (γ: name) (lock: val) (R: iProp Σ) : iProp Σ;
locked (γ: name) : iProp Σ; locked (γ: name) : iProp Σ;
(* -- general properties -- *) (* -- general properties -- *)
is_lock_ne N γ lk : Contractive (is_lock N γ lk); is_lock_ne γ lk : Contractive (is_lock γ lk);
is_lock_persistent N γ lk R : Persistent (is_lock N γ lk R); is_lock_persistent γ lk R : Persistent (is_lock γ lk R);
is_lock_iff N γ lk R1 R2 : is_lock_iff γ lk R1 R2 :
is_lock N γ lk R1 -∗ (R1 R2) -∗ is_lock N γ lk R2; is_lock γ lk R1 -∗ (R1 R2) -∗ is_lock γ lk R2;
locked_timeless γ : Timeless (locked γ); locked_timeless γ : Timeless (locked γ);
locked_exclusive γ : locked γ -∗ locked γ -∗ False; locked_exclusive γ : locked γ -∗ locked γ -∗ False;
(* -- operation specs -- *) (* -- operation specs -- *)
newlock_spec N (R : iProp Σ) : newlock_spec (R : iProp Σ) :
{{{ R }}} newlock #() {{{ lk γ, RET lk; is_lock N γ lk R }}}; {{{ R }}} newlock #() {{{ lk γ, RET lk; is_lock γ lk R }}};
acquire_spec N γ lk R : acquire_spec γ lk R :
{{{ is_lock N γ lk R }}} acquire lk {{{ RET #(); locked γ R }}}; {{{ is_lock γ lk R }}} acquire lk {{{ RET #(); locked γ R }}};
release_spec N γ lk R : release_spec γ lk R :
{{{ is_lock N γ lk R locked γ R }}} release lk {{{ RET #(); True }}} {{{ is_lock γ lk R locked γ R }}} release lk {{{ RET #(); True }}}
}. }.
Arguments newlock {_ _} _. Arguments newlock {_ _} _.
Arguments acquire {_ _} _. Arguments acquire {_ _} _.
Arguments release {_ _} _. Arguments release {_ _} _.
Arguments is_lock {_ _} _ _ _ _ _. Arguments is_lock {_ _} _ _ _ _.
Arguments locked {_ _} _ _. Arguments locked {_ _} _ _.
Existing Instances is_lock_ne is_lock_persistent locked_timeless. Existing Instances is_lock_ne is_lock_persistent locked_timeless.
Instance is_lock_proper Σ `{!heapG Σ} (L: lock Σ) N γ lk: Instance is_lock_proper Σ `{!heapG Σ} (L: lock Σ) γ lk:
Proper (() ==> ()) (is_lock L N γ lk) := ne_proper _. Proper (() ==> ()) (is_lock L γ lk) := ne_proper _.
...@@ -21,7 +21,8 @@ Instance subG_lockΣ {Σ} : subG lockΣ Σ → lockG Σ. ...@@ -21,7 +21,8 @@ Instance subG_lockΣ {Σ} : subG lockΣ Σ → lockG Σ.
Proof. solve_inG. Qed. Proof. solve_inG. Qed.
Section proof. Section proof.
Context `{!heapG Σ, !lockG Σ} (N : namespace). Context `{!heapG Σ, !lockG Σ}.
Let N := nroot .@ "spin_lock".
Definition lock_inv (γ : gname) (l : loc) (R : iProp Σ) : iProp Σ := Definition lock_inv (γ : gname) (l : loc) (R : iProp Σ) : iProp Σ :=
( b : bool, l #b if b then True else own γ (Excl ()) R)%I. ( b : bool, l #b if b then True else own γ (Excl ()) R)%I.
......
...@@ -37,7 +37,8 @@ Instance subG_tlockΣ {Σ} : subG tlockΣ Σ → tlockG Σ. ...@@ -37,7 +37,8 @@ Instance subG_tlockΣ {Σ} : subG tlockΣ Σ → tlockG Σ.
Proof. solve_inG. Qed. Proof. solve_inG. Qed.
Section proof. Section proof.
Context `{!heapG Σ, !tlockG Σ} (N : namespace). Context `{!heapG Σ, !tlockG Σ}.
Let N := nroot .@ "ticket_lock".
Definition lock_inv (γ : gname) (lo ln : loc) (R : iProp Σ) : iProp Σ := Definition lock_inv (γ : gname) (lo ln : loc) (R : iProp Σ) : iProp Σ :=
( o n : nat, ( o n : nat,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment