Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
klee_tutorial
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
Niklas Lundberg
klee_tutorial
Commits
8ecf733e
Commit
8ecf733e
authored
4 years ago
by
Blinningjr
Browse files
Options
Downloads
Patches
Plain Diff
Finished block time function
parent
2d2f7572
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
srp_analysis/src/main.rs
+41
-15
41 additions, 15 deletions
srp_analysis/src/main.rs
with
41 additions
and
15 deletions
srp_analysis/src/main.rs
+
41
−
15
View file @
8ecf733e
...
...
@@ -104,7 +104,7 @@ fn total_load_factor(tasks: &Tasks) -> f32 {
* worst case. And the task t will not be able to finish in time in the worst case.
*/
fn
cpu_load
(
task
:
&
Task
)
->
f32
{
return
(
wcet
(
task
)
as
f32
)
/
(
task
.inter_arrival
as
f32
)
return
(
wcet
(
&
task
.trace
)
as
f32
)
/
(
task
.inter_arrival
as
f32
)
}
...
...
@@ -112,8 +112,8 @@ fn cpu_load(task: &Task) -> f32 {
* Worst case execution time(WCET) of a task t(C(t)).
* C(t)
*/
fn
wcet
(
t
ask
:
&
Task
)
->
u32
{
return
task
.
trace.end
.wrapping_sub
(
task
.
trace.start
);
fn
wcet
(
t
race
:
&
Trace
)
->
u32
{
return
trace
.end
.wrapping_sub
(
trace
.start
);
}
...
...
@@ -140,6 +140,24 @@ fn response_time(task: &Task) -> u32 {
* Note: B(t) = max(C(l_r)), where P(l) < P(t), π(l_r) >= P(t)
*/
fn
block_time
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
u32
{
/*
* Helper function for finding the trace of a resource using only the id an a trace.
*/
fn
find_res_tr
<
'a
>
(
res_id
:
&
String
,
trace
:
&
'a
Trace
)
->
Option
<&
'a
Trace
>
{
if
trace
.id
==
*
res_id
{
return
Some
(
trace
);
}
else
{
for
tr
in
&
trace
.inner
{
match
find_res_tr
(
res_id
,
tr
)
{
Some
(
val
)
=>
return
Some
(
val
),
None
=>
(),
}
}
}
return
None
;
}
// Find all lower priority tasks
let
mut
lower_prio
:
Vec
<&
Task
>
=
vec!
();
for
t
in
tasks
{
...
...
@@ -148,35 +166,43 @@ fn block_time(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u3
}
}
println!
(
"prio {:?}"
,
task
.prio
);
println!
(
"lower_prio {:?}"
,
lower_prio
);
//
println!("prio {:?}", task.prio);
//
println!("lower_prio {:?}", lower_prio);
// Find all resources that will block the task(resources with a higher of equal priority) from
// the resources that the lower priority tasks use.
let
mut
block_res
:
Vec
<
String
>
=
vec!
();
let
mut
block_res
:
Vec
<
&
Trace
>
=
vec!
();
for
lpt
in
lower_prio
{
match
tr
.get
(
&
lpt
.id
)
{
match
tr
.get
(
&
lpt
.id
)
{
Some
(
resources
)
=>
{
for
r
in
resources
{
if
*
ip
.get
(
r
)
.unwrap
()
>=
task
.prio
{
block_res
.push
(
r
.clone
());
block_res
.push
(
find_res_tr
(
r
,
&
lpt
.trace
)
.unwrap
());
}
}
},
None
=>
(),
};
};
}
println!
(
"block_res {:?}"
,
block_res
);
let
mut
wcets
:
Vec
<
u32
>
=
vec!
();
//println!("block_res {:?}", block_res);
// Calculate the max wcet of the list of blocking resource traces.
let
mut
block_time
:
u32
=
0
;
for
tr
in
block_res
{
let
wcet
=
wcet
(
tr
);
if
wcet
>
block_time
{
block_time
=
wcet
;
}
}
println!
(
"block time {:?}"
,
block_time
);
// TODO: Implement
return
0
;
return
block_time
;
}
/*
* Calculates the interference (preemptions) to task t(I(t)).
* I(t)
...
...
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