Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtic_f4xx_nucleo
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Edvin Åkerfeldt
rtic_f4xx_nucleo
Commits
9ef1a8df
Commit
9ef1a8df
authored
4 years ago
by
Edvin Åkerfeldt
Browse files
Options
Downloads
Patches
Plain Diff
3 done, also changed so MAX_R is always assigned
parent
7bf39007
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
examples/timing_exam.rs
+59
-15
59 additions, 15 deletions
examples/timing_exam.rs
with
59 additions
and
15 deletions
examples/timing_exam.rs
+
59
−
15
View file @
9ef1a8df
...
@@ -48,19 +48,21 @@ const APP: () = {
...
@@ -48,19 +48,21 @@ const APP: () = {
// emulates timing behavior of t1
// emulates timing behavior of t1
cortex_m
::
asm
::
delay
(
10_000
);
cortex_m
::
asm
::
delay
(
10_000
);
asm
::
bkpt
();
// 2) your code here to update T1_MAX_RP and
// 2) your code here to update T1_MAX_RP and
// break if deadline missed
// break if deadline missed
let
resp
:
u32
=
cx
.scheduled
.elapsed
()
.as_cycles
();
let
resp
:
u32
=
cx
.scheduled
.elapsed
()
.as_cycles
();
asm
::
bkpt
();
if
resp
>
100_000
{
if
resp
>
100_000
{
//panic!();
//panic!();
asm
::
bkpt
();
asm
::
bkpt
();
}
else
{
}
unsafe
{
unsafe
{
if
resp
>
T1_MAX_RP
{
if
resp
>
T1_MAX_RP
{
T1_MAX_RP
=
resp
;
T1_MAX_RP
=
resp
;
}
}
}
}
}
asm
::
bkpt
();
}
}
// Deadline 200, Inter-arrival 200
// Deadline 200, Inter-arrival 200
...
@@ -81,7 +83,9 @@ const APP: () = {
...
@@ -81,7 +83,9 @@ const APP: () = {
asm
::
delay
(
2_000
);
asm
::
delay
(
2_000
);
// R2 : claim
// R2 : claim
cx
.resources.R2
.lock
(|
r2
|
{
cx
.resources.R2
.lock
(|
r2
|
{
*
r2
=
1338
;
asm
::
delay
(
4_000
);
asm
::
delay
(
4_000
);
*
r2
=
1668
;
});
});
// R2 : release
// R2 : release
asm
::
delay
(
4_000
);
asm
::
delay
(
4_000
);
...
@@ -93,19 +97,20 @@ const APP: () = {
...
@@ -93,19 +97,20 @@ const APP: () = {
asm
::
delay
(
2_000
);
asm
::
delay
(
2_000
);
// == End trace ==
// == End trace ==
asm
::
bkpt
();
// 2) your code here to update T2_MAX_RP and
// 2) your code here to update T2_MAX_RP and
// break if deadline missed
// break if deadline missed
let
resp
:
u32
=
cx
.scheduled
.elapsed
()
.as_cycles
();
let
resp
:
u32
=
cx
.scheduled
.elapsed
()
.as_cycles
();
if
resp
>
200_000
{
if
resp
>
200_000
{
//panic!();
//panic!();
asm
::
bkpt
();
asm
::
bkpt
();
}
else
{
}
unsafe
{
unsafe
{
if
resp
>
T2_MAX_RP
{
if
resp
>
T2_MAX_RP
{
T2_MAX_RP
=
resp
;
T2_MAX_RP
=
resp
;
}
}
}
}
}
asm
::
bkpt
();
}
}
// Deadline 50, Inter-arrival 50
// Deadline 50, Inter-arrival 50
...
@@ -122,24 +127,26 @@ const APP: () = {
...
@@ -122,24 +127,26 @@ const APP: () = {
// == Begin trace ==
// == Begin trace ==
asm
::
delay
(
10_000
);
asm
::
delay
(
10_000
);
// R2 : claim
// R2 : claim
*
cx
.resources.R2
=
1337
;
asm
::
delay
(
10_000
);
asm
::
delay
(
10_000
);
// R2 : release
// R2 : release
asm
::
delay
(
10_000
);
asm
::
delay
(
10_000
);
// == End trace ==
// == End trace ==
asm
::
bkpt
();
// 2) your code here to update T3_MAX_RP and
// 2) your code here to update T3_MAX_RP and
// break if deadline missed
// break if deadline missed
let
resp
:
u32
=
cx
.scheduled
.elapsed
()
.as_cycles
();
let
resp
:
u32
=
cx
.scheduled
.elapsed
()
.as_cycles
();
if
resp
>
50_000
{
if
resp
>
50_000
{
//panic!();
//panic!();
asm
::
bkpt
();
asm
::
bkpt
();
}
else
{
}
unsafe
{
unsafe
{
if
resp
>
T3_MAX_RP
{
if
resp
>
T3_MAX_RP
{
T3_MAX_RP
=
resp
;
T3_MAX_RP
=
resp
;
}
}
}
}
}
asm
::
bkpt
();
}
}
// RTIC requires that unused interrupts are declared in an extern block when
// RTIC requires that unused interrupts are declared in an extern block when
...
@@ -276,62 +283,99 @@ Because multiple tasks can access these variables, rust can't ensure that the re
...
@@ -276,62 +283,99 @@ Because multiple tasks can access these variables, rust can't ensure that the re
// 3A) Why is there an offset 50240 (instead of 50000)?
// 3A) Why is there an offset 50240 (instead of 50000)?
//
//
// [Your answer here]
// [Your answer here]
/*
Because of the context-switching into the task.
*/
//
//
// 3B) Why is the calculated response time larger than the
// 3B) Why is the calculated response time larger than the
// delays you inserted to simulate workload?
// delays you inserted to simulate workload?
//
//
// [Your answer here]
// [Your answer here]
/*
Because of the context switching and the amount of instructions it takes to re-schedule T3.
*/
//
//
// 3C) Why is the second arrival of `t3` further delayed?
// 3C) Why is the second arrival of `t3` further delayed?
//
//
// [Your answer here]
// [Your answer here]
// Hint, think about what happens at time 100_000, what tasks
// Hint, think about what happens at time 100_000, what tasks
// are set to `arrive` at that point compared to time 50_000.
// are set to `arrive` at that point compared to time 50_000.
/*
Because their has to be a preemption check between t3 and t1 because they are scheduled for the same instance.
*/
//
//
// 3D) What is the scheduled time for task `t1` (130595 is the
// 3D) What is the scheduled time for task `t1` (130595 is the
// measured time according to CYCYCNT).
// measured time according to CYCYCNT).
//
//
// [Your answer here]
// [Your answer here]
/*
Scheduled time is 100_000.
*/
//
//
// Why is the measured value much higher than the scheduled time?
// Why is the measured value much higher than the scheduled time?
//
//
// [Your answer here]
// [Your answer here]
/*
Because t1 has been preempted by t3 and is not allowed to run until t3 is done executing.
*/
//
//
// Now you can continue until you get a first update of `T1_MAX_RP`.
// Now you can continue until you get a first update of `T1_MAX_RP`.
//
//
// What is the first update of `T1_MAX_RP`?
// What is the first update of `T1_MAX_RP`?
//
//
// [Your answer here]
// [Your answer here]
/*
T1_MAX_RP: 40704
*/
//
//
// Explain the obtained value in terms of:
// Explain the obtained value in terms of:
// Execution time, blocking and preemptions
// Execution time, blocking and preemptions
// (that occurred for this task instance).
// (that occurred for this task instance).
//
//
// [Your answer here]
// [Your answer here]
/*
WCET for t1 is roughly ~= 10_000 (Give or take, beacause of the context switching)
B(t1) = 0, because t1 doesn't share any resources (in fact it doesn't have any) with other tasks it can never be blocked.
I(t1) = R(t3), t1 has to wait for t3 (and only t3) to execute. The preemption time is the responsetime of t3.
*/
//
//
// Now continue until you get a first timing measurement for `T2_MAX_RP`.
// Now continue until you get a first timing measurement for `T2_MAX_RP`.
//
//
// What is the first update of `T2_MAX_RP`?
// What is the first update of `T2_MAX_RP`?
//
//
// [Your answer here]
// [Your answer here]
/*
T2_MAX_RP: 91_224
*/
//
//
// Now continue until you get a second timing measurement for `T1_MAX_RP`.
// Now continue until you get a second timing measurement for `T1_MAX_RP`.
//
//
// What is the second update of `T3_MAX_RP`?
// What is the second update of `T3_MAX_RP`?
//
//
// [Your answer here]
// [Your answer here]
/*
I'm assuming we're suppose to check the second update of T1_MAX_RP.
T1_MAX_RP: 131_992
*/
//
//
// Now you should have ended up in a deadline miss right!!!!
// Now you should have ended up in a deadline miss right!!!!
//
//
// Why did this happen?
// Why did this happen?
//
//
// [Your answer here]
// [Your answer here]
/*
Because t1 has the lowest priority of all the tasks and they all happend at once t1 got preempted to the point it could no longer hold its deadline.
*/
//
//
// Compare that to the result obtained from your analysis tool.
// Compare that to the result obtained from your analysis tool.
//
//
// Do they differ, if so why?
// Do they differ, if so why?
//
//
// [Your answer here]
// [Your answer here]
/*
In the analysis this scheduling works out fine (even if its a tight squeeze) but that's because all the times are exact.
In this real life example we have some longer responsetimes which means it doesn't hold.
*/
//
//
// Commit your repository once you completed this part.
// Commit your repository once you completed this part.
//
//
...
...
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