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
7d3e7f55
Commit
7d3e7f55
authored
4 years ago
by
Ruben Asplund
Browse files
Options
Downloads
Patches
Plain Diff
fixed blocking function
parent
41ffd8c2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
srp_analysis/src/analysis.rs
+22
-35
22 additions, 35 deletions
srp_analysis/src/analysis.rs
srp_analysis/src/main.rs
+20
-9
20 additions, 9 deletions
srp_analysis/src/main.rs
with
42 additions
and
44 deletions
srp_analysis/src/analysis.rs
+
22
−
35
View file @
7d3e7f55
...
@@ -104,44 +104,30 @@ pub fn preemptions(task: &Task, tasks: &Tasks, exact: bool) -> Result<u32, Strin
...
@@ -104,44 +104,30 @@ pub fn preemptions(task: &Task, tasks: &Tasks, exact: bool) -> Result<u32, Strin
}
}
pub
fn
blocking
(
task
:
&
Task
,
tasks
:
&
Tasks
)
->
u32
{
pub
fn
blocking
(
task
:
&
Task
,
tasks
:
&
Tasks
)
->
u32
{
let
(
_ip
,
tr
)
=
pre_analysis
(
&
tasks
);
let
(
ip
,
tr
)
=
pre_analysis
(
&
tasks
);
// Checks if the Task is claming a resource
let
mut
max_block
=
0
;
if
!
tr
.contains_key
(
&
task
.id
)
{
return
0
;
}
// Find lower prio tasks that holds a resource
// Find lower prio tasks that holds a resource
let
mut
lower_prio_tasks
=
HashSet
::
new
();
for
t
in
tasks
{
for
t
in
tasks
{
if
t
.prio
<
task
.prio
&&
tr
.contains_key
(
&
t
.id
)
{
if
(
t
.prio
<
task
.prio
)
&&
(
tr
.contains_key
(
&
t
.id
))
&&
(
t
.id
!=
task
.id
)
{
lower_prio_tasks
.insert
(
t
.id
.to_string
());
// All resources t are using
}
let
current_task_resources
=
&
tr
[
&
t
.id
];
}
if
lower_prio_tasks
.len
()
==
0
{
let
mut
blocking_resources
=
HashSet
::
new
();
return
0
;
for
r
in
current_task_resources
{
if
ip
.contains_key
(
r
)
{
let
prio_ceiling
=
&
ip
[
r
];
// Is the resource prio ceiling higher than task prio OR task is using the resource
if
(
prio_ceiling
>
&
task
.prio
)
||
tr
[
&
task
.id
]
.contains
(
r
)
{
blocking_resources
.insert
(
r
);
}
}
let
resources
=
&
tr
[
&
task
.id
];
// println!("{}", &task.id);
// println!("{:?}", tr);
// println!("{:?}", resources);
// Checking every resource it holds
let
mut
max_block
=
0
;
// Iterate through current task resources
for
r1
in
resources
{
// Iterate through lower prio tasks
for
t_id
in
&
lower_prio_tasks
{
let
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
{
if
&
t
.id
==
t_id
{
// Finds the longest blocking time
max_block
=
longest_blocking
(
&
t
.trace
,
r1
);
}
}
}
}
for
r
in
blocking_resources
{
// Finds the longest blocking time with resource r
let
block
=
longest_blocking
(
&
t
.trace
,
r
);
if
max_block
<
block
{
max_block
=
block
;
}
}
}
}
}
}
...
@@ -149,6 +135,7 @@ pub fn blocking(task: &Task, tasks: &Tasks) -> u32 {
...
@@ -149,6 +135,7 @@ pub fn blocking(task: &Task, tasks: &Tasks) -> u32 {
return
max_block
;
return
max_block
;
}
}
// Finds the longest blocking time recursive
fn
longest_blocking
(
trace
:
&
Trace
,
r
:
&
str
)
->
u32
{
fn
longest_blocking
(
trace
:
&
Trace
,
r
:
&
str
)
->
u32
{
let
mut
max_block
=
0
;
let
mut
max_block
=
0
;
if
trace
.id
==
r
{
if
trace
.id
==
r
{
...
...
This diff is collapsed.
Click to expand it.
srp_analysis/src/main.rs
+
20
−
9
View file @
7d3e7f55
...
@@ -5,7 +5,11 @@ use common::*;
...
@@ -5,7 +5,11 @@ use common::*;
fn
main
()
{
fn
main
()
{
let
tasks
=
taskset_1
();
let
tasks
=
taskset_2
();
// let (ip, tr) = pre_analysis(&tasks);
// println!("{:?}", ip);
// println!("{:?}", tr);
println!
(
"CPU load {}"
,
load_factor
(
&
tasks
));
println!
(
"CPU load {}"
,
load_factor
(
&
tasks
));
let
analysis
=
analysis
(
&
tasks
,
true
);
let
analysis
=
analysis
(
&
tasks
,
true
);
...
@@ -14,13 +18,11 @@ fn main() {
...
@@ -14,13 +18,11 @@ fn main() {
a
.task.id
,
a
.response_time
,
a
.wcet
,
a
.blocking_time
,
a
.preemption_time
);
a
.task.id
,
a
.response_time
,
a
.wcet
,
a
.blocking_time
,
a
.preemption_time
);
}
}
if
schedulable_check
(
analysis
)
{
if
schedulable_check
(
analysis
)
{
println!
(
"The taskset is schedulable!"
)
println!
(
"
OK!
The taskset is schedulable!"
)
}
else
{
}
else
{
println!
(
"The taskset is NOT schedulable!"
)
println!
(
"
ERROR!
The taskset is NOT schedulable!"
)
}
}
}
}
fn
taskset_1
()
->
Tasks
{
fn
taskset_1
()
->
Tasks
{
...
@@ -99,12 +101,21 @@ fn taskset_2() -> Tasks {
...
@@ -99,12 +101,21 @@ fn taskset_2() -> Tasks {
id
:
"T1"
.to_string
(),
id
:
"T1"
.to_string
(),
start
:
0
,
start
:
0
,
end
:
15
,
end
:
15
,
inner
:
vec!
[
Trace
{
inner
:
vec!
[
id
:
"R1"
.to_string
(),
Trace
{
id
:
"R3"
.to_string
(),
start
:
2
,
start
:
2
,
end
:
8
,
end
:
8
,
inner
:
vec!
[],
inner
:
vec!
[],
}],
},
Trace
{
id
:
"R1"
.to_string
(),
start
:
9
,
end
:
13
,
inner
:
vec!
[],
},
],
},
},
};
};
...
@@ -149,7 +160,7 @@ fn taskset_2() -> Tasks {
...
@@ -149,7 +160,7 @@ fn taskset_2() -> Tasks {
start
:
0
,
start
:
0
,
end
:
20
,
end
:
20
,
inner
:
vec!
[
Trace
{
inner
:
vec!
[
Trace
{
id
:
"R
2
"
.to_string
(),
id
:
"R
3
"
.to_string
(),
start
:
8
,
start
:
8
,
end
:
20
,
end
:
20
,
inner
:
vec!
[],
inner
:
vec!
[],
...
...
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