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

1991/0311/gnot/lock.c (diff list | history)

1990/03091/sys/src/9/gnot/lock.c:66,711990/0312/sys/src/9/gnot/lock.c:66,77 (short | long)
1990/03091    
	sched(); 
} 
 
1990/0312    
int 
canqlock(QLock *q) 
{ 
	return canlock(&q->use); 
} 
 
1990/03091    
void 
qunlock(QLock *q) 
{ 
1990/0312/sys/src/9/gnot/lock.c:4,91990/0403/sys/src/9/gnot/lock.c:4,18 (short | long)
1990/03091    
#include "dat.h" 
#include "fns.h" 
 
1990/0403    
#define PCOFF -2 
 
/* 
 *  N.B.  Ken's compiler generates a TAS instruction for the sequence: 
 * 
 *  	if(l->key >= 0){ 
 *		l->key |= 0x80; 
 *		... 
 */ 
1990/03091    
void 
lock(Lock *l) 
{ 
1990/0312/sys/src/9/gnot/lock.c:12,351990/0403/sys/src/9/gnot/lock.c:21,49
1990/03091    
	/* 
	 * Try the fast grab first 
	 */ 
    	if(tas(l->key) == 0){ 
		l->pc = ((ulong*)&l)[-1]; 
1990/0403    
    	if(l->key >= 0){ 
		l->key |= 0x80; 
		l->pc = ((ulong*)&i)[PCOFF]; 
1990/03091    
		return; 
	} 
	for(i=0; i<10000000; i++) 
    		if(tas(l->key) == 0){ 
			l->pc = ((ulong*)&l)[-1]; 
1990/0403    
    		if(l->key >= 0){ 
			l->key |= 0x80; 
			l->pc = ((ulong*)&i)[PCOFF]; 
1990/03091    
			return; 
	} 
	l->key[0] = 0; 
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&l)[-1], l->pc); 
1990/0403    
	l->key = 0; 
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&i)[PCOFF], l->pc); 
1990/03091    
} 
 
int 
canlock(Lock *l) 
{ 
	if(tas(l->key) == 0){ 
		l->pc = ((ulong*)&l)[-1]; 
1990/0403    
	int i; 
 
	if(l->key >= 0){ 
		l->key |= 0x80; 
		l->pc = ((ulong*)&i)[PCOFF]; 
1990/03091    
		return 1; 
	} 
	return 0; 
1990/0312/sys/src/9/gnot/lock.c:39,451990/0403/sys/src/9/gnot/lock.c:53,59
1990/03091    
unlock(Lock *l) 
{ 
	l->pc = 0; 
	l->key[0] = 0; 
1990/0403    
	l->key = 0; 
1990/03091    
} 
 
void 
1990/0403/sys/src/9/gnot/lock.c:76,811990/05313/sys/src/9/gnot/lock.c:76,82 (short | long)
1990/03091    
	q->tail = u->p; 
	u->p->qnext = 0; 
	u->p->state = Queueing; 
1990/05313    
	u->p->qlock = q;	/* DEBUG */ 
1990/03091    
	unlock(&q->queue); 
	sched(); 
} 
1990/05313/sys/src/9/gnot/lock.c:12,171990/0601/sys/src/9/gnot/lock.c:12,19 (short | long)
1990/0403    
 *  	if(l->key >= 0){ 
 *		l->key |= 0x80; 
 *		... 
1990/0601    
 * 
 *	DO NOT TAKE THE ADDRESS OF l->key or the TAS will disappear. 
1990/0403    
 */ 
1990/03091    
void 
lock(Lock *l) 
1990/05313/sys/src/9/gnot/lock.c:31,371990/0601/sys/src/9/gnot/lock.c:33,39
1990/0403    
			l->key |= 0x80; 
			l->pc = ((ulong*)&i)[PCOFF]; 
1990/03091    
			return; 
	} 
1990/0601    
		} 
1990/0403    
	l->key = 0; 
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&i)[PCOFF], l->pc); 
1990/03091    
} 
1990/0601/sys/src/9/gnot/lock.c:4,101990/0617/sys/src/9/gnot/lock.c:4,10 (short | long)
1990/03091    
#include "dat.h" 
#include "fns.h" 
 
1990/0403    
#define PCOFF -2 
1990/0617    
#define PCOFF -1 
1990/0403    
 
/* 
 *  N.B.  Ken's compiler generates a TAS instruction for the sequence: 
1990/0601/sys/src/9/gnot/lock.c:25,371990/0617/sys/src/9/gnot/lock.c:25,37
1990/03091    
	 */ 
1990/0403    
    	if(l->key >= 0){ 
		l->key |= 0x80; 
		l->pc = ((ulong*)&i)[PCOFF]; 
1990/0617    
		l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
		return; 
	} 
	for(i=0; i<10000000; i++) 
1990/0403    
    		if(l->key >= 0){ 
			l->key |= 0x80; 
			l->pc = ((ulong*)&i)[PCOFF]; 
1990/0617    
			l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
			return; 
1990/0601    
		} 
1990/0403    
	l->key = 0; 
1990/0601/sys/src/9/gnot/lock.c:41,511990/0617/sys/src/9/gnot/lock.c:41,49
1990/03091    
int 
canlock(Lock *l) 
{ 
1990/0403    
	int i; 
                 
	if(l->key >= 0){ 
		l->key |= 0x80; 
		l->pc = ((ulong*)&i)[PCOFF]; 
1990/0617    
		l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
		return 1; 
	} 
	return 0; 
1990/0617/sys/src/9/gnot/lock.c:35,411990/0619/sys/src/9/gnot/lock.c:35,42 (short | long)
1990/03091    
			return; 
1990/0601    
		} 
1990/0403    
	l->key = 0; 
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&i)[PCOFF], l->pc); 
1990/0619    
dumpstack(); 
	panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&l)[PCOFF], l->pc); 
1990/03091    
} 
 
int 
1990/0619/sys/src/9/gnot/lock.c:94,991990/0623/sys/src/9/gnot/lock.c:94,100 (short | long)
1990/03091    
	Proc *p; 
 
	lock(&q->queue); 
1990/0623    
	u->p->qlock = 0; 
1990/03091    
	if(q->head){ 
		p = q->head; 
		q->head = p->qnext; 
1990/0623/sys/src/9/gnot/lock.c:18,401990/0705/sys/src/9/gnot/lock.c:18,41 (short | long)
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; 
1990/0705/sys/src/9/gnot/lock.c:18,241990/1226/sys/src/9/gnot/lock.c:18,24 (short | long)
1990/03091    
void 
lock(Lock *l) 
{ 
1990/0705    
	Lock *ll = l;	/* do NOT take the address of l */ 
1990/1226    
	Lock *ll = l;	/* do NOT take the address of ll */ 
1990/03091    
	int i; 
 
	/* 
1990/0705/sys/src/9/gnot/lock.c:43,491990/1226/sys/src/9/gnot/lock.c:43,49
1990/03091    
int 
canlock(Lock *l) 
{ 
1990/0705    
	Lock *ll = l;	/* do NOT take the address of l */ 
1990/1226    
	Lock *ll = l;	/* do NOT take the address of ll */ 
1990/0705    
	if(ll->key >= 0){ 
		ll->key |= 0x80; 
		ll->pc = ((ulong*)&l)[PCOFF]; 
1990/1226/sys/src/9/gnot/lock.c:36,431991/0109/sys/src/9/gnot/lock.c:36,42 (short | long)
1990/03091    
			return; 
1990/0601    
		} 
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); 
1991/0109    
	print("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&l)[PCOFF], l->pc); 
1990/03091    
} 
 
int 
1991/0109/sys/src/9/gnot/lock.c:95,1011991/0311/sys/src/9/gnot/lock.c:95,102 (short | long)
1990/03091    
	Proc *p; 
 
	lock(&q->queue); 
1990/0623    
	u->p->qlock = 0; 
1991/0311    
	if(u) 
		u->p->qlock = 0; 
1990/03091    
	if(q->head){ 
		p = q->head; 
		q->head = p->qnext; 
1991/0311/sys/src/9/gnot/lock.c:57,1111991/0428/sys/src/9/gnot/lock.c:57,59 (short | long)
1990/03091    
	l->pc = 0; 
1990/0403    
	l->key = 0; 
1990/03091    
} 
                 
void 
qlock(QLock *q) 
{ 
	Proc *p; 
                 
	if(canlock(&q->use)) 
		return; 
	lock(&q->queue); 
	if(canlock(&q->use)){ 
		unlock(&q->queue); 
		return; 
	} 
	p = q->tail; 
	if(p == 0) 
		q->head = u->p; 
	else 
		p->qnext = u->p; 
	q->tail = u->p; 
	u->p->qnext = 0; 
	u->p->state = Queueing; 
1990/05313    
	u->p->qlock = q;	/* DEBUG */ 
1990/03091    
	unlock(&q->queue); 
	sched(); 
} 
                 
1990/0312    
int 
canqlock(QLock *q) 
{ 
	return canlock(&q->use); 
} 
                 
1990/03091    
void 
qunlock(QLock *q) 
{ 
	Proc *p; 
                 
	lock(&q->queue); 
1991/0311    
	if(u) 
		u->p->qlock = 0; 
1990/03091    
	if(q->head){ 
		p = q->head; 
		q->head = p->qnext; 
		if(q->head == 0) 
			q->tail = 0; 
		unlock(&q->queue); 
		ready(p); 
	}else{ 
		unlock(&q->use); 
		unlock(&q->queue); 
	} 
} 
1991/0428/sys/src/9/gnot/lock.c:3,81991/0606/sys/src/9/gnot/lock.c:3,9 (short | long)
1990/03091    
#include "mem.h" 
#include "dat.h" 
#include "fns.h" 
1991/0606    
#include "errno.h" 
1990/03091    
 
1990/0617    
#define PCOFF -1 
1990/0403    
 
1991/0428/sys/src/9/gnot/lock.c:56,591991/0606/sys/src/9/gnot/lock.c:57,66
1990/03091    
{ 
	l->pc = 0; 
1990/0403    
	l->key = 0; 
1991/0606    
} 
 
void 
mklockseg(Seg *s) 
{ 
	error(Esegaddr); 
1990/03091    
} 
1991/0606/sys/src/9/gnot/lock.c:64,661991/0608/sys/src/9/gnot/lock.c:64,71 (short | long)
1991/0606    
{ 
	error(Esegaddr); 
1990/03091    
} 
1991/0608    
 
Page* 
lkpage(Orig* o, ulong va) 
{ 
} 
1991/0608/sys/src/9/gnot/lock.c:28,331991/0614/sys/src/9/gnot/lock.c:28,35 (short | long)
1990/0705    
    	if(ll->key >= 0){ 
		ll->key |= 0x80; 
		ll->pc = ((ulong*)&l)[PCOFF]; 
1991/0614    
		if(u && u->p) 
			u->p->hasspin = 1; 
1990/03091    
		return; 
	} 
	for(i=0; i<10000000; i++) 
1991/0608/sys/src/9/gnot/lock.c:34,391991/0614/sys/src/9/gnot/lock.c:36,43
1990/0705    
    		if(ll->key >= 0){ 
			ll->key |= 0x80; 
			ll->pc = ((ulong*)&l)[PCOFF]; 
1991/0614    
			if(u && u->p) 
				u->p->hasspin = 1; 
1990/03091    
			return; 
1990/0601    
		} 
1990/0705    
	ll->key = 0; 
1991/0608/sys/src/9/gnot/lock.c:47,521991/0614/sys/src/9/gnot/lock.c:51,58
1990/0705    
	if(ll->key >= 0){ 
		ll->key |= 0x80; 
		ll->pc = ((ulong*)&l)[PCOFF]; 
1991/0614    
		if(u && u->p) 
			u->p->hasspin = 1; 
1990/03091    
		return 1; 
	} 
	return 0; 
1991/0608/sys/src/9/gnot/lock.c:57,621991/0614/sys/src/9/gnot/lock.c:63,70
1990/03091    
{ 
	l->pc = 0; 
1990/0403    
	l->key = 0; 
1991/0614    
	if(u && u->p) 
		u->p->hasspin = 0; 
1991/0606    
} 
 
void 
1991/0614/sys/src/9/gnot/lock.c:66,791991/0705/sys/src/9/gnot/lock.c:66,68 (short | long)
1991/0614    
	if(u && u->p) 
		u->p->hasspin = 0; 
1991/0606    
} 
                 
void 
mklockseg(Seg *s) 
{ 
	error(Esegaddr); 
1990/03091    
} 
1991/0608    
                 
Page* 
lkpage(Orig* o, ulong va) 
{ 
} 
1991/0705/sys/src/9/gnot/lock.c:7,611991/0723/sys/src/9/gnot/lock.c:7,51 (short | long)
1990/03091    
 
1990/0617    
#define PCOFF -1 
1990/0403    
 
/* 
 *  N.B.  Ken's compiler generates a TAS instruction for the sequence: 
 * 
 *  	if(l->key >= 0){ 
 *		l->key |= 0x80; 
 *		... 
1990/0601    
 * 
 *	DO NOT TAKE THE ADDRESS OF l->key or the TAS will disappear. 
1990/0403    
 */ 
1990/03091    
void 
lock(Lock *l) 
{ 
1990/1226    
	Lock *ll = l;	/* do NOT take the address of ll */ 
1990/03091    
	int i; 
 
	/* 
	 * Try the fast grab first 
	 */ 
1990/0705    
    	if(ll->key >= 0){ 
		ll->key |= 0x80; 
		ll->pc = ((ulong*)&l)[PCOFF]; 
1991/0723    
    	if(tas(&l->key) == 0){ 
1991/0614    
		if(u && u->p) 
			u->p->hasspin = 1; 
1991/0723    
		l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
		return; 
	} 
	for(i=0; i<10000000; i++) 
1990/0705    
    		if(ll->key >= 0){ 
			ll->key |= 0x80; 
			ll->pc = ((ulong*)&l)[PCOFF]; 
1991/0723    
	for(i = 0; i < 1000; i++){ 
		sched(); 
    		if (tas(&l->key) == 0){ 
1991/0614    
			if(u && u->p) 
				u->p->hasspin = 1; 
1991/0723    
			l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
			return; 
1990/0601    
		} 
1990/0705    
	ll->key = 0; 
1991/0109    
	print("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&l)[PCOFF], l->pc); 
1991/0723    
	} 
	i = l->key; 
	l->key = 0; 
 
	panic("lock loop 0x%lux key 0x%lux pc 0x%lux held by pc 0x%lux\n", l, i, 
		((ulong*)&l)[PCOFF], l->pc); 
1990/03091    
} 
 
int 
canlock(Lock *l) 
{ 
1990/1226    
	Lock *ll = l;	/* do NOT take the address of ll */ 
1990/0705    
	if(ll->key >= 0){ 
		ll->key |= 0x80; 
		ll->pc = ((ulong*)&l)[PCOFF]; 
1991/0614    
		if(u && u->p) 
			u->p->hasspin = 1; 
1990/03091    
		return 1; 
	} 
	return 0; 
1991/0723    
	if(tas(&l->key)) 
		return 0; 
	l->pc = ((ulong*)&l)[PCOFF]; 
	if(u && u->p) 
		u->p->hasspin = 1; 
	return 1; 
1990/03091    
} 
 
void 
1991/0723/sys/src/9/gnot/lock.c:16,301991/0820/sys/src/9/gnot/lock.c:16,31 (short | long)
1990/03091    
	 * Try the fast grab first 
	 */ 
1991/0723    
    	if(tas(&l->key) == 0){ 
1991/0614    
		if(u && u->p) 
1991/0820    
		if(u) 
1991/0614    
			u->p->hasspin = 1; 
1991/0723    
		l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
		return; 
	} 
1991/0723    
	for(i = 0; i < 1000; i++){ 
		sched(); 
1991/0820    
	for(i = 0; i < 100000; i++){ 
		if(u && u->p->state == Running) 
			sched(); 
1991/0723    
    		if (tas(&l->key) == 0){ 
1991/0614    
			if(u && u->p) 
1991/0820    
			if(u) 
1991/0614    
				u->p->hasspin = 1; 
1991/0723    
			l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
			return; 
1991/0820/sys/src/9/gnot/lock.c:12,291991/0821/sys/src/9/gnot/lock.c:12,18 (short | long)
1990/03091    
{ 
	int i; 
 
	/* 
	 * Try the fast grab first 
	 */ 
1991/0723    
    	if(tas(&l->key) == 0){ 
1991/0820    
		if(u) 
1991/0614    
			u->p->hasspin = 1; 
1991/0723    
		l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
		return; 
	} 
1991/0820    
	for(i = 0; i < 100000; i++){ 
		if(u && u->p->state == Running) 
			sched(); 
1991/0821    
	for(i = 0; i < 1000000; i++){ 
1991/0723    
    		if (tas(&l->key) == 0){ 
1991/0820    
			if(u) 
1991/0614    
				u->p->hasspin = 1; 
1991/0820/sys/src/9/gnot/lock.c:30,351991/0821/sys/src/9/gnot/lock.c:19,26
1991/0723    
			l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
			return; 
1990/0601    
		} 
1991/0821    
		if(u && u->p->state == Running) 
			sched(); 
1991/0723    
	} 
	i = l->key; 
	l->key = 0; 
1991/0821/sys/src/9/gnot/lock.c:3,91992/0111/sys/src/9/gnot/lock.c:3,9 (short | long)
1990/03091    
#include "mem.h" 
#include "dat.h" 
#include "fns.h" 
1991/0606    
#include "errno.h" 
1992/0111    
#include "../port/error.h" 
1990/03091    
 
1990/0617    
#define PCOFF -1 
1990/0403    
 
1992/0111/sys/src/9/gnot/lock.c:1,501992/0222/sys/src/9/gnot/lock.c:0 (short | long)
Deleted.
rsc Mon Mar 7 10:21:48 2005
1990/03091    
#include "u.h" 
#include "lib.h" 
#include "mem.h" 
#include "dat.h" 
#include "fns.h" 
1992/0111    
#include "../port/error.h" 
1990/03091    
                 
1990/0617    
#define PCOFF -1 
1990/0403    
                 
1990/03091    
void 
lock(Lock *l) 
{ 
	int i; 
                 
1991/0821    
	for(i = 0; i < 1000000; i++){ 
1991/0723    
    		if (tas(&l->key) == 0){ 
1991/0820    
			if(u) 
1991/0614    
				u->p->hasspin = 1; 
1991/0723    
			l->pc = ((ulong*)&l)[PCOFF]; 
1990/03091    
			return; 
1990/0601    
		} 
1991/0821    
		if(u && u->p->state == Running) 
			sched(); 
1991/0723    
	} 
	i = l->key; 
	l->key = 0; 
                 
	panic("lock loop 0x%lux key 0x%lux pc 0x%lux held by pc 0x%lux\n", l, i, 
		((ulong*)&l)[PCOFF], l->pc); 
1990/03091    
} 
                 
int 
canlock(Lock *l) 
{ 
1991/0723    
	if(tas(&l->key)) 
		return 0; 
	l->pc = ((ulong*)&l)[PCOFF]; 
	if(u && u->p) 
		u->p->hasspin = 1; 
	return 1; 
1990/03091    
} 
                 
void 
unlock(Lock *l) 
{ 
	l->pc = 0; 
1990/0403    
	l->key = 0; 
1991/0614    
	if(u && u->p) 
		u->p->hasspin = 0; 
1991/0606    
} 


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