Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2020
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
Model registry
Operate
Environments
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
Anton Grahn
e7020e_2020
Commits
6b7eff1b
Commit
6b7eff1b
authored
5 years ago
by
Anton Grahn
Browse files
Options
Downloads
Patches
Plain Diff
bare 4_3
parent
e27f04cd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/bare4.rs
+21
-3
21 additions, 3 deletions
examples/bare4.rs
with
21 additions
and
3 deletions
examples/bare4.rs
+
21
−
3
View file @
6b7eff1b
...
...
@@ -116,13 +116,15 @@ fn main() -> ! {
//
// error: aborting due to previous error
//
//
R
ead
ing adresses is not
safe so it panics
//
r
ead
_voliatile is a un
safe so it panics
//
// Digging a bit deeper, why do you think `read_volatile` is declared `unsafe`.
// (https://doc.rust-lang.org/core/ptr/fn.read_volatile.html, for some food for thought )
//
// ** your answer here **
//
//
// because rust cant guarantee to know whats on the memmory address
//
// Commit your answers (bare4_2)
//
// 3. Volatile read/writes are explicit *volatile operations* in Rust, while in C they
...
...
@@ -135,15 +137,31 @@ fn main() -> ! {
// Why is it important that ordering of volatile operations are ensured by the compiler?
//
// ** your answer here **
//
// because volatile just reads the momory address so if it is done in the wrong order it
// might read values that are wrong and the use them.
//
// 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 **
//
//
// // power on GPIOA
// let r = read_u32(RCC_AHB1ENR); // read
// write_u32(RCC_AHB1ENR, r | 1); // set enable
//
// //configure PA5 as output
// let r = read_u32(GPIOA_MODER) & !(0b11 << (5 * 2)); // read and mask
// write_u32(GPIOA_MODER, r | 0b01 << (5 * 2)); // set output mode
//
// if poweron giopa would happen after the config it could cause problems
//
// 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 **
//
// its important that they are non-reordering because otherwise if a write_volitile is dependent on data from a read_volitile
// and its reorderd it would not have all the relevent data it needs.
//
// 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