diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2017-04-07 19:33:08 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2017-04-07 19:33:08 -0500 |
| commit | 6ac2625a75fc73b5cb846cd3d60422976f8946fc (patch) | |
| tree | be6af71ba8d13052a89c3c0583461b85096ae230 | |
| parent | 185f368d63e6b083d1717c3625b7756e77782add (diff) | |
drop global critical sections in checked::Resource
| -rw-r--r-- | src/checked.rs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/checked.rs b/src/checked.rs index 87318ec..ec4114d 100644 --- a/src/checked.rs +++ b/src/checked.rs @@ -10,25 +10,16 @@ use vcell::VolatileCell; use Ceiling; unsafe fn acquire(locked: &VolatileCell<bool>, ceiling: u8) -> u8 { - interrupt::free( - |_| { - assert!(!locked.get(), "resource already locked"); - let old_basepri = basepri::read(); - basepri_max::write(ceiling); - locked.set(true); - old_basepri - }, - ) + assert!(!locked.get(), "resource already locked"); + let old_basepri = basepri::read(); + basepri_max::write(ceiling); + locked.set(true); + old_basepri } 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); - basepri::write(old_basepri); - // }, - // ); + locked.set(false); + basepri::write(old_basepri); } /// A totally safe `Resource` that panics on misuse @@ -70,7 +61,7 @@ where /// Mutably locks the resource, blocking tasks with priority equal or /// smaller than the ceiling `C` pub fn lock_mut<R, F>(&'static self, f: F) -> R - where + where F: FnOnce(&mut T) -> R, { unsafe { |
