]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/kern/lock.h
Initial checkin from Perforce.
[polintos/scott/priv.git] / kernel / include / kern / lock.h
1 #ifndef _KERN_LOCK_H
2 #define _KERN_LOCK_H
3
4 #include <kern/kernel.h>
5 #include <kern/spinlock.h>
6 #include <kern/thread.h>
7 #include <util/spinlock.h>
8
9 namespace Lock {
10         extern int dying;
11
12         struct Lock {
13                 SpinLock spinlock;
14                 Threads::WaitQueue waitqueue;
15                 ulong lockval;
16                 
17                 Lock()
18                 {
19                         lockval = 0;
20                 }
21                 
22                 void lock();
23                 void unlock();
24
25                 bool held_by_curthread()
26                 {
27                         return lockval == reinterpret_cast<ulong>(curthread);
28                 }
29         };
30 }
31
32 #endif