Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
klee-examples
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
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
Samuel Karlsson
klee-examples
Commits
8ada6661
Commit
8ada6661
authored
5 years ago
by
Samuel Karlsson
Browse files
Options
Downloads
Patches
Plain Diff
fixes
parent
7d19d448
Branches
master
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
runner/src/bin/generate.rs
+13
-11
13 additions, 11 deletions
runner/src/bin/generate.rs
runner/src/common.rs
+49
-53
49 additions, 53 deletions
runner/src/common.rs
with
62 additions
and
64 deletions
runner/src/bin/generate.rs
+
13
−
11
View file @
8ada6661
...
...
@@ -64,29 +64,31 @@ fn main() {
},
};
let
debug
=
fals
e
;
let
advance
=
fals
e
;
let
debug
=
tru
e
;
let
advance
=
tru
e
;
// builds a vector of tasks t1, t2, t3
// in falling prio order IMPORTENT The order are used
let
mut
tasks
:
Tasks
=
vec!
[
t1
,
t2
,
t3
];
tasks
.sort_by
(|
a
,
b
|
(
a
.prio
)
.partial_cmp
(
&
b
.prio
)
.unwrap
());
tasks
.reverse
();
// tasks.sort_by(|a, b| (a.prio).partial_cmp(&b.prio).unwrap());
// tasks.reverse();
let
(
tp
,
rp
,
tr
,
a
,
dl
)
=
pre_analysis
(
&
tasks
);
let
(
ip
,
tr
)
=
pre_analysis
(
&
tasks
);
let
dl
=
dead_line
(
&
tasks
);
let
c
=
c_times
(
&
tasks
);
let
(
l
,
l_tot
)
=
load
(
&
tasks
,
&
c
);
let
b
=
block
(
&
t
asks
,
&
i
p
,
&
tr
);
let
i
=
interferens
(
&
t
asks
,
&
c
,
advance
);
let
b
=
block
(
&
t
p
,
&
r
p
,
&
tr
);
let
i
=
interferens
(
&
t
p
,
&
c
,
&
a
,
&
dl
,
advance
);
let
r
=
response
(
&
c
,
&
b
,
&
i
);
if
debug
{
println!
(
"Debug data"
);
println!
(
"tasks {:?}"
,
&
tasks
);
println!
(
"ip: {:?}"
,
ip
);
println!
(
"tp: {:?}"
,
tp
);
println!
(
"rp: {:?}"
,
rp
);
println!
(
"tr: {:?}"
,
tr
);
println!
(
"DeadLine: {:?}"
,
dl
);
println!
(
"A: {:?}"
,
a
);
println!
(
"C(t): {:?}"
,
c
);
println!
(
"L(t): {:?}"
,
l
);
println!
(
"L(T): {:?}"
,
l_tot
);
...
...
@@ -101,7 +103,7 @@ fn main() {
}
// WARNIGN assums 0 overhead
fn
test
(
dl
:
d
ata
,
l
:
f32
,
r
:
&
d
ata
)
{
fn
test
(
dl
:
D
ata
,
l
:
f32
,
r
:
&
D
ata
)
{
println!
(
"TEST of real time critarias"
);
if
l
<=
1.0
{
println!
(
"Load test SUCSES"
);
...
...
@@ -119,7 +121,7 @@ fn test(dl: data, l: f32, r: &data) {
println!
(
""
);
}
fn
analys_data
(
tasks
:
&
Tasks
,
l
:
L
,
r
:
&
d
ata
,
c
:
d
ata
,
b
:
d
ata
,
i
:
d
ata
,
load
:
f32
){
fn
analys_data
(
tasks
:
&
Tasks
,
l
:
L
,
r
:
&
D
ata
,
c
:
D
ata
,
b
:
D
ata
,
i
:
D
ata
,
load
:
f32
){
println!
(
"The data for analyse"
);
println!
(
"Total load {}%"
,
load
);
println!
(
"ID | L | R | C | B | I | PRIO "
);
...
...
This diff is collapsed.
Click to expand it.
runner/src/common.rs
+
49
−
53
View file @
8ada6661
...
...
@@ -33,20 +33,22 @@ pub type IdPrio = HashMap<String, u8>;
// id_task, {id_res, longest}
pub
type
TaskResources
=
HashMap
<
String
,
Vec
<
HashMap
<
String
,
u32
>>>
;
pub
type
d
ata
=
HashMap
<
String
,
u32
>
;
pub
type
D
ata
=
HashMap
<
String
,
u32
>
;
pub
type
L
=
HashMap
<
String
,
f32
>
;
// Derives the above maps from a set of tasks
pub
fn
pre_analysis
(
tasks
:
&
Tasks
)
->
(
IdPrio
,
TaskResources
)
{
let
mut
ip
=
HashMap
::
new
();
pub
fn
pre_analysis
(
tasks
:
&
Tasks
)
->
(
IdPrio
,
IdPrio
,
TaskResources
,
Data
,
Data
)
{
let
mut
tp
=
HashMap
::
new
();
let
mut
rp
=
HashMap
::
new
();
let
mut
tr
:
TaskResources
=
HashMap
::
new
();
for
t
in
tasks
{
update_prio
(
t
.prio
,
&
t
.trace
,
&
mut
ip
);
update_prio
(
t
.prio
,
&
t
.trace
,
&
mut
rp
);
tp
.insert
(
t
.id
.clone
(),
t
.prio
);
for
i
in
&
t
.trace.inner
{
update_tr
(
t
.id
.clone
(),
i
,
&
mut
tr
);
}
}
(
ip
,
tr
)
(
tp
,
rp
,
tr
,
inter_arival
(
&
tasks
),
dead_line
(
&
tasks
)
)
}
// helper functions
...
...
@@ -91,7 +93,7 @@ fn update_tr(s: String, trace: &Trace, trmap: &mut TaskResources) {
}
}
pub
fn
c_times
(
tasks
:
&
Tasks
)
->
d
ata
{
pub
fn
c_times
(
tasks
:
&
Tasks
)
->
D
ata
{
let
mut
c
=
HashMap
::
new
();
for
t
in
tasks
{
c
.insert
(
t
.id
.clone
(),
t
.trace.end
-
t
.trace.start
);
...
...
@@ -99,7 +101,7 @@ pub fn c_times(tasks: &Tasks) -> data {
c
}
pub
fn
load
(
tasks
:
&
Tasks
,
c
:
&
d
ata
)
->
(
L
,
f32
){
pub
fn
load
(
tasks
:
&
Tasks
,
c
:
&
D
ata
)
->
(
L
,
f32
){
let
mut
l
=
HashMap
::
new
();
let
mut
tot
=
0.0
;
for
t
in
tasks
{
...
...
@@ -111,35 +113,33 @@ pub fn load(tasks: &Tasks, c: &data) -> (L, f32){
(
l
,
tot
)
}
pub
fn
block
(
t
asks
:
&
Tasks
,
i
p
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
d
ata
{
pub
fn
block
(
t
p
:
&
IdPrio
,
r
p
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
D
ata
{
let
mut
b
=
HashMap
::
new
();
for
t
in
tasks
{
for
(
task_id
,
task_prio
)
in
tp
{
let
mut
block_time
=
0
;
let
resourses
=
tr
.get
(
&
t
.
id
);
let
resourses
=
tr
.get
(
task_
id
);
match
resourses
{
Some
(
res
)
=>
{
for
vectorn
in
res
{
for
(
id
,
_
)
in
vectorn
{
// iter this, all res
for
(
tr_id
,
tr_
ha
s
)
in
tr
{
if
i
p
.get
(
tr_id
)
.unwrap
()
<
&
t
.
prio
{
for
(
tr_id
,
tr_
resorse
s
)
in
tr
{
if
r
p
.get
(
tr_id
)
.unwrap
()
<
task_
prio
{
for
bl
in
tr_
ha
s
{
for
bl
in
tr_
resorse
s
{
if
let
Some
(
time
)
=
bl
.get
(
id
)
{
block_time
+=
time
;
}
}
}
}
}
}
b
.insert
(
t
.
id
.clone
(),
block_time
);
b
.insert
(
t
ask_
id
.clone
(),
block_time
);
},
None
=>
{
b
.insert
(
t
.
id
.clone
(),
0
);
b
.insert
(
t
ask_
id
.clone
(),
0
);
},
}
...
...
@@ -147,48 +147,44 @@ pub fn block(tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> data {
b
}
pub
fn
interferens
(
tasks
:
&
Tasks
,
c
:
&
data
,
advance
:
bool
)
->
data
{
pub
fn
interferens
(
tp
:
&
IdPrio
,
c
:
&
Data
,
a
:
&
Data
,
dl
:
&
Data
,
advance
:
bool
)
->
Data
{
let
mut
i
=
HashMap
::
new
();
let
a
=
inter_arival
(
&
tasks
);
i
.insert
(
tasks
[
0
]
.id
.clone
(),
0
);
if
!
advance
{
for
index
in
1
..
tasks
.len
()
{
for
(
id_curent
,
prio_curent
)
in
tp
{
let
mut
sum
=
0
;
for
index2
in
0
..
index
{
let
id
=
&
tasks
[
index2
]
.id
;
sum
+=
block_eq
(
*
a
.get
(
&
tasks
[
index
]
.id
)
.unwrap
(),
*
a
.get
(
id
)
.unwrap
(),
*
c
.get
(
id
)
.unwrap
());
let
mut
block
=
*
dl
.get
(
&
id_curent
.clone
())
.unwrap
();
if
advance
{
block
=
*
c
.get
(
&
id_curent
.clone
())
.unwrap
();
}
i
.insert
(
tasks
[
index
]
.id
.clone
(),
sum
);
}
}
else
{
for
index
in
1
..
tasks
.len
()
{
let
mut
sum
=
0
;
let
mut
block
=
*
c
.get
(
&
tasks
[
index
]
.id
)
.unwrap
();
let
mut
temp
=
0
;
while
sum
<
block
{
sum
=
block
;
temp
=
block
;
let
mut
part
=
0
;
for
index2
in
0
..
index
{
let
id
=
&
tasks
[
index2
]
.id
;
part
+=
block_eq
(
block
,
*
a
.get
(
id
)
.unwrap
(),
*
c
.get
(
id
)
.unwrap
());
for
(
id_ref
,
prio_ref
)
in
tp
{
if
*
id_curent
==
*
id_ref
{
continue
;
}
else
{
if
*
prio_curent
==
*
prio_ref
{
part
+=
*
c
.get
(
id_ref
)
.unwrap
();
}
else
if
prio_curent
<
prio_ref
{
part
+=
block_eq
(
block
,
*
a
.get
(
id_ref
)
.unwrap
(),
*
c
.get
(
id_ref
)
.unwrap
());
}
block
=
part
;
}
i
.insert
(
tasks
[
index
]
.id
.clone
(),
sum
);
}
block
=
part
;
sum
=
part
;
if
!
advance
{
break
;}
}
i
.insert
(
id_curent
.clone
(),
sum
);
}
i
}
fn
block_eq
(
block
:
u32
,
a
:
u32
,
c
:
u32
)
->
u32
{
return
ceil
(
block
as
f64
/
a
as
f64
,
0
)
as
u32
*
c
;
}
fn
inter_arival
(
tasks
:
&
Tasks
)
->
d
ata
{
fn
inter_arival
(
tasks
:
&
Tasks
)
->
D
ata
{
let
mut
a
=
HashMap
::
new
();
for
t
in
tasks
{
a
.insert
(
t
.id
.clone
(),
t
.inter_arrival
.clone
());
...
...
@@ -196,7 +192,7 @@ fn inter_arival(tasks: &Tasks) -> data {
a
}
pub
fn
response
(
c
:
&
d
ata
,
b
:
&
d
ata
,
i
:
&
d
ata
)
->
d
ata
{
pub
fn
response
(
c
:
&
D
ata
,
b
:
&
D
ata
,
i
:
&
D
ata
)
->
D
ata
{
let
mut
r
=
HashMap
::
new
();
for
(
id
,
tim
)
in
c
{
r
.insert
(
id
.clone
(),
tim
+
b
.get
(
id
)
.unwrap
()
+
i
.get
(
id
)
.unwrap
());
...
...
@@ -204,7 +200,7 @@ pub fn response(c: &data, b: &data, i: &data) -> data {
r
}
pub
fn
dead_line
(
tasks
:
&
Tasks
)
->
d
ata
{
fn
dead_line
(
tasks
:
&
Tasks
)
->
D
ata
{
let
mut
dl
=
HashMap
::
new
();
for
t
in
tasks
{
dl
.insert
(
t
.id
.clone
(),
t
.deadline
);
...
...
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