Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Actris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
tlsomers
Actris
Commits
6eee4a54
Commit
6eee4a54
authored
5 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
More powerful allocation rule for spin lock. Add deallocation rule for spin_lock.
parent
e29d18e2
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
theories/utils/spin_lock.v
+20
-8
20 additions, 8 deletions
theories/utils/spin_lock.v
with
20 additions
and
8 deletions
theories/utils/spin_lock.v
+
20
−
8
View file @
6eee4a54
...
@@ -6,7 +6,7 @@ From iris.base_logic.lib Require Import cancelable_invariants.
...
@@ -6,7 +6,7 @@ From iris.base_logic.lib Require Import cancelable_invariants.
From
iris
.
bi
.
lib
Require
Import
fractional
.
From
iris
.
bi
.
lib
Require
Import
fractional
.
Set
Default
Proof
Using
"Type"
.
Set
Default
Proof
Using
"Type"
.
Definition
newlock
:
val
:=
λ
:
<>
,
ref
#
false
.
Definition
new
_
lock
:
val
:=
λ
:
<>
,
ref
#
false
.
Definition
try_acquire
:
val
:=
λ
:
"l"
,
CAS
"l"
#
false
#
true
.
Definition
try_acquire
:
val
:=
λ
:
"l"
,
CAS
"l"
#
false
#
true
.
Definition
acquire
:
val
:=
Definition
acquire
:
val
:=
rec
:
"acquire"
"l"
:=
if
:
try_acquire
"l"
then
#
()
else
"acquire"
"l"
.
rec
:
"acquire"
"l"
:=
if
:
try_acquire
"l"
then
#
()
else
"acquire"
"l"
.
...
@@ -63,21 +63,33 @@ Section proof.
...
@@ -63,21 +63,33 @@ Section proof.
Global
Instance
unlocked_timeless
lk
q
:
Timeless
(
unlocked
lk
q
)
.
Global
Instance
unlocked_timeless
lk
q
:
Timeless
(
unlocked
lk
q
)
.
Proof
.
apply
_
.
Qed
.
Proof
.
apply
_
.
Qed
.
Lemma
newlock_spec
(
R
:
iProp
Σ
):
Lemma
lock_cancel
E
lk
R
:
↑
N
⊆
E
→
is_lock
lk
R
-∗
unlocked
lk
1
=
{
E
}
=∗
▷
R
.
{{{
R
}}}
newlock
#
()
{{{
lk
,
RET
#
lk
;
is_lock
lk
R
∗
unlocked
lk
1
}}}
.
Proof
.
Proof
.
iIntros
(
Φ
)
"HR HΦ"
.
rewrite
-
wp_fupd
/
newlock
/=.
intros
.
iDestruct
1
as
(
γ
γi
)
"#[Hm Hinv]"
.
iDestruct
1
as
(
γ'
γi'
)
"[Hm' Hq]"
.
wp_lam
.
wp_apply
(
wp_alloc
with
"[//]"
);
iIntros
(
l
)
"[Hl Hm]"
.
iDestruct
(
meta_agree
with
"Hm Hm'"
)
as
%
[
=
<-
<-
];
iClear
"Hm'"
.
iMod
(
cinv_open_strong
with
"[$] [$]"
)
as
"(HR & Hq & Hclose)"
;
first
done
.
iDestruct
"HR"
as
([])
"[Hl HR]"
.
-
iDestruct
"HR"
as
(
p
)
"[_ Hq']"
.
iDestruct
(
cinv_own_1_l
with
"Hq Hq'"
)
as
">[]"
.
-
iDestruct
"HR"
as
"[_ $]"
.
iApply
"Hclose"
;
auto
.
Qed
.
Lemma
new_lock_spec
:
{{{
True
}}}
new_lock
#
()
{{{
lk
,
RET
#
lk
;
unlocked
lk
1
∗
(
∀
R
,
R
=
{
⊤
}
=∗
is_lock
lk
R
)
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
iApply
wp_fupd
.
wp_lam
.
wp_apply
(
wp_alloc
with
"[//]"
);
iIntros
(
l
)
"[Hl Hm]"
.
iDestruct
(
meta_token_difference
_
(
↑
N
)
with
"Hm"
)
as
"[Hm1 Hm2]"
;
first
done
.
iDestruct
(
meta_token_difference
_
(
↑
N
)
with
"Hm"
)
as
"[Hm1 Hm2]"
;
first
done
.
iMod
(
own_alloc
(
●
None
))
as
(
γ
)
"Hγ"
;
first
by
apply
auth_auth_valid
.
iMod
(
own_alloc
(
●
None
))
as
(
γ
)
"Hγ"
;
first
by
apply
auth_auth_valid
.
iMod
(
cinv_alloc_strong
(
λ
_,
True
))
iMod
(
cinv_alloc_strong
(
λ
_,
True
))
as
(
γi
_)
"[Hγi H]"
;
first
by
apply
pred_infinite_True
.
as
(
γi
_)
"[Hγi H]"
;
first
by
apply
pred_infinite_True
.
iMod
(
meta_set
_
_
(
γ
,
γi
)
with
"Hm1"
)
as
"#Hm1"
;
first
done
.
iMod
(
meta_set
_
_
(
γ
,
γi
)
with
"Hm1"
)
as
"#Hm1"
;
first
done
.
iApply
"HΦ"
;
iSplitL
"Hγi"
;
first
by
(
iExists
γ
,
γi
;
auto
)
.
iIntros
"!>"
(
R
)
"HR"
.
iMod
(
"H"
$!
(
lock_inv
γ
γi
l
R
)
with
"[HR Hl Hγ]"
)
as
"#?"
.
iMod
(
"H"
$!
(
lock_inv
γ
γi
l
R
)
with
"[HR Hl Hγ]"
)
as
"#?"
.
{
iIntros
"!>"
.
iExists
false
.
by
iFrame
.
}
{
iIntros
"!>"
.
iExists
false
.
by
iFrame
.
}
iModIntro
.
iApply
"HΦ"
.
iSplit
;
iExists
γ
,
γi
;
auto
.
iModIntro
.
iExists
γ
,
γi
;
auto
.
Qed
.
Qed
.
Lemma
try_acquire_spec
lk
R
q
:
Lemma
try_acquire_spec
lk
R
q
:
...
...
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