Closed phillipjohnston closed 4 years ago
Atomic CAS would be a nice implementation to have, although you'd need some way to say "thread sleep" as a primitive that can be overridden. Another approach would be to follow the newlib/picolibc approach and define __malloc_lock() and __malloc_unlock() stubs that can be weakly defined and overridden for a specific RTOS. We can provide example implementations in this repo for common RTOSes.
Thinking on this more, I like weakly defined __malloc_lock() and __malloc_unlock() stubs that default to no-ops.
malloc/free: need to add a locking variant. Or CAS version. I don't believe the freelist is threadsafe.