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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Niklas Lundberg
rtic_f4xx_nucleo
Commits
2b8e24e5
Commit
2b8e24e5
authored
4 years ago
by
Blinningjr
Browse files
Options
Downloads
Patches
Plain Diff
Improved my answers in tinming_resources
parent
cd8a796d
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_resources.rs
+32
-13
32 additions, 13 deletions
examples/timing_resources.rs
with
32 additions
and
13 deletions
examples/timing_resources.rs
+
32
−
13
View file @
2b8e24e5
...
@@ -83,6 +83,11 @@ const APP: () = {
...
@@ -83,6 +83,11 @@ const APP: () = {
// msr basepri, r0 = Writes the value of r0 into coprocessor register basepri.
// msr basepri, r0 = Writes the value of r0 into coprocessor register basepri.
// bx lr =
// bx lr =
//
//
// The function starts by loading the priority celling into registry r0.
// Then it loads in the shared variable into register r2.
// Then it add one to the shared variable(r1).
// Then it sets the shared variable.
// Lastly it sets the priority celling back to what it was before.
//
//
//
//
// > cargo run --example timing_resources --release --features nightly
// > cargo run --example timing_resources --release --features nightly
...
@@ -103,7 +108,7 @@ const APP: () = {
...
@@ -103,7 +108,7 @@ const APP: () = {
// (gdb) x 0xe0001004
// (gdb) x 0xe0001004
//
//
// [Your answer here]
// [Your answer here]
// 0xe0001004: 0x00000010
// 0xe0001004: 0x00000010
= 16 cycles
//
//
// (gdb) disassemble
// (gdb) disassemble
//
//
...
@@ -129,12 +134,12 @@ const APP: () = {
...
@@ -129,12 +134,12 @@ const APP: () = {
// What was the software latency observed to enter the task?
// What was the software latency observed to enter the task?
//
//
// [Your answer here]
// [Your answer here]
// 16 - 2 = 14
// 16 - 2 = 14
cycles
//
//
// Does RTIC infer any overhead?
// Does RTIC infer any overhead?
//
//
// [Your answer here]
// [Your answer here]
// Yes, it add 2 cycles
. Because
Cortex-M4 interupt takes 12 cycles.
// Yes, it add 2 cycles
of overhead.
Cortex-M4 interupt takes 12 cycles.
//
//
// The debugger reports that the breakpoint was hit in the `run<closure>`.
// The debugger reports that the breakpoint was hit in the `run<closure>`.
// The reason is that the RTIC implements the actual interrupt handler,
// The reason is that the RTIC implements the actual interrupt handler,
...
@@ -153,7 +158,7 @@ const APP: () = {
...
@@ -153,7 +158,7 @@ const APP: () = {
// (gdb) x 0xe0001004
// (gdb) x 0xe0001004
//
//
// [Your answer here]
// [Your answer here]
// 0xe0001004: 0x00000025
// 0xe0001004: 0x00000025
= 32 + 5 = 37 cycles
//
//
// You should have a total execution time in the range of 30-40 cycles.
// You should have a total execution time in the range of 30-40 cycles.
//
//
...
@@ -161,7 +166,9 @@ const APP: () = {
...
@@ -161,7 +166,9 @@ const APP: () = {
// `exti0` was safe without locking the resource.
// `exti0` was safe without locking the resource.
//
//
// [Your answer here]
// [Your answer here]
// TODO
// I think the reason is that EXTI0 has a higher priorety then EXTI1 which means that EXTI0 will
// never be interupted by EXTI1. And EXTI0 can never interupt EXTI1 when it is using the shared
// variable becaise EXTI1 uses a lock.
//
//
// In `exti1` we also access `shared` but this time through a lock.
// In `exti1` we also access `shared` but this time through a lock.
//
//
...
@@ -191,12 +198,12 @@ const APP: () = {
...
@@ -191,12 +198,12 @@ const APP: () = {
// (gdb) x 0xe0001004
// (gdb) x 0xe0001004
//
//
// [Your answer here]
// [Your answer here]
// 0xe0001004: 0x00000034
// 0xe0001004: 0x00000034
= 32 + 16 + 4 = 52 cycles
//
//
// Calculate the total time (in cycles), for this section of code.
// Calculate the total time (in cycles), for this section of code.
//
//
// [Your answer here]
// [Your answer here]
// 52 - 37 = 15
// 52 - 37 = 15
cycles
//
//
// You should get a value around 15 cycles.
// You should get a value around 15 cycles.
//
//
...
@@ -237,7 +244,7 @@ const APP: () = {
...
@@ -237,7 +244,7 @@ const APP: () = {
// (gdb) x 0xe0001004
// (gdb) x 0xe0001004
//
//
// [Your answer here]
// [Your answer here]
// 0xe0001004: 0x00000028
// 0xe0001004: 0x00000028
= 32 + 8 = 40 cycles
//
//
// (gdb) c
// (gdb) c
//
//
...
@@ -248,7 +255,7 @@ const APP: () = {
...
@@ -248,7 +255,7 @@ const APP: () = {
// (gdb) x 0xe0001004
// (gdb) x 0xe0001004
//
//
// [Your answer here]
// [Your answer here]
// 0xe0001004: 0x00000032
// 0xe0001004: 0x00000032
= 32 + 16 + 2 = 50 cycles
//
//
// From a real-time perspective the critical section infers
// From a real-time perspective the critical section infers
// blocking (of higher priority tasks).
// blocking (of higher priority tasks).
...
@@ -256,7 +263,7 @@ const APP: () = {
...
@@ -256,7 +263,7 @@ const APP: () = {
// How many clock cycles is the blocking?
// How many clock cycles is the blocking?
//
//
// [Your answer here]
// [Your answer here]
// 50 - 40 = 10
// 50 - 40 = 10
cycles
//
//
// Finally continue out of the closure.
// Finally continue out of the closure.
//
//
...
@@ -267,7 +274,7 @@ const APP: () = {
...
@@ -267,7 +274,7 @@ const APP: () = {
// (gdb) x 0xe0001004
// (gdb) x 0xe0001004
//
//
// [Your answer here]
// [Your answer here]
// 0xe0001004: 0x00000034
// 0xe0001004: 0x00000034
= 32 + 16 + 4 = 52 cycles
//
//
// This is the total execution time of:
// This is the total execution time of:
//
//
...
@@ -291,7 +298,19 @@ const APP: () = {
...
@@ -291,7 +298,19 @@ const APP: () = {
// Motivate your answer (not just a number).
// Motivate your answer (not just a number).
//
//
// [Your answer here]
// [Your answer here]
// TODO
// Estimated cost per task:
// Pending the task EXTI1 cost 650 cycles (job latency).
// Starting the thread EXTI1 cost 1522 cycles (job overhead).
// Pending the task EXTI0 cost 650 cycles (job latency).
// Starting the thread EXTI0 cost 1522 cycles (job overhead).
// Locking the shared variable cost 260 cycles ().
// Unlocking the shared variable cost 170 cycles ().
// Returning to EXTI1 cost 1522 cycles (job overhead).
// Locking the shared variable cost 260 cycles ().
// Unlocking the shared variable cost 170 cycles ().
//
//
// The total cost: 650 + 1522 + 650 + 1522 + 260 + 170 + 1522 + 260 + 170 = 6726
//
//
// Notice, the Rust implementation is significantly faster than the C code version
// Notice, the Rust implementation is significantly faster than the C code version
// of Real-Time For the Masses back in 2013.
// of Real-Time For the Masses back in 2013.
...
...
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