1
Files
lecture-operating-system-de…/c_os/lib/SpinLock.h
2022-07-24 21:12:31 +02:00

31 lines
1.1 KiB
C++

/*****************************************************************************
* *
* S P I N L O C K *
* *
*---------------------------------------------------------------------------*
* Beschreibung: Implementierung eines Spinlocks mithilfe der cmpxchg *
* Instruktion. *
* *
* Autor: Michael Schoettner, 2.2.2018 *
*****************************************************************************/
#ifndef SpinLock_include__
#define SpinLock_include__
class SpinLock {
private:
unsigned long lock;
unsigned long* ptr;
public:
SpinLock(const SpinLock& copy) = delete; // Verhindere Kopieren
SpinLock() : lock(0), ptr(&lock) {}
void acquire();
void release();
};
#endif