add vorgabe10
This commit is contained in:
31
c_os/lib/SpinLock.h
Normal file
31
c_os/lib/SpinLock.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* 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:
|
||||
SpinLock(const SpinLock& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
unsigned long lock;
|
||||
unsigned long* ptr;
|
||||
|
||||
public:
|
||||
SpinLock() : lock(0), ptr(&lock) {}
|
||||
|
||||
void acquire();
|
||||
|
||||
void release();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user