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

1995/0109/port/taslock.c (diff list | history)

1995/0108/sys/src/9/port/taslock.c:38,701995/0109/sys/src/9/port/taslock.c:38,60 (short | long | prev | next)
1992/0222    
	} 
} 
 
1994/0322    
void 
ilock(Lock *l) 
1995/0109    
int 
canlock(Lock *l) 
1994/0322    
{ 
1994/0323    
	ulong x; 
1995/0109    
	int n; 
1994/0323    
 
	x = splhi(); 
	if(tas(&l->key) == 0){ 
		l->sr = x; 
1994/0322    
		return; 
1994/0323    
	} 
1994/0525    
                 
1994/0322    
	for(;;){ 
		while(l->key) 
			; 
1994/0323    
		if(tas(&l->key) == 0){ 
			l->sr = x; 
1994/0322    
			return; 
1995/0109    
	if(up) { 
		n = up->inlock; 
		up->inlock = n+2; 
		if(tas(&l->key)) { 
			up->inlock = n; 
			return 0; 
1994/0323    
		} 
1995/0109    
		return 1; 
1994/0322    
	} 
} 
 
1992/0222    
int 
canlock(Lock *l) 
{ 
	if(tas(&l->key)) 
		return 0; 
1994/0322    
                 
1992/0222    
	return 1; 
} 
 
1995/0108/sys/src/9/port/taslock.c:73,791995/0109/sys/src/9/port/taslock.c:63,68
1992/0222    
{ 
1995/0108    
	int n; 
 
1992/0222    
	l->key = 0; 
1995/0108    
	if(up) { 
		n = up->inlock-2; 
		if(n < 0) 
1995/0108/sys/src/9/port/taslock.c:80,931995/0109/sys/src/9/port/taslock.c:69,93
1995/0108    
			n = 0; 
		up->inlock = n; 
	} 
1995/0109    
	l->key = 0; 
1994/0322    
} 
 
void 
1995/0109    
ilock(Lock *l) 
{ 
	ulong sr; 
 
	sr = splhi(); 
	lock(l); 
	l->sr = sr; 
} 
 
void 
1994/0322    
iunlock(Lock *l) 
{ 
	ulong sr; 
 
	sr = l->sr; 
	l->key = 0; 
1995/0109    
	unlock(l); 
1994/0322    
	splx(sr); 
1992/0222    
} 


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