plan 9 kernel history: overview | file list | diff list

1994/0516/port/taslock.c (diff list | history)

1994/0516/sys/src/9/port/taslock.c:1,661994/0525/sys/src/9/port/taslock.c:1,66 (short | long | prev | next)
1992/0222    
#include "u.h" 
1992/0321    
#include "../port/lib.h" 
1992/0222    
#include "mem.h" 
#include "dat.h" 
#include "fns.h" 
#include "../port/error.h" 
 
void 
lock(Lock *l) 
{ 
1993/1204    
	if(tas(&l->key) == 0) 
		return; 
1994/0322    
 
1993/0830    
	for(;;){ 
		while(l->key) 
			; 
		if(tas(&l->key) == 0) 
1992/0222    
			return; 
	} 
} 
 
1994/0322    
void 
ilock(Lock *l) 
{ 
1994/0323    
	ulong x; 
 
	x = splhi(); 
	if(tas(&l->key) == 0){ 
		l->sr = x; 
1994/0322    
		return; 
1994/0323    
	} 
1994/0516    
 print("ilock loop %lux\n", getcallerpc(0)); 
1994/0525    
 
1994/0322    
	for(;;){ 
		while(l->key) 
			; 
1994/0323    
		if(tas(&l->key) == 0){ 
			l->sr = x; 
1994/0322    
			return; 
1994/0323    
		} 
1994/0322    
	} 
} 
 
1992/0222    
int 
canlock(Lock *l) 
{ 
	if(tas(&l->key)) 
		return 0; 
1994/0322    
 
1992/0222    
	return 1; 
} 
 
void 
unlock(Lock *l) 
{ 
	l->key = 0; 
1994/0322    
} 
 
void 
iunlock(Lock *l) 
{ 
	ulong sr; 
 
	sr = l->sr; 
	l->key = 0; 
	splx(sr); 
1992/0222    
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)