-
Notifications
You must be signed in to change notification settings - Fork 0
/
code_retired_list.v
60 lines (49 loc) · 1.59 KB
/
code_retired_list.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From smr.lang Require Import tactics notation.
From iris.prelude Require Import options.
(** RetiredNode *)
Notation rNodeSize := 4%nat (only parsing).
Notation rNodeNext := 0 (only parsing).
Notation rNodePtr := 1 (only parsing).
Notation rNodePtrSize := 2 (only parsing).
Notation rNodeEpoch := 3 (only parsing).
Definition retired_node_new : val :=
λ: "ptr" "size" "epoch",
let: "rNode" := AllocN #rNodeSize #0 in
"rNode" +ₗ #rNodeNext <- #NULL;;
"rNode" +ₗ #rNodePtr <- "ptr";;
"rNode" +ₗ #rNodePtrSize <- "size";;
"rNode" +ₗ #rNodeEpoch <- "epoch";;
"rNode".
Definition retired_node_next : val :=
λ: "rNode",
! ("rNode" +ₗ #rNodeNext).
Definition retired_node_ptr : val :=
λ: "rNode",
! ("rNode" +ₗ #rNodePtr).
Definition retired_node_size : val :=
λ: "rNode",
! ("rNode" +ₗ #rNodePtrSize).
Definition retired_node_epoch : val :=
λ: "rNode",
! ("rNode" +ₗ #rNodeEpoch).
Definition retired_node_drop : val :=
λ: "rNode",
Free #rNodeSize "rNode".
(** RetiredSet *)
Notation rSetSize := 1%nat (only parsing).
Notation rSetHead := 0 (only parsing).
Definition retired_list_new : val :=
λ: <>,
let: "rSet" := AllocN #rSetSize #0 in
"rSet" +ₗ #rSetHead <- #NULL;;
"rSet".
Definition retired_list_push : val :=
rec: "loop" "rSet" "rNode" :=
let: "head" := !("rSet" +ₗ #rSetHead) in
"rNode" +ₗ #rNodeNext <- "head";;
if: CAS ("rSet" +ₗ #rSetHead) "head" "rNode" then
#()
else
"loop" "rSet" "rNode".
Definition retired_list_pop_all : val :=
λ: "rSet", Xchg ("rSet" +ₗ #rSetHead) #NULL.