• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "pthread_impl.h"
2 #include "fork_impl.h"
3 
4 static volatile int vmlock[2];
5 volatile int *const __vmlock_lockptr = vmlock;
6 
__vm_wait()7 void __vm_wait()
8 {
9 	int tmp;
10 	while ((tmp=vmlock[0]))
11 		__wait(vmlock, vmlock+1, tmp, 1);
12 }
13 
__vm_lock()14 void __vm_lock()
15 {
16 	a_inc(vmlock);
17 }
18 
__vm_unlock()19 void __vm_unlock()
20 {
21 	if (a_fetch_add(vmlock, -1)==1 && vmlock[1])
22 		__wake(vmlock, -1, 1);
23 }
24