Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Iris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaëtan Gilbert
Iris
Commits
a7d741f6
Commit
a7d741f6
authored
8 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
More consistent names in ticket lock.
parent
e8b99bd7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
heap_lang/lib/ticket_lock.v
+21
-21
21 additions, 21 deletions
heap_lang/lib/ticket_lock.v
with
21 additions
and
21 deletions
heap_lang/lib/ticket_lock.v
+
21
−
21
View file @
a7d741f6
...
@@ -7,23 +7,23 @@ From iris.heap_lang.lib Require Export lock.
...
@@ -7,23 +7,23 @@ From iris.heap_lang.lib Require Export lock.
Import
uPred
.
Import
uPred
.
Definition
wait_loop
:
val
:=
Definition
wait_loop
:
val
:=
rec
:
"wait_loop"
"x"
"l
oc
k"
:=
rec
:
"wait_loop"
"x"
"lk"
:=
let
:
"o"
:=
!
(
Fst
"l
oc
k"
)
in
let
:
"o"
:=
!
(
Fst
"lk"
)
in
if
:
"x"
=
"o"
if
:
"x"
=
"o"
then
#
()
(* my turn *)
then
#
()
(* my turn *)
else
"wait_loop"
"x"
"l
oc
k"
.
else
"wait_loop"
"x"
"lk"
.
Definition
newlock
:
val
:=
λ
:
<>
,
(
(* owner *)
ref
#
0
,
(* next *)
ref
#
0
)
.
Definition
newlock
:
val
:=
λ
:
<>
,
(
(* owner *)
ref
#
0
,
(* next *)
ref
#
0
)
.
Definition
acquire
:
val
:=
Definition
acquire
:
val
:=
rec
:
"acquire"
"l
oc
k"
:=
rec
:
"acquire"
"lk"
:=
let
:
"n"
:=
!
(
Snd
"l
oc
k"
)
in
let
:
"n"
:=
!
(
Snd
"lk"
)
in
if
:
CAS
(
Snd
"l
oc
k"
)
"n"
(
"n"
+
#
1
)
if
:
CAS
(
Snd
"lk"
)
"n"
(
"n"
+
#
1
)
then
wait_loop
"n"
"l
oc
k"
then
wait_loop
"n"
"lk"
else
"acquire"
"l
oc
k"
.
else
"acquire"
"lk"
.
Definition
release
:
val
:=
λ
:
"l
oc
k"
,
Definition
release
:
val
:=
λ
:
"lk"
,
(
Fst
"l
oc
k"
)
<-
!
(
Fst
"l
oc
k"
)
+
#
1
.
(
Fst
"lk"
)
<-
!
(
Fst
"lk"
)
+
#
1
.
Global
Opaque
newlock
acquire
release
wait_loop
.
Global
Opaque
newlock
acquire
release
wait_loop
.
...
@@ -58,14 +58,14 @@ Section proof.
...
@@ -58,14 +58,14 @@ Section proof.
Definition
locked
(
γ
:
gname
)
:
iProp
Σ
:=
(
∃
o
,
own
γ
(
◯
(
Excl'
o
,
∅
)))
%
I
.
Definition
locked
(
γ
:
gname
)
:
iProp
Σ
:=
(
∃
o
,
own
γ
(
◯
(
Excl'
o
,
∅
)))
%
I
.
Global
Instance
lock_inv_ne
n
γ
s
lo
ln
:
Global
Instance
lock_inv_ne
n
γ
lo
ln
:
Proper
(
dist
n
==>
dist
n
)
(
lock_inv
γ
s
lo
ln
)
.
Proper
(
dist
n
==>
dist
n
)
(
lock_inv
γ
lo
ln
)
.
Proof
.
solve_proper
.
Qed
.
Proof
.
solve_proper
.
Qed
.
Global
Instance
is_lock_ne
γ
s
n
l
:
Proper
(
dist
n
==>
dist
n
)
(
is_lock
γ
s
l
)
.
Global
Instance
is_lock_ne
γ
n
l
k
:
Proper
(
dist
n
==>
dist
n
)
(
is_lock
γ
l
k
)
.
Proof
.
solve_proper
.
Qed
.
Proof
.
solve_proper
.
Qed
.
Global
Instance
is_lock_persistent
γ
s
l
R
:
PersistentP
(
is_lock
γ
s
l
R
)
.
Global
Instance
is_lock_persistent
γ
l
k
R
:
PersistentP
(
is_lock
γ
l
k
R
)
.
Proof
.
apply
_
.
Qed
.
Proof
.
apply
_
.
Qed
.
Global
Instance
locked_timeless
γ
s
:
TimelessP
(
locked
γ
s
)
.
Global
Instance
locked_timeless
γ
:
TimelessP
(
locked
γ
)
.
Proof
.
apply
_
.
Qed
.
Proof
.
apply
_
.
Qed
.
Lemma
locked_exclusive
(
γ
:
gname
)
:
(
locked
γ
★
locked
γ
⊢
False
)
%
I
.
Lemma
locked_exclusive
(
γ
:
gname
)
:
(
locked
γ
★
locked
γ
⊢
False
)
%
I
.
...
@@ -88,8 +88,8 @@ Section proof.
...
@@ -88,8 +88,8 @@ Section proof.
iVsIntro
.
iApply
(
"HΦ"
$!
(
#
lo
,
#
ln
)
%
V
γ
)
.
iExists
lo
,
ln
.
eauto
.
iVsIntro
.
iApply
(
"HΦ"
$!
(
#
lo
,
#
ln
)
%
V
γ
)
.
iExists
lo
,
ln
.
eauto
.
Qed
.
Qed
.
Lemma
wait_loop_spec
γ
l
x
R
(
Φ
:
val
→
iProp
Σ
)
:
Lemma
wait_loop_spec
γ
l
k
x
R
(
Φ
:
val
→
iProp
Σ
)
:
issued
γ
l
x
R
★
(
locked
γ
-★
R
-★
Φ
#
())
⊢
WP
wait_loop
#
x
l
{{
Φ
}}
.
issued
γ
l
k
x
R
★
(
locked
γ
-★
R
-★
Φ
#
())
⊢
WP
wait_loop
#
x
l
k
{{
Φ
}}
.
Proof
.
Proof
.
iIntros
"[Hl HΦ]"
.
iDestruct
"Hl"
as
(
lo
ln
)
"(% & #? & % & #? & Ht)"
.
iIntros
"[Hl HΦ]"
.
iDestruct
"Hl"
as
(
lo
ln
)
"(% & #? & % & #? & Ht)"
.
iLöb
as
"IH"
.
wp_rec
.
subst
.
wp_let
.
wp_proj
.
wp_bind
(
!
_)
%
E
.
iLöb
as
"IH"
.
wp_rec
.
subst
.
wp_let
.
wp_proj
.
wp_bind
(
!
_)
%
E
.
...
@@ -110,8 +110,8 @@ Section proof.
...
@@ -110,8 +110,8 @@ Section proof.
wp_if
.
iApply
(
"IH"
with
"Ht"
)
.
by
iExact
"HΦ"
.
wp_if
.
iApply
(
"IH"
with
"Ht"
)
.
by
iExact
"HΦ"
.
Qed
.
Qed
.
Lemma
acquire_spec
γ
l
R
(
Φ
:
val
→
iProp
Σ
)
:
Lemma
acquire_spec
γ
l
k
R
(
Φ
:
val
→
iProp
Σ
)
:
is_lock
γ
l
R
★
(
locked
γ
-★
R
-★
Φ
#
())
⊢
WP
acquire
l
{{
Φ
}}
.
is_lock
γ
l
k
R
★
(
locked
γ
-★
R
-★
Φ
#
())
⊢
WP
acquire
l
k
{{
Φ
}}
.
Proof
.
Proof
.
iIntros
"[Hl HΦ]"
.
iDestruct
"Hl"
as
(
lo
ln
)
"(% & #? & % & #?)"
.
iIntros
"[Hl HΦ]"
.
iDestruct
"Hl"
as
(
lo
ln
)
"(% & #? & % & #?)"
.
iLöb
as
"IH"
.
wp_rec
.
wp_bind
(
!
_)
%
E
.
subst
.
wp_proj
.
iLöb
as
"IH"
.
wp_rec
.
wp_bind
(
!
_)
%
E
.
subst
.
wp_proj
.
...
@@ -142,8 +142,8 @@ Section proof.
...
@@ -142,8 +142,8 @@ Section proof.
iVsIntro
.
wp_if
.
by
iApply
"IH"
.
iVsIntro
.
wp_if
.
by
iApply
"IH"
.
Qed
.
Qed
.
Lemma
release_spec
γ
l
R
(
Φ
:
val
→
iProp
Σ
):
Lemma
release_spec
γ
l
k
R
(
Φ
:
val
→
iProp
Σ
):
is_lock
γ
l
R
★
locked
γ
★
R
★
Φ
#
()
⊢
WP
release
l
{{
Φ
}}
.
is_lock
γ
l
k
R
★
locked
γ
★
R
★
Φ
#
()
⊢
WP
release
l
k
{{
Φ
}}
.
Proof
.
Proof
.
iIntros
"(Hl & Hγ & HR & HΦ)"
.
iIntros
"(Hl & Hγ & HR & HΦ)"
.
iDestruct
"Hl"
as
(
lo
ln
)
"(% & #? & % & #?)"
;
subst
.
iDestruct
"Hl"
as
(
lo
ln
)
"(% & #? & % & #?)"
;
subst
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment