From e4e7cb9d0cb84ebbcdcec43ff926c5095ec564d6 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 13 May 2025 15:10:03 +0200 Subject: [PATCH] added spinlock --- main.cc | 2 +- sync/spinlock.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/main.cc b/main.cc index fa2d0ae..5c9a0e1 100644 --- a/main.cc +++ b/main.cc @@ -115,7 +115,7 @@ extern "C" int main_ap() { DBG << "test\n" << flush; DBG << static_cast(LAPIC::getID()) << endl << flush; - assert(Core::getID() != 1); + //assert(Core::getID() != 1); Application{}.action(); return 0; diff --git a/sync/spinlock.h b/sync/spinlock.h index ba73e41..a3f8941 100644 --- a/sync/spinlock.h +++ b/sync/spinlock.h @@ -35,14 +35,15 @@ class Spinlock { // Prevent copies and assignments Spinlock(const Spinlock& copy) = delete; Spinlock& operator=(const Spinlock&) = delete; - + private: + volatile uint64_t locked; public: /*! \brief Constructor; Initializes as unlocked. * * \todo(12) Complete Constructor (for \MPStuBS, or use \ref Ticketlock) * */ - consteval Spinlock() {} + consteval Spinlock() : locked(0) {} /*! \brief Enters the critical area. In case the area is already locked, * \ref lock() will actively wait until the area can be entered. @@ -50,11 +51,11 @@ class Spinlock { * \see \ref Core::pause() * \todo(12) Implement Method (for \MPStuBS, or use \ref Ticketlock) */ - void lock() {} + void lock(); /*! \brief Unblocks the critical area. * * \todo(12) Implement Method (for \MPStuBS, or use \ref Ticketlock) */ - void unlock() {} + void unlock(); };