aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/stl
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2025-03-15 11:29:26 +0000
committerFabian Imhof <fabian.imhof@ost.ch>2025-03-15 12:03:23 +0000
commit2b8e6e7e10f084a9a9ba5c0b79a041f4d1ac459b (patch)
tree04f77a457517c8c36e22dead8261191e560eae6d /arch/x86_64/src/stl
parentf2b9ac8f0f22354241e9b78e47aa7cb94e5ef511 (diff)
downloadteachos-2b8e6e7e10f084a9a9ba5c0b79a041f4d1ac459b.tar.xz
teachos-2b8e6e7e10f084a9a9ba5c0b79a041f4d1ac459b.zip
implement loading of gdtr register
Diffstat (limited to 'arch/x86_64/src/stl')
-rw-r--r--arch/x86_64/src/stl/mutex.cpp16
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