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

1990/0705/gnot/lock.c (diff list | history)

1990/0623/sys/src/9/gnot/lock.c:18,401990/0705/sys/src/9/gnot/lock.c:18,41 (short | long | prev | next)
1990/03091    
void 
lock(Lock *l) 
{ 
1990/0705    
	Lock *ll = l;	/* do NOT take the address of l */ 
1990/03091    
	int i; 
 
	/* 
	 * Try the fast grab first 
	 */ 
1990/0403    
    	if(l->key >= 0){ 
		l->key |= 0x80; 
1990/0617    
		l->pc = ((ulong*)&l)[PCOFF]; 
1990/0705    
    	if(ll->key >= 0){ 
		ll->key |= 0x80; 
		ll->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
		return; 
	} 
	for(i=0; i<10000000; i++) 
1990/0403    
    		if(l->key >= 0){ 
			l->key |= 0x80; 
1990/0617    
			l->pc = ((ulong*)&l)[PCOFF]; 
1990/0705    
    		if(ll->key >= 0){ 
			ll->key |= 0x80; 
			ll->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
			return; 
1990/0601    
		} 
1990/0403    
	l->key = 0; 
1990/0705    
	ll->key = 0; 
1990/0619    
dumpstack(); 
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&l)[PCOFF], l->pc); 
1990/03091    
} 
1990/0623/sys/src/9/gnot/lock.c:42,501990/0705/sys/src/9/gnot/lock.c:43,52
1990/03091    
int 
canlock(Lock *l) 
{ 
1990/0403    
	if(l->key >= 0){ 
		l->key |= 0x80; 
1990/0617    
		l->pc = ((ulong*)&l)[PCOFF]; 
1990/0705    
	Lock *ll = l;	/* do NOT take the address of l */ 
	if(ll->key >= 0){ 
		ll->key |= 0x80; 
		ll->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
		return 1; 
	} 
	return 0; 


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