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
Ruben Asplund
klee_tutorial
Commits
c0eee49c
Commit
c0eee49c
authored
4 years ago
by
Ruben Asplund
Browse files
Options
Downloads
Patches
Plain Diff
Added function reccurence_preemptions()
parent
ceacb8de
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
+39
-28
39 additions, 28 deletions
srp_analysis/src/main.rs
with
39 additions
and
28 deletions
srp_analysis/src/main.rs
+
39
−
28
View file @
c0eee49c
...
@@ -76,28 +76,26 @@ fn main() {
...
@@ -76,28 +76,26 @@ fn main() {
println!
(
"tr: {:?}"
,
tr
);
println!
(
"tr: {:?}"
,
tr
);
print_analysis
(
&
tasks
,
&
ip
,
&
tr
);
print_analysis
(
&
tasks
,
&
ip
,
&
tr
);
}
}
// Prints out vector with [task id, response time, wcet time, blocking time, preemption time]
fn
print_analysis
(
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
{
fn
print_analysis
(
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
{
for
t
in
tasks
{
for
t
in
tasks
{
let
b
=
blocking
(
t
,
&
tasks
,
&
ip
,
&
tr
);
let
b
=
blocking
(
t
,
&
tasks
,
&
ip
,
&
tr
);
let
p
=
preemptions
(
t
,
&
tasks
);
// let p = preemptions(t, &tasks);
let
r
=
response_time
(
t
,
&
tasks
,
&
ip
,
&
tr
);
let
p
=
recurrence_preemption
(
t
,
&
tasks
,
&
ip
,
&
tr
,
true
)
.unwrap
();
let
r
=
response_time
(
t
,
&
tasks
,
&
ip
,
&
tr
,
true
);
let
c
=
wcet
(
t
);
let
c
=
wcet
(
t
);
let
tasks_analysis
=
vec!
[
t
.id
.to_string
(),
r
.to_string
(),
c
.to_string
(),
b
.to_string
(),
p
.to_string
()];
let
tasks_analysis
=
vec!
[
t
.id
.to_string
(),
r
.to_string
(),
c
.to_string
(),
b
.to_string
(),
p
.to_string
()];
println!
(
"{:?}"
,
tasks_analysis
)
println!
(
"{:?}"
,
tasks_analysis
)
}
}
}
}
fn
response_time
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
,
exact_solution
:
bool
)
->
u32
{
fn
response_time
(
task
:
&
T
ask
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
u32
{
let
b
=
blocking
(
t
ask
,
&
tasks
,
&
ip
,
&
tr
);
let
blocking
=
blocking
(
task
,
&
tasks
,
&
ip
,
&
tr
);
let
c
=
wcet
(
task
);
let
wcet
=
wcet
(
task
);
//
let
p = preemptions(task, &tasks
);
let
p
reemption
=
preemption
s
(
task
,
&
tasks
);
let
p
=
recurrence_
preemption
(
task
,
&
tasks
,
&
ip
,
&
tr
,
exact_solution
)
.unwrap
(
);
return
b
locking
+
wcet
+
preemption
;
return
b
+
c
+
p
;
}
}
fn
wcet
(
task
:
&
Task
)
->
u32
{
fn
wcet
(
task
:
&
Task
)
->
u32
{
...
@@ -115,29 +113,42 @@ fn load_factor(tasks: &Tasks) -> f32{
...
@@ -115,29 +113,42 @@ fn load_factor(tasks: &Tasks) -> f32{
return
l_tot
;
return
l_tot
;
}
}
fn
preemptions
(
task
:
&
Task
,
tasks
:
&
Tasks
)
->
u32
{
fn
recurrence_preemption
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
,
exact_solution
:
bool
)
->
Result
<
u32
,
String
>
{
// Find higher or same task prio
if
!
exact_solution
{
let
mut
higher_prio_tasks
=
HashSet
::
new
();
return
Ok
(
preemptions
(
task
,
&
tasks
,
0
,
exact_solution
));
for
t
in
tasks
{
if
t
.id
==
task
.id
{
continue
;
}
}
if
t
.prio
>=
task
.prio
{
let
sum
=
wcet
(
task
)
+
blocking
(
task
,
&
tasks
,
&
ip
,
&
tr
);
higher_prio_tasks
.insert
(
t
.id
.to_string
());
let
mut
current_busy_period
:
u32
=
sum
+
preemptions
(
task
,
&
tasks
,
sum
,
exact_solution
);
loop
{
let
busy_period
:
u32
=
current_busy_period
+
preemptions
(
task
,
&
tasks
,
current_busy_period
,
exact_solution
);
if
current_busy_period
==
busy_period
{
return
Ok
(
busy_period
);
}
if
current_busy_period
>
task
.deadline
{
return
Err
(
"Deadline miss!"
.to_string
());
}
}
current_busy_period
=
busy_period
;
}
}
// Calculate preemptions time (I(t))
}
fn
preemptions
(
task
:
&
Task
,
tasks
:
&
Tasks
,
busy_period
:
u32
,
exact_solution
:
bool
)
->
u32
{
let
mut
p_time
=
0
;
let
mut
p_time
=
0
;
for
t_id
in
higher_prio_tasks
{
let
mut
busy_period
=
busy_period
;
if
!
exact_solution
{
busy_period
=
task
.deadline
;
}
for
t
in
tasks
{
for
t
in
tasks
{
if
t_id
==
t
.id
{
if
t
.id
==
task
.id
{
let
inter_arrival
=
t
.inter_arrival
;
continue
;
let
busy_period
=
t
.deadline
;
p_time
=
p_time
+
wcet
(
t
)
*
(
busy_period
/
inter_arrival
);
}
}
if
t
.prio
>=
task
.prio
{
let
inter_arrival
=
t
.inter_arrival
;
// println!("bp{} ia{}", busy_period, inter_arrival);
p_time
=
p_time
+
wcet
(
t
)
*
(((
busy_period
as
f32
)
/
(
inter_arrival
as
f32
))
.ceil
()
as
u32
);
}
}
}
}
//
println!("{}", p_time);
println!
(
"{}"
,
p_time
);
return
p_time
;
return
p_time
;
}
}
...
...
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