#include "thread/Spinlock.h" #include "Log.h" #include "arch/CPU.h" void Spinlock::lock() { int expected = -1; while (!m_lock.compare_exchange_strong(expected, 0)) { expected = -1; CPU::pause(); } } void Spinlock::unlock() { int expected = 0; if (!m_lock.compare_exchange_strong(expected, -1)) { kwarnln("Spinlock::unlock() called on an unlocked lock with value %d", expected); } }