From 60ab85044289f4a9a0a84c37bfb2b3938f6ae416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sat, 15 Mar 2025 11:29:26 +0000 Subject: Fix size of segment descriptor using bit fields and struct packing --- arch/x86_64/src/stl/mutex.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 arch/x86_64/src/stl/mutex.cpp (limited to 'arch/x86_64/src/stl/mutex.cpp') 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 -- cgit v1.2.3