mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
drop global critical sections in checked::Resource
This commit is contained in:
parent
185f368d63
commit
6ac2625a75
1 changed files with 8 additions and 17 deletions
|
@ -10,25 +10,16 @@ use vcell::VolatileCell;
|
||||||
use Ceiling;
|
use Ceiling;
|
||||||
|
|
||||||
unsafe fn acquire(locked: &VolatileCell<bool>, ceiling: u8) -> u8 {
|
unsafe fn acquire(locked: &VolatileCell<bool>, ceiling: u8) -> u8 {
|
||||||
interrupt::free(
|
|
||||||
|_| {
|
|
||||||
assert!(!locked.get(), "resource already locked");
|
assert!(!locked.get(), "resource already locked");
|
||||||
let old_basepri = basepri::read();
|
let old_basepri = basepri::read();
|
||||||
basepri_max::write(ceiling);
|
basepri_max::write(ceiling);
|
||||||
locked.set(true);
|
locked.set(true);
|
||||||
old_basepri
|
old_basepri
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn release(locked: &VolatileCell<bool>, old_basepri: u8) {
|
unsafe fn release(locked: &VolatileCell<bool>, old_basepri: u8) {
|
||||||
// XXX Is it really memory safe to *not* use a global critical section here
|
|
||||||
// interrupt::free(
|
|
||||||
// |_| {
|
|
||||||
locked.set(false);
|
locked.set(false);
|
||||||
basepri::write(old_basepri);
|
basepri::write(old_basepri);
|
||||||
// },
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A totally safe `Resource` that panics on misuse
|
/// A totally safe `Resource` that panics on misuse
|
||||||
|
|
Loading…
Reference in a new issue