32 lines
686 B
C
32 lines
686 B
C
|
|
#ifndef __SPINLOCK_H__
|
|
#define __SPINLOCK_H__
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#define SPINLOCK_NAMELEN 32
|
|
|
|
typedef struct Spinlock
|
|
{
|
|
volatile uint64_t lock;
|
|
uint64_t cpu;
|
|
uint64_t count;
|
|
uint64_t lockTime;
|
|
uint64_t waitTime;
|
|
uint64_t lockedTSC;
|
|
char name[SPINLOCK_NAMELEN];
|
|
LIST_ENTRY(Spinlock) lockList;
|
|
} Spinlock;
|
|
|
|
void Critical_Init();
|
|
void Critical_Enter();
|
|
void Critical_Exit();
|
|
void Spinlock_Init(Spinlock *lock, const char *name);
|
|
void Spinlock_Destroy(Spinlock *lock);
|
|
void Spinlock_Lock(Spinlock *lock);
|
|
void Spinlock_Unlock(Spinlock *lock);
|
|
bool Spinlock_IsHeld(Spinlock *lock);
|
|
|
|
#endif /* __SPINLOCK_H__ */
|
|
|