Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sasa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
verimag
synchrone
sasa
Commits
7770ced6
Commit
7770ced6
authored
4 years ago
by
erwan
Browse files
Options
Downloads
Patches
Plain Diff
Update: Call the fault function if provided when a legitimate configuration is reached
nb: does not really work yet.
parent
4d08c6e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#46744
failed
4 years ago
Stage: build
Stage: release
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/algo/algo.mli
+3
-1
3 additions, 1 deletion
lib/algo/algo.mli
src/sasaMain.ml
+68
-35
68 additions, 35 deletions
src/sasaMain.ml
test/unison/state.ml
+7
-1
7 additions, 1 deletion
test/unison/state.ml
with
78 additions
and
37 deletions
lib/algo/algo.mli
+
3
−
1
View file @
7770ced6
(* Time-stamp: <modified the 0
7
/07/2020 (at 1
6
:1
1
) by Erwan Jahier> *)
(* Time-stamp: <modified the 0
8
/07/2020 (at 1
5
:1
2
) by Erwan Jahier> *)
(** {1 The Algorithm programming Interface.} *)
(**
{1 What's need to be provided by users.}
...
...
@@ -86,7 +86,9 @@ Useful to explore best/worst case daemons
type
pid
=
string
type
'
s
pf_info
=
{
neighbors
:
'
s
neighbor
list
;
curr
:
'
s
;
next
:
'
s
;
action
:
action
}
type
'
s
potential_fun
=
pid
list
->
(
pid
->
'
s
pf_info
)
->
float
(** *)
(** {1 Legitimate Configurations} *)
type
'
s
legitimate_fun
=
pid
list
->
(
pid
->
'
s
*
'
s
neighbor
list
)
->
bool
(** By default, legitimate configurations (i.e., global states) are
...
...
This diff is collapsed.
Click to expand it.
src/sasaMain.ml
+
68
−
35
View file @
7770ced6
...
...
@@ -59,47 +59,79 @@ let legitimate p_nl_l e =
if
p
.
Process
.
pid
=
pid
then
Env
.
get
e
pid
,
nl
else
from_pid
tail
pid
in
ulf
pidl
(
from_pid
p_nl_l
)
let
inject_fault
ff
p_nl
e
=
let
update_nodes
e
(
p
,
nl
)
=
let
pid
=
p
.
Process
.
pid
in
let
v
=
Env
.
get
e
pid
in
let
v
=
ff
(
List
.
length
nl
)
pid
v
in
Env
.
set
e
pid
v
in
List
.
fold_left
update_nodes
e
p_nl
let
(
simustep
:
int
->
int
->
SasArg
.
t
->
string
->
(
'
v
Process
.
t
*
'
v
Register
.
neighbor
list
)
list
->
'
v
Env
.
t
->
'
v
Env
.
t
*
string
)
=
(
'
v
Process
.
t
*
'
v
Register
.
neighbor
list
)
list
->
'
v
Env
.
t
->
'
v
Env
.
t
*
string
)
=
fun
n
i
args
activate_val
p_nl
e
->
(* 1: Get enable processes *)
let
all
,
enab_ll
=
Sasacore
.
Main
.
get_enable_processes
p_nl
e
in
let
pl
=
fst
(
List
.
split
p_nl
)
in
List
.
iter
(
List
.
iter
(
fun
b
->
if
b
then
incr
moves
))
enab_ll
;
(* 1: Get enable processes *)
let
all
,
enab_ll
=
Sasacore
.
Main
.
get_enable_processes
p_nl
e
in
let
pl
=
fst
(
List
.
split
p_nl
)
in
List
.
iter
(
List
.
iter
(
fun
b
->
if
b
then
incr
moves
))
enab_ll
;
let
e
=
if
not
(
args
.
rif
)
&&
List
.
for_all
(
fun
b
->
not
b
)
(
List
.
flatten
enab_ll
)
then
(
print_step
n
i
args
e
pl
activate_val
enab_ll
;
incr
rounds
;
raise
(
Silent
(
n
-
i
+
1
))
match
Register
.
get_fault
()
with
|
None
->
print_step
n
i
args
e
pl
activate_val
enab_ll
;
incr
rounds
;
raise
(
Silent
(
n
-
i
+
1
))
|
Some
ff
->
print_step
n
i
args
e
pl
activate_val
enab_ll
;
let
str
=
if
args
.
rif
then
"#"
else
""
in
Printf
.
eprintf
"
\n
%sThis algo is silent after %i moves, %i steps, %i rounds.
\n
"
str
!
moves
i
!
rounds
;
Printf
.
eprintf
"==> Inject a fault
\n
%!"
;
inject_fault
ff
p_nl
e
)
else
if
legitimate
p_nl
e
then
(
print_step
n
i
args
e
pl
activate_val
enab_ll
;
raise
(
Legitimate
(
n
-
i
+
1
))
match
Register
.
get_fault
()
with
|
None
->
print_step
n
i
args
e
pl
activate_val
enab_ll
;
raise
(
Legitimate
(
n
-
i
+
1
))
|
Some
ff
->
print_step
n
i
args
e
pl
activate_val
enab_ll
;
let
str
=
if
args
.
rif
then
"#"
else
""
in
Printf
.
eprintf
"
\n
%sThis algo Reached a legitimate configuration after %i moves, %i steps, %i rounds.
\n
"
str
!
moves
i
!
rounds
;
Printf
.
eprintf
"==> Inject a fault
\n
%!"
;
inject_fault
ff
p_nl
e
)
else
if
args
.
daemon
=
Daemon
.
Custom
then
print_step
n
i
args
e
pl
activate_val
enab_ll
;
(* 2: read the actions *)
let
get_action_value
=
RifRead
.
bool
(
args
.
verbose
>
1
)
in
let
next_activate_val
,
pnal
=
Daemon
.
f
args
.
dummy_input
(
args
.
verbose
>
1
)
args
.
daemon
pl
e
all
enab_ll
get_action_value
in
update_round
next_activate_val
enab_ll
;
let
next_activate_val
=
String
.
concat
" "
(
List
.
map
(
fun
b
->
if
b
then
"t"
else
"f"
)
(
List
.
flatten
next_activate_val
)
)
in
(* 3: Do the steps *)
let
ne
=
Sasacore
.
Step
.
f
pnal
e
in
if
args
.
daemon
<>
Daemon
.
Custom
then
print_step
n
i
args
e
pl
next_activate_val
enab_ll
;
ne
,
next_activate_val
else
e
in
if
args
.
daemon
=
Daemon
.
Custom
then
print_step
n
i
args
e
pl
activate_val
enab_ll
;
(* 2: read the actions *)
let
get_action_value
=
RifRead
.
bool
(
args
.
verbose
>
1
)
in
let
next_activate_val
,
pnal
=
Daemon
.
f
args
.
dummy_input
(
args
.
verbose
>
1
)
args
.
daemon
pl
e
all
enab_ll
get_action_value
in
update_round
next_activate_val
enab_ll
;
let
next_activate_val
=
String
.
concat
" "
(
List
.
map
(
fun
b
->
if
b
then
"t"
else
"f"
)
(
List
.
flatten
next_activate_val
)
)
in
(* 3: Do the steps *)
let
ne
=
Sasacore
.
Step
.
f
pnal
e
in
if
args
.
daemon
<>
Daemon
.
Custom
then
print_step
n
i
args
e
pl
next_activate_val
enab_ll
;
ne
,
next_activate_val
let
rec
(
simuloop
:
int
->
int
->
SasArg
.
t
->
string
->
(
'
v
Process
.
t
*
'
v
Register
.
neighbor
list
)
list
->
'
v
Env
.
t
->
unit
)
=
...
...
@@ -127,7 +159,8 @@ let () =
flush
stdout
|
Legitimate
i
->
let
str
=
if
args
.
rif
then
"#"
else
""
in
Printf
.
eprintf
"
\n
%sThis algo Reached a legitimate configuration after %i moves, %i steps, %i rounds.
\n
"
Printf
.
eprintf
"
\n
%sThis algo Reached a legitimate configuration after %i moves, %i steps, %i rounds.
\n
"
str
!
moves
i
!
rounds
;
flush
stderr
;
flush
stdout
;
...
...
This diff is collapsed.
Click to expand it.
test/unison/state.ml
+
7
−
1
View file @
7770ced6
...
...
@@ -5,7 +5,13 @@ let of_string = None
let
copy
x
=
x
let
actions
=
[
"g"
]
let
potential
=
None
let
fault
=
None
let
fault
m
_
e
=
if
Random
.
bool
()
then
Random
.
int
m
else
e
let
fault
=
Some
fault
let
legitimate
pidl
from_pid
=
(* a legitimate configuration is reached when all states have the same values *)
...
...
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