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
04f32dd5
Commit
04f32dd5
authored
4 years ago
by
Ruben Asplund
Browse files
Options
Downloads
Patches
Plain Diff
Added a recursive function to blocking
parent
570955e0
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
+66
-14
66 additions, 14 deletions
srp_analysis/src/main.rs
with
66 additions
and
14 deletions
srp_analysis/src/main.rs
+
66
−
14
View file @
04f32dd5
...
@@ -77,8 +77,6 @@ fn main() {
...
@@ -77,8 +77,6 @@ fn main() {
print_analysis
(
&
tasks
,
&
ip
,
&
tr
);
print_analysis
(
&
tasks
,
&
ip
,
&
tr
);
let
test
=
(
10.0
as
f32
/
30.0
as
f32
)
.ceil
();
println!
(
"Test {}"
,
test
);
}
}
// Prints out vector with [task id, response time, wcet time, blocking time, preemption time]
// 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
)
{
...
@@ -139,7 +137,7 @@ fn preemptions_exact(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources
...
@@ -139,7 +137,7 @@ fn preemptions_exact(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources
new_busy_period
=
new_busy_period
+
wcet
(
t
)
*
(((
busy_period
as
f32
)
/
(
t
.inter_arrival
as
f32
))
.ceil
()
as
u32
);
new_busy_period
=
new_busy_period
+
wcet
(
t
)
*
(((
busy_period
as
f32
)
/
(
t
.inter_arrival
as
f32
))
.ceil
()
as
u32
);
}
}
}
}
println!
(
"nb {}, b {}"
,
new_busy_period
,
busy_period
);
//
println!("nb {}, b {}", new_busy_period, busy_period);
if
new_busy_period
.wrapping_sub
(
base_case
)
==
0
{
if
new_busy_period
.wrapping_sub
(
base_case
)
==
0
{
return
Ok
(
0
);
return
Ok
(
0
);
}
else
if
new_busy_period
>
task
.deadline
{
}
else
if
new_busy_period
>
task
.deadline
{
...
@@ -162,30 +160,83 @@ fn preemptions(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources, exac
...
@@ -162,30 +160,83 @@ fn preemptions(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources, exac
fn
blocking
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
u32
{
fn
blocking
(
task
:
&
Task
,
tasks
:
&
Tasks
,
ip
:
&
IdPrio
,
tr
:
&
TaskResources
)
->
u32
{
// Checks if the Task is claming a resource
// Checks if the Task is claming a resource
if
!
tr
.contains_key
(
&
task
.id
)
{
if
!
tr
.contains_key
(
&
task
.id
)
{
// println!("0");
return
0
;
return
0
;
}
}
// Find lower prio tasks
// Find lower prio tasks
that holds a resource
let
mut
lower_prio_tasks
=
HashSet
::
new
();
let
mut
lower_prio_tasks
=
HashSet
::
new
();
for
t
in
tasks
{
for
t
in
tasks
{
if
t
.prio
<
task
.prio
{
if
t
.prio
<
task
.prio
&&
tr
.contains_key
(
&
t
.id
)
{
lower_prio_tasks
.insert
(
t
.id
.to_string
());
lower_prio_tasks
.insert
(
t
.id
.to_string
());
}
}
}
}
// Do these task hold a resource, if not delete from list
if
lower_prio_tasks
.len
()
==
0
{
return
0
;
}
let
resources
=
&
tr
[
&
task
.id
];
println!
(
"{}"
,
&
task
.id
);
println!
(
"{:?}"
,
tr
);
println!
(
"{:?}"
,
resources
);
// Checking every resource it holds
let
mut
max_block
=
0
;
let
mut
current_block
=
0
;
// Iterate through current task resources
for
r1
in
resources
{
// Iterate through lower prio tasks
for
t_id
in
&
lower_prio_tasks
{
let
mut
lower_prio_task_resources
=
&
tr
[
t_id
];
// Iterate through lower prio task resources
for
r2
in
lower_prio_task_resources
{
// When current task use the same resource as a task
if
r1
==
r2
{
// Takes forward the blocking task
for
t
in
tasks
{
for
t
in
tasks
{
if
!
lower_prio_tasks
.contains
(
&
t
.id
)
{
if
&
t
.id
==
t_id
{
continue
;
max_block
=
longest_blocking
(
&
t
.trace
,
r1
);
}
}
}
}
}
if
!
tr
.contains_key
(
&
t
.id
)
{
}
lower_prio_tasks
.remove
(
&
t
.id
);
}
return
max_block
;
}
fn
longest_blocking
(
trace
:
&
Trace
,
r
:
&
str
)
->
u32
{
let
mut
max_block
=
0
;
if
trace
.id
==
r
{
max_block
=
trace
.end
.wrapping_sub
(
trace
.start
);
}
if
trace
.inner
.len
()
!=
0
{
for
inner
in
&
trace
.inner
{
let
block
=
longest_blocking
(
&
inner
,
r
);
if
max_block
<
block
{
max_block
=
block
;
}
}
}
return
max_block
;
}
/*
fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32 {
// Checks if the Task is claming a resource
if !tr.contains_key(&task.id) {
return 0;
}
// Find lower prio tasks that holds a resource
let mut lower_prio_tasks = HashSet::new();
for t in tasks {
if t.prio < task.prio && tr.contains_key(&t.id) {
lower_prio_tasks.insert(t.id.to_string());
}
}
}
}
if lower_prio_tasks.len() == 0 {
if lower_prio_tasks.len() == 0 {
return 0;
return 0;
}
}
/* Finding longest blocking */
let resources = &tr[&task.id];
let resources = &tr[&task.id];
println!("{:?}", tr);
println!("{:?}", resources);
// Checking every resource it holds
// Checking every resource it holds
let mut max_block = 0;
let mut max_block = 0;
let mut current_block = 0;
let mut current_block = 0;
...
@@ -234,3 +285,4 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32
...
@@ -234,3 +285,4 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32
}
}
return max_block;
return max_block;
}
}
*/
\ No newline at end of file
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