feat: Symmetric Multiprocessing, text editor improvements, merge doom libc, implement math functions
This commit is contained in:
@@ -15,4 +15,20 @@ namespace kcp {
|
||||
void Acquire();
|
||||
void Release();
|
||||
};
|
||||
|
||||
// Non-interrupt-disabling mutex for subsystems that are only called
|
||||
// from process/syscall context (never from interrupt handlers).
|
||||
// Keeps interrupts enabled while spinning and while held.
|
||||
class Mutex {
|
||||
std::atomic_flag flag{ATOMIC_FLAG_INIT};
|
||||
public:
|
||||
void Acquire() {
|
||||
while (flag.test_and_set(std::memory_order_acquire)) {
|
||||
asm volatile("pause");
|
||||
}
|
||||
}
|
||||
void Release() {
|
||||
flag.clear(std::memory_order_release);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user