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

1992/0602/port/taslock.c (diff list | history)

1992/0428/sys/src/9/port/taslock.c:5,101992/0602/sys/src/9/port/taslock.c:5,13 (short | long | prev | next)
1992/0222    
#include "fns.h" 
#include "../port/error.h" 
 
1992/0602    
ulong spinner; 
ulong spinpc; 
 
1992/0222    
void 
lock(Lock *l) 
{ 
1992/0428/sys/src/9/port/taslock.c:13,221992/0602/sys/src/9/port/taslock.c:16,27
1992/0222    
	ulong pc; 
 
	pc = getcallerpc(((uchar*)&l) - sizeof(l)); 
1992/0428    
if(l == 0){ 
print("pc= %lux", pc); 
for(;;); 
} 
1992/0602    
    	if (tas(&ll->key) == 0){ 
		if(u) 
			u->p->hasspin = 1; 
		ll->pc = pc; 
		return; 
	} 
1992/0222    
	for(i = 0; i < 1000000; i++){ 
    		if (tas(&ll->key) == 0){ 
			if(u) 
1992/0428/sys/src/9/port/taslock.c:24,311992/0602/sys/src/9/port/taslock.c:29,36
1992/0222    
			ll->pc = pc; 
			return; 
		} 
		if(u && u->p->state == Running) 
			sched(); 
1992/0602    
spinner++; 
spinpc = pc; 
1992/0222    
	} 
	i = l->key; 
	l->key = 0; 


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