You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new allocator uses a spin-lock to synchronize the access to the ALLOCATOR(LockedHeap).
Following sequence can result in a deadlock:
ISR1 is entering the lock.
ISR1 is preempted. ISR2 has higher priority and tries to access the lock. Scine the lock is already entered by ISR1, ISR2 has to wait in a loop until ISR1 has left the lock.
ISR1 and ISR2 don't make progress => Deadlock
Solution: Use the PRIMASK register on cortex m processors to synchronize the critical section by disabling interrutps.
LockedHeap is a wrapper type around Heap that uses a spinlock to implement the Alloc trait for shared references (&LockedHeap). This is required to be able to use it as a global allocator (see the RFC).
Instead of LockedHeap, we should create another wrapper type around Heap that uses the PRIMASK register instead of a spinlock. This wrapper type could live in either this crate or directly in linked-list-allocator.
I'm on vacation for the next four weeks, but I will look into this afterwards. It should be straightforward to implement such a wrapper type though (it should be pretty similar to the implementation of LockedHeap, but with a PRIMASK Mutex instead of a spinlock Mutex).
I have already implemented a wrapper (CortexMHeap) and sent a PR to the alloc-cortex-m repo. I just wait until it is merged. When it is merged, I will switch the ALLOCATOR to the new CortexMHeap.
The new allocator uses a spin-lock to synchronize the access to the
ALLOCATOR
(LockedHeap).Following sequence can result in a deadlock:
ISR1
is entering the lock.ISR1
is preempted.ISR2
has higher priority and tries to access the lock. Scine the lock is already entered byISR1
,ISR2
has to wait in a loop untilISR1
has left the lock.ISR1
andISR2
don't make progress => DeadlockSolution: Use the PRIMASK register on cortex m processors to synchronize the critical section by disabling interrutps.
See pull request for
CortexMHeap
rust-embedded/embedded-alloc#6The text was updated successfully, but these errors were encountered: