aboutsummaryrefslogtreecommitdiff
path: root/kernel/task/include/task/lock.h
blob: bfb7994423ad65f04efcf4afe5fe7733a3775a47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef LOCK_H
#define LOCK_H

#include "task/shed.h"

typedef char spin_lock_t;

#define SPIN_LOCK_UNLOCKED 0

static inline void spin_lock(struct spin_lock_t* lock) {
  while(*lock != SPIN_LOCK_UNLOCKED) {yield();};
  *lock = 1;
}

static inline void spin_unlock(struct spin_lock_t* lock) {
  *lock = SPIN_LOCK_UNLOCKED;
}

#endif