-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlock.h
More file actions
38 lines (26 loc) · 757 Bytes
/
lock.h
File metadata and controls
38 lines (26 loc) · 757 Bytes
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
38
//
// lock.h -- Declares functions and structures for the locking mechanism.
// Written for JamesM's kernel development tutorials.
//
#ifndef LOCK_H
#define LOCK_H
#include "common.h"
#include "thread.h"
#include "scheduler.h"
#define SPINLOCK_LOCKED 0
#define SPINLOCK_UNLOCKED 1
typedef volatile uint32_t spinlock_t;
typedef struct semaphore
{
uint32_t counter;
spinlock_t lock;
thread_list_t queue;
} semaphore_t;
void spinlock_lock (spinlock_t *lock);
void spinlock_unlock (spinlock_t *lock);
// uint32_t spinlock_trylock (spinlock_t *lock);
/*void semaphore_init (semaphore_t *sem, uint32_t value);
void semaphore_destroy (semaphore_t *sem);
void semaphore_p (semaphore_t *sem);
void semaphore_v (semaphore_t *sem);*/
#endif