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
e2876ba7
Commit
e2876ba7
authored
4 years ago
by
Blinningjr
Browse files
Options
Downloads
Patches
Plain Diff
Implemented exact preemptions
parent
5f5852ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
srp_analysis/src/main.rs
+38
-29
38 additions, 29 deletions
srp_analysis/src/main.rs
with
38 additions
and
29 deletions
srp_analysis/src/main.rs
+
38
−
29
View file @
e2876ba7
...
@@ -74,7 +74,7 @@ fn main() {
...
@@ -74,7 +74,7 @@ fn main() {
println!
(
"ip: {:?}"
,
ip
);
println!
(
"ip: {:?}"
,
ip
);
println!
(
"tr: {:?}"
,
tr
);
println!
(
"tr: {:?}"
,
tr
);
let
analysis
=
analyse
(
&
tasks
,
&
ip
,
&
tr
);
let
analysis
=
analyse
(
&
tasks
,
&
ip
,
&
tr
,
true
);
println!
(
"Analysis {:#?}"
,
analysis
);
println!
(
"Analysis {:#?}"
,
analysis
);
}
}
...
@@ -124,9 +124,9 @@ fn wcet(trace: &Trace) -> u32 {
...
@@ -124,9 +124,9 @@ fn wcet(trace: &Trace) -> u32 {
* - B(t) is the blocking time for task t, and
* - B(t) is the blocking time for task t, and
* - I(t) is the interference (preemptions) to task t
* - I(t) is the interference (preemptions) to task t
*/
*/
fn
response_time
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
u32
{
fn
response_time
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
,
approx
:
bool
)
->
u32
{
let
r
:
u32
=
block_time
(
task
,
tasks
,
ip
,
tr
)
+
wcet
(
&
task
.trace
)
+
interference_time
(
task
,
tasks
);
let
r
:
u32
=
block_time
(
task
,
tasks
,
ip
,
tr
)
+
wcet
(
&
task
.trace
)
+
interference_time
(
task
,
tasks
,
ip
,
tr
,
approx
)
.unwrap
(
);
println!
(
"response_time {:?}"
,
r
);
//
println!("response_time {:?}", r);
return
r
;
return
r
;
}
}
...
@@ -194,7 +194,7 @@ fn block_time(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u3
...
@@ -194,7 +194,7 @@ fn block_time(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u3
}
}
}
}
println!
(
"block time {:?}"
,
block_time
);
//
println!("block time {:?}", block_time);
return
block_time
;
return
block_time
;
}
}
...
@@ -208,28 +208,37 @@ fn block_time(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u3
...
@@ -208,28 +208,37 @@ fn block_time(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u3
* Note: I(t) = sum(C(h) * ceiling(Bp(t)/A(h))), forall tasks h, P(h) > P(t), where
* Note: I(t) = sum(C(h) * ceiling(Bp(t)/A(h))), forall tasks h, P(h) > P(t), where
* Bp(t) is the busy-period
* Bp(t) is the busy-period
*/
*/
fn
interference_time
(
task
:
&
Task
,
tasks
:
&
Tasks
)
->
u32
{
fn
interference_time
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
,
approx
:
bool
)
->
Result
<
u32
,
String
>
{
fn
calc_interference
(
task
:
&
Task
,
tasks
:
&
Tasks
,
busy_period
:
u32
)
->
u32
{
let
mut
interference
:
u32
=
0
;
let
mut
interference
:
u32
=
0
;
for
t
in
tasks
{
for
t
in
tasks
{
if
t
.prio
>
task
.prio
{
if
t
.prio
>
task
.prio
{
interference
+=
wcet
(
&
t
.trace
)
*
(((
busy_period
(
t
)
as
f32
)
/
(
t
.inter_arrival
as
f32
))
.ceil
()
as
u32
);
interference
+=
wcet
(
&
t
.trace
)
*
(((
busy_period
as
f32
)
/
(
t
.inter_arrival
as
f32
))
.ceil
()
as
u32
);
}
}
}
}
println!
(
"interference_time {:?}"
,
interference
);
return
interference
;
return
interference
;
}
}
if
approx
{
/*
let
interference
:
u32
=
calc_interference
(
task
,
tasks
,
task
.deadline
);
* Caclulates the busy period of task t(Bp(t)).
//println!("interference_time {:?}", interference);
* Bp(t)
return
Ok
(
interference
);
*
}
else
{
* Note: We can over approximate the busy period Bp(i) = D(i) (assuming the worst allowed busy-period).
let
constant
=
block_time
(
task
,
tasks
,
ip
,
tr
)
+
wcet
(
&
task
.trace
);
* D(i) is the deadline of task i.
let
mut
busy_period
:
u32
=
constant
+
calc_interference
(
task
,
tasks
,
constant
);
*/
loop
{
fn
busy_period
(
task
:
&
Task
)
->
u32
{
if
busy_period
>
task
.deadline
{
return
task
.deadline
;
return
Err
(
"Busy period is longer then deadline"
.to_string
());
}
else
{
let
new_busy_period
:
u32
=
constant
+
calc_interference
(
task
,
tasks
,
busy_period
);
if
busy_period
==
new_busy_period
{
return
Ok
(
new_busy_period
-
constant
);
}
else
{
busy_period
=
new_busy_period
;
}
}
}
}
}
}
...
@@ -239,13 +248,13 @@ fn busy_period(task: &Task) -> u32 {
...
@@ -239,13 +248,13 @@ fn busy_period(task: &Task) -> u32 {
* Note: Finally, make a function that iterates over the task set and returns a vector with containing:
* Note: Finally, make a function that iterates over the task set and returns a vector with containing:
Vec<Task, R(t), C(t), B(t), I(t)>. Just a simple println! of that vector gives the essential information on the analysis.
Vec<Task, R(t), C(t), B(t), I(t)>. Just a simple println! of that vector gives the essential information on the analysis.
*/
*/
fn
analyse
(
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
Vec
<
(
Task
,
u32
,
u32
,
u32
,
u32
)
>
{
fn
analyse
(
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
,
approx
:
bool
)
->
Vec
<
(
Task
,
u32
,
u32
,
u32
,
u32
)
>
{
let
mut
analysis
:
Vec
<
(
Task
,
u32
,
u32
,
u32
,
u32
)
>
=
vec!
();
let
mut
analysis
:
Vec
<
(
Task
,
u32
,
u32
,
u32
,
u32
)
>
=
vec!
();
for
t
in
tasks
{
for
t
in
tasks
{
let
r_t
=
response_time
(
t
,
tasks
,
ip
,
tr
);
let
r_t
=
response_time
(
t
,
tasks
,
ip
,
tr
,
approx
);
let
c_t
=
wcet
(
&
t
.trace
);
let
c_t
=
wcet
(
&
t
.trace
);
let
b_t
=
block_time
(
t
,
tasks
,
ip
,
tr
);
let
b_t
=
block_time
(
t
,
tasks
,
ip
,
tr
);
let
i_t
=
interference_time
(
t
,
tasks
);
let
i_t
=
interference_time
(
t
,
tasks
,
ip
,
tr
,
approx
)
.unwrap
(
);
analysis
.push
((
t
.clone
(),
r_t
,
c_t
,
b_t
,
i_t
));
analysis
.push
((
t
.clone
(),
r_t
,
c_t
,
b_t
,
i_t
));
}
}
return
analysis
;
return
analysis
;
...
...
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