Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
LARA
inox
Commits
d93606fa
Commit
d93606fa
authored
8 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
using Random to model threads
parent
a102909c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
library/util/Random.scala
+0
-1
0 additions, 1 deletion
library/util/Random.scala
testcases/verification/xlang/DataRacing.scala
+42
-0
42 additions, 0 deletions
testcases/verification/xlang/DataRacing.scala
with
42 additions
and
1 deletion
library/util/Random.scala
+
0
−
1
View file @
d93606fa
...
@@ -29,4 +29,3 @@ object Random {
...
@@ -29,4 +29,3 @@ object Random {
}
ensuring
(
res
=>
res
>=
0
&&
res
<
max
)
}
ensuring
(
res
=>
res
>=
0
&&
res
<
max
)
}
}
This diff is collapsed.
Click to expand it.
testcases/verification/xlang/DataRacing.scala
0 → 100644
+
42
−
0
View file @
d93606fa
import
leon.lang._
import
leon.lang.xlang._
import
leon.util.Random
import
leon.collection._
object
DataRacing
{
case
class
SharedState
(
var
i
:
Int
)
case
class
AtomicInstr
(
instr
:
(
SharedState
)
=>
Unit
)
implicit
def
toInstr
(
instr
:
(
SharedState
)
=>
Unit
)
:
AtomicInstr
=
AtomicInstr
(
instr
)
def
execute
(
t1
:
List
[
AtomicInstr
],
t2
:
List
[
AtomicInstr
],
state
:
SharedState
)
:
Unit
=
(
t1
,
t2
)
match
{
case
(
x
::
xs
,
y
::
ys
)
=>
if
(
Random
.
nextBoolean
)
{
x
.
instr
(
state
)
execute
(
xs
,
y
::
ys
,
state
)
}
else
{
y
.
instr
(
state
)
execute
(
x
::
xs
,
ys
,
state
)
}
case
(
Nil
(),
y
::
ys
)
=>
y
.
instr
(
state
)
execute
(
Nil
(),
ys
,
state
)
case
(
x
::
xs
,
Nil
())
=>
x
.
instr
(
state
)
execute
(
xs
,
Nil
(),
state
)
case
(
Nil
(),
Nil
())
=>
()
}
def
main
()
:
Unit
=
{
val
state
=
SharedState
(
0
)
val
t1
=
List
[
AtomicInstr
]((
s
:
SharedState
)
=>
s
.
i
=
s
.
i
+
1
)
val
t2
=
List
[
AtomicInstr
]((
s
:
SharedState
)
=>
s
.
i
=
s
.
i
*
2
)
execute
(
t1
,
t2
,
state
)
assert
(
state
.
i
==
2
)
}
}
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