blob: 4ce57c873079bed6cebe2ec201dffb16f2f91b89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#pragma once
typedef struct spinlock
{
volatile char s_locked;
} spinlock_t;
#define SPINLOCK_INITIALIZER(lock) \
{ \
.s_locked = 0 \
}
/**
* Initializes the fields of the specified spinlock_t
* @param lock the spinlock to initialize
*/
void spinlock_init(spinlock_t *lock);
/**
* Locks the specified spinlock.
*
* Note: this function may spin on the current core.
*
* Note: these locks are not re-entrant
*
* @param lock the spinlock to lock
*/
void spinlock_lock(spinlock_t *lock);
/**
* Unlocks the specified spinlock.
*
* @param lock the spinlock to unlock
*/
void spinlock_unlock(spinlock_t *lock);
long spinlock_ownslock(spinlock_t *lock);
|