Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2021
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
Anton Johansson
e7020e_2021
Commits
9817a47a
Commit
9817a47a
authored
Mar 3, 2021
by
Anton
Browse files
Options
Downloads
Patches
Plain Diff
bare4_3
parent
59d5a43d
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/rtic_bare4.rs
+10
-5
10 additions, 5 deletions
examples/rtic_bare4.rs
with
10 additions
and
5 deletions
examples/rtic_bare4.rs
+
10
−
5
View file @
9817a47a
...
...
@@ -35,8 +35,8 @@ use address::*;
#[inline(always)]
fn
read_u32
(
addr
:
u32
)
->
u32
{
//
unsafe { core::ptr::read_volatile(addr as *const _) }
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
);
unsafe
{
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
)
}
//
core::ptr::read_volatile(addr as *const _);
}
#[inline(always)]
...
...
@@ -119,16 +119,21 @@ const APP: () = {
//
// Why is it important that ordering of volatile operations are ensured by the compiler?
//
// ** your answer here **
// Since you are accessing memory outside of the aqusition of rust
// the ordering is very important.
//
// Give an example in the above code, where reordering might make things go horribly wrong
// (hint, accessing a peripheral not being powered...)
//
// ** your answer here **
// If the write instruction on line 65 before the read instruction on line 64
// The word on address GPIOA_MODER would look completely different since r is no longer a copy
// with modifications for the word you are writing to.
// Or if one of the writes for PA5 happens before any of the initialization writes to RCC_AHB1ENR or BPIOA_MODER.
//
// Without the non-reordering property of `write_volatile/read_volatile` could that happen in theory
// (argue from the point of data dependencies).
//
// ** your answer here **
// Since the PA5 write does not depend on anything from the initialization in software point of view,
// Theoretically it could happen.
//
// Commit your answers (bare4_3)
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