diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-15 11:29:26 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-15 11:29:26 +0000 |
| commit | 60ab85044289f4a9a0a84c37bfb2b3938f6ae416 (patch) | |
| tree | f1b41963d0a28bbe26e4e8f61c8bcc11b4daa000 /arch/x86_64/src/stl/mutex.cpp | |
| parent | f2b9ac8f0f22354241e9b78e47aa7cb94e5ef511 (diff) | |
| download | teachos-60ab85044289f4a9a0a84c37bfb2b3938f6ae416.tar.xz teachos-60ab85044289f4a9a0a84c37bfb2b3938f6ae416.zip | |
Fix size of segment descriptor using bit fields and struct packing
Diffstat (limited to 'arch/x86_64/src/stl/mutex.cpp')
| -rw-r--r-- | arch/x86_64/src/stl/mutex.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86_64/src/stl/mutex.cpp b/arch/x86_64/src/stl/mutex.cpp new file mode 100644 index 0000000..232a11c --- /dev/null +++ b/arch/x86_64/src/stl/mutex.cpp @@ -0,0 +1,16 @@ +#include "arch/stl/mutex.hpp" + +namespace teachos::arch::stl +{ + auto mutex::lock() -> void + { + while (!try_lock()) + { + // Nothing to do + } + } + + auto mutex::try_lock() -> bool { return !locked.exchange(true, std::memory_order_acquire); } + + auto mutex::unlock() -> void { locked.store(false, std::memory_order_release); } +} // namespace teachos::arch::stl |
