Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/port/taslock.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname port/taslock.c 1992/0222
## diff -e /dev/null /n/bootesdump/1992/0222/sys/src/9/port/taslock.c
0a
#include "u.h"
#include "lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"

void
lock(Lock *l)
{
	Lock *ll = l;
	int i;
	ulong pc;

	pc = getcallerpc(((uchar*)&l) - sizeof(l));

	for(i = 0; i < 1000000; i++){
    		if (tas(&ll->key) == 0){
			if(u)
				u->p->hasspin = 1;
			ll->pc = pc;
			return;
		}
		if(u && u->p->state == Running)
			sched();
	}
	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,
		pc, l->pc);
}

int
canlock(Lock *l)
{
	if(tas(&l->key))
		return 0;
	l->pc = getcallerpc(((uchar*)&l) - sizeof(l));
	if(u && u->p)
		u->p->hasspin = 1;
	return 1;
}

void
unlock(Lock *l)
{
	l->pc = 0;
	l->key = 0;
	if(u && u->p)
		u->p->hasspin = 0;
}
.
## diffname port/taslock.c 1992/0321
## diff -e /n/bootesdump/1992/0222/sys/src/9/port/taslock.c /n/bootesdump/1992/0321/sys/src/9/port/taslock.c
2c
#include "../port/lib.h"
.
## diffname port/taslock.c 1992/0428
## diff -e /n/bootesdump/1992/0321/sys/src/9/port/taslock.c /n/bootesdump/1992/0428/sys/src/9/port/taslock.c
16c
if(l == 0){
print("pc= %lux", pc);
for(;;);
}
.
## diffname port/taslock.c 1992/0602
## diff -e /n/bootesdump/1992/0428/sys/src/9/port/taslock.c /n/bootesdump/1992/0602/sys/src/9/port/taslock.c
27,28c
spinner++;
spinpc = pc;
.
16,19c
    	if (tas(&ll->key) == 0){
		if(u)
			u->p->hasspin = 1;
		ll->pc = pc;
		return;
	}
.
7a
ulong spinner;
ulong spinpc;

.
## diffname port/taslock.c 1992/0905
## diff -e /n/bootesdump/1992/0602/sys/src/9/port/taslock.c /n/bootesdump/1992/0905/sys/src/9/port/taslock.c
32,33d
19,25c
	for(i = 0; i < 10000000; i++){
.
8,10d
## diffname port/taslock.c 1992/0912
## diff -e /n/bootesdump/1992/0905/sys/src/9/port/taslock.c /n/bootesdump/1992/0912/sys/src/9/port/taslock.c
16c
	for(i = 0; i < 100000000; i++){
.
## diffname port/taslock.c 1992/0913
## diff -e /n/bootesdump/1992/0912/sys/src/9/port/taslock.c /n/bootesdump/1992/0913/sys/src/9/port/taslock.c
44a
	int s;

.
## diffname port/taslock.c 1992/0914
## diff -e /n/bootesdump/1992/0913/sys/src/9/port/taslock.c /n/bootesdump/1992/0914/sys/src/9/port/taslock.c
45,46d
26,28c
	panic("lock loop 0x%lux key 0x%lux pc 0x%lux held by pc 0x%lux\n",
			l->key, i, pc, l->pc);
.
24d
20c
			l->pc = pc;
.
16,17c

	for(i = 0; i < 10000000; i++){
    		if (tas(&l->key) == 0){
.
11d
## diffname port/taslock.c 1993/0501
## diff -e /n/bootesdump/1992/0914/sys/src/9/port/taslock.c /n/fornaxdump/1993/0501/sys/src/brazil/port/taslock.c
45,46d
35,36d
18,19d
## diffname port/taslock.c 1993/0525
## diff -e /n/fornaxdump/1993/0501/sys/src/brazil/port/taslock.c /n/fornaxdump/1993/0525/sys/src/brazil/port/taslock.c
24c
			i, l->key, pc, l->pc);
.
22d
## diffname port/taslock.c 1993/0528
## diff -e /n/fornaxdump/1993/0525/sys/src/brazil/port/taslock.c /n/fornaxdump/1993/0528/sys/src/brazil/port/taslock.c
16c
	for(i = 0; i < 20000000; i++){
.
## diffname port/taslock.c 1993/0830
## diff -e /n/fornaxdump/1993/0528/sys/src/brazil/port/taslock.c /n/fornaxdump/1993/0830/sys/src/brazil/port/taslock.c
22,23d
20d
11,18c
	for(;;){
		while(l->key)
			;
		if(tas(&l->key) == 0)
.
## diffname port/taslock.c 1993/1204
## diff -e /n/fornaxdump/1993/0830/sys/src/brazil/port/taslock.c /n/fornaxdump/1993/1204/sys/src/brazil/port/taslock.c
10a
	if(tas(&l->key) == 0)
		return;
.
## diffname port/taslock.c 1994/0322
## diff -e /n/fornaxdump/1993/1204/sys/src/brazil/port/taslock.c /n/fornaxdump/1994/0322/sys/src/brazil/port/taslock.c
34a
}

void
iunlock(Lock *l)
{
	ulong sr;

	sr = l->sr;
	l->key = 0;
	splx(sr);
.
33d
26c

.
20a
void
ilock(Lock *l)
{
	l->sr = splhi();
	if(tas(&l->key) == 0)
		return;

	for(;;){
		while(l->key)
			;
		if(tas(&l->key) == 0)
			return;
	}
}

.
12a

.
## diffname port/taslock.c 1994/0323
## diff -e /n/fornaxdump/1994/0322/sys/src/brazil/port/taslock.c /n/fornaxdump/1994/0323/sys/src/brazil/port/taslock.c
33a
		}
.
32c
		if(tas(&l->key) == 0){
			l->sr = x;
.
27a
	}
.
25,26c
	ulong x;

	x = splhi();
	if(tas(&l->key) == 0){
		l->sr = x;
.
## diffname port/taslock.c 1994/0507
## diff -e /n/fornaxdump/1994/0323/sys/src/brazil/port/taslock.c /n/fornaxdump/1994/0507/sys/src/brazil/port/taslock.c
32c
/* print("ilock loop %lux\n", getcallerpc(0)); */
.
## diffname port/taslock.c 1994/0516
## diff -e /n/fornaxdump/1994/0507/sys/src/brazil/port/taslock.c /n/fornaxdump/1994/0516/sys/src/brazil/port/taslock.c
32c
 print("ilock loop %lux\n", getcallerpc(0));
.
## diffname port/taslock.c 1994/0525
## diff -e /n/fornaxdump/1994/0516/sys/src/brazil/port/taslock.c /n/fornaxdump/1994/0525/sys/src/brazil/port/taslock.c
32c

.
## diffname port/taslock.c 1994/0805
## diff -e /n/fornaxdump/1994/0525/sys/src/brazil/port/taslock.c /n/fornaxdump/1994/0805/sys/src/brazil/port/taslock.c
15,16c
		while(l->key) {
			if(loop-- <= 0) {
				dumpstack();
				panic("lock loop: lock %lux\n", l);
			}
		}
.
13a
	loop = 50000000;
.
10a
	int loop;

.
## diffname port/taslock.c 1994/0808
## diff -e /n/fornaxdump/1994/0805/sys/src/brazil/port/taslock.c /n/fornaxdump/1994/0808/sys/src/brazil/port/taslock.c
18,23c
		while(l->key)
			;
.
16d
11,12d
## diffname port/taslock.c 1995/0108
## diff -e /n/fornaxdump/1994/0808/sys/src/brazil/port/taslock.c /n/fornaxdump/1995/0108/sys/src/brazil/port/taslock.c
55a
	if(up) {
		n = up->inlock-2;
		if(n < 0)
			n = 0;
		up->inlock = n;
	}
.
54a
	int n;

.
13d
10a
	int n;

	if(up) {
		n = up->inlock+2;
		up->inlock = n;
		if(tas(&l->key) == 0)
			return;

		for(;;){
			while(l->key)
				if(conf.nproc == 1) {
					up->yield = 1;
					sched();
				}
			up->inlock = n;
			if(tas(&l->key) == 0)
				return;
		}
	}

.
## diffname port/taslock.c 1995/0109
## diff -e /n/fornaxdump/1995/0108/sys/src/brazil/port/taslock.c /n/fornaxdump/1995/0109/sys/src/brazil/port/taslock.c
91c
	unlock(l);
.
85a
ilock(Lock *l)
{
	ulong sr;

	sr = splhi();
	lock(l);
	l->sr = sr;
}

void
.
82a
	l->key = 0;
.
76d
67d
62,64d
60d
58a
		return 1;
.
46,57c
	if(up) {
		n = up->inlock;
		up->inlock = n+2;
		if(tas(&l->key)) {
			up->inlock = n;
			return 0;
.
44c
	int n;
.
41,42c
int
canlock(Lock *l)
.
## diffname port/taslock.c 1995/0110
## diff -e /n/fornaxdump/1995/0109/sys/src/brazil/port/taslock.c /n/fornaxdump/1995/0110/sys/src/brazil/port/taslock.c
91c
	l->key = 0;
.
76,85d
64,71d
57a

.
44,55d
37a
		}
.
36c
		if(tas(&l->key) == 0){
			l->sr = x;
.
32a
	}

.
31c
void
ilock(Lock *l)
{
	ulong x;

	x = splhi();
	if(tas(&l->key) == 0){
		l->sr = x;
.
29a
}
.
18,28d
13,15c
	for(;;){
		while(l->key)
			;
.
11c
	if(tas(&l->key) == 0)
		return;
.
## diffname port/taslock.c 1995/1009
## diff -e /n/fornaxdump/1995/0110/sys/src/brazil/port/taslock.c /n/fornaxdump/1995/1009/sys/src/brazil/port/taslock.c
48a
	l->pc = getcallerpc(l);
.
37a
			l->pc = pc;
.
29a
		l->pc = pc;
.
26a
	pc = getcallerpc(l);

.
25a
	ulong pc;
.
18a
		}
.
16,17c
			if(i++ > 10000000)
				panic("lock loop key 0x%lux pc 0x%lux held by pc 0x%lux\n",
					l->key, getcallerpc(l), l->pc);
		if(tas(&l->key) == 0){
			l->pc = pc;
.
14a
		i = 0;
.
12a
	}
.
11c
	int i;
	ulong pc;

	pc = getcallerpc(l);

	if(tas(&l->key) == 0){
		l->pc = pc;
.
## diffname port/taslock.c 1995/1014
## diff -e /n/fornaxdump/1995/1009/sys/src/brazil/port/taslock.c /n/fornaxdump/1995/1014/sys/src/brazil/port/taslock.c
82a
	l->pc = 0;
.
73a
	l->pc = 0;
.
24,26c
			if(i++ > 100000000)
				panic("lock loop key 0x%lux pc 0x%lux held by pc 0x%lux pl 0x%lux\n",
					l->key, pc, l->pc, splhi());
.
## diffname port/taslock.c 1995/1030
## diff -e /n/fornaxdump/1995/1014/sys/src/brazil/port/taslock.c /n/fornaxdump/1995/1030/sys/src/brazil/port/taslock.c
66a
	l->pid = up ? up->pid : 0;
.
54a
			l->pid = pid;
.
45a
		l->pid = pid;
.
40a
	pid = up ? up->pid : 0;
.
38c
	ulong pc, pid;
.
28a
			l->pid = pid;
.
24,26c
			if(i++ > 100000000){
				i = 0;
				lockloop(l, pc);
			}
.
17a
		l->pid = pid;
.
14a
	pid = up ? up->pid : 0;
.
12c
	ulong pc, pid;
.
8a
lockloop(Lock *l, ulong pc)
{
	print("lock loop key 0x%lux pc 0x%lux held by pc 0x%lux proc %d\n",
		l->key, pc, l->pc, l->pid);
	dumpaproc(up);
}

void
.
## diffname port/taslock.c 1996/0511
## diff -e /n/fornaxdump/1995/1030/sys/src/brazil/port/taslock.c /n/fornaxdump/1996/0511/sys/src/brazil/port/taslock.c
90a
	l->key = 0;
	if(up != 0)
		up->priority = p;
.
89c
	int p;

	p = l->pri;
.
81,82c
	SET(pri);
	if(up) {
		pri = up->priority;
		up->priority = PriLock;
	}
	if(tas(&l->key)) {
		up->priority = pri;
		l->pc = getcallerpc(l);
		return 0;
	}
	l->pri = pri;
.
78,79c
	int pri;
.
43a
	lockloop(l, pc);
.
42a
		if(conf.nmach == 1 && up->state == Running && (getstatus()&IE))
			sched();
.
40d
38a
			l->pri = pri;
.
31,37c
	pri = up->priority;
	up->priority = PriLock;

	for(i=0; i<1000; i++){
.
25,27c
	if(up == 0) {
		for(i=0; i<1000000; i++)
			if(tas(&l->key) == 0){
				l->pc = pc;
				return;
			}
		lockloop(l, pc);
.
23d
19,20c
	int pri, i;
	ulong pc;
.
## diffname port/taslock.c 1996/0516
## diff -e /n/fornaxdump/1996/0511/sys/src/brazil/port/taslock.c /n/fornaxdump/1996/0516/sys/src/brazil/port/taslock.c
105,106c
	l->pri = 0;
.
100,102d
89d
86,87c
	else
		pri = 0;
.
83,84c
	if(up)
.
46a
	up->lockpri = 0;	/* back to normal priority */
.
39a
			up->lockpri = 0;	/* back to normal priority */
.
37a
		up->lockpri = l->pri;		/* assume priority of process holding lock */
.
35d
33a
	/* priority interacts with code in ready() in proc.c */
.
27a
				l->pri = 0;
.
## diffname port/taslock.c 1996/0517
## diff -e /n/fornaxdump/1996/0516/sys/src/brazil/port/taslock.c /n/fornaxdump/1996/0517/sys/src/brazil/port/taslock.c
38c
	for(i=0; i<1000000; i++){
.
## diffname port/taslock.c 1996/0522
## diff -e /n/fornaxdump/1996/0517/sys/src/brazil/port/taslock.c /n/fornaxdump/1996/0522/sys/src/brazil/port/taslock.c
114a
	l->pri = 0;
.
103a
	l->pc = 0;
.
102d
95d
93a

	l->pc = getcallerpc(l);
	if(up){
		l->pid = up->pid;
		l->pri = up->priority;
	} else {
		l->pid = 0;
		l->pri = 0;
.
85,92c
	if(tas(&l->key))
.
76a
			l->pri = 0;
.
66a
		l->pri = 0;
.
49,50d
46,47d
43a
			l->pid = pid;
			l->pri = pri;
			up->lockpri = 0;
.
41,42d
38,39c
				/* possible priority inversion, try switching priority */
				if(up && up->state == Running)
				if(getstatus()&IE) {
print("priority inversion\n");
					up->lockpri = l->pri;
					sched();
				}
			}

.
35,36c
	spins = 0;
	for(;;){
		i = 0;
		while(l->key)
			if(i++ > SPINLOOP){
				/* look for lock loops */
				if(spins++ > LOCKLOOP/SPINLOOP){
					spins = 0;
					lockloop(l, pc);
				}
.
24,31c
	/* quick try, it might work */
	if(tas(&l->key) == 0){
		l->pc = pc;
		l->pid = pid;
		l->pri = pri;
.
22a
	if(up){
		pid = up->pid;
		pri = up->priority;
	} else {
		pid = 0;
		pri = 0;
	}
.
19,20c
	int i, pri, spins;
	ulong pc, pid;
.
15a
#define LOCKLOOP 100000000	/* to detect a lock loop */
#define SPINLOOP 10000000	/* to keep tas's off the bus */

.
## diffname port/taslock.c 1996/0523
## diff -e /n/fornaxdump/1996/0522/sys/src/brazil/port/taslock.c /n/fornaxdump/1996/0523/sys/src/brazil/port/taslock.c
136d
125d
110,116c
	l->pid = up ? up->pid : 0;
.
97d
86d
65,66c
			if(up)
				up->lockpri = 0;
.
61d
46,59c
			if(i++ > 100000000){
				i = 0;
				lockloop(l, pc);
.
42d
38d
34d
26,32c
	pid = up ? up->pid : 0;
.
22c
	int i;
.
16,18d
13a

	/* lower priority till we get the lock */
	if(up && up->state == Running && (getstatus()&IE)){
		up->lockpri = 1;
		sched();
	}
.
## diffname port/taslock.c 1997/0220
## diff -e /n/fornaxdump/1996/0523/sys/src/brazil/port/taslock.c /n/emeliedump/1997/0220/sys/src/brazil/port/taslock.c
109a
	coherence();
.
98a
	coherence();
.
## diffname port/taslock.c 1997/0327
## diff -e /n/emeliedump/1997/0220/sys/src/brazil/port/taslock.c /n/emeliedump/1997/0327/sys/src/brazil/port/taslock.c
109a
	l->key = 0;
.
108d
98a
	l->key = 0;
.
97d
16c
	if(up && up->state == Running && islo()){
.
## diffname port/taslock.c 1997/0409
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/port/taslock.c /n/emeliedump/1997/0409/sys/src/brazil/port/taslock.c
73a
#else
{   int i;
    i = 0;
    while(l->key){
	if(i++ > 100000000)
	    panic("ilock loop: caller pc %luX, held by %luX\n", pc, l->pc);
    }
}
#endif /* notdef */
.
71a
#ifdef notdef
.
## diffname port/taslock.c 1997/0411
## diff -e /n/emeliedump/1997/0409/sys/src/brazil/port/taslock.c /n/emeliedump/1997/0411/sys/src/brazil/port/taslock.c
75,83d
72d
## diffname port/taslock.c 1998/0228
## diff -e /n/emeliedump/1997/0411/sys/src/brazil/port/taslock.c /n/emeliedump/1998/0228/sys/src/brazil/port/taslock.c
73a
		x = splhi();
.
71a
		splx(x);
.
## diffname port/taslock.c 1998/0522
## diff -e /n/emeliedump/1998/0228/sys/src/brazil/port/taslock.c /n/emeliedump/1998/0522/sys/src/brazil/port/taslock.c
98a
	if(l->key == 0)
		print("unlock: not locked: pc %uX\n", getcallerpc(l));
.
70a
	if(conf.nmach < 2)
		panic("ilock: no way out: pc %uX\n", pc);

.
## diffname port/taslock.c 1998/0603
## diff -e /n/emeliedump/1998/0522/sys/src/brazil/port/taslock.c /n/emeliedump/1998/0603/sys/src/brazil/port/taslock.c
113a
	if(l->key == 0)
		print("iunlock: not locked: pc %uX\n", getcallerpc(l));

.
## diffname port/taslock.c 1998/0604
## diff -e /n/emeliedump/1998/0603/sys/src/brazil/port/taslock.c /n/emeliedump/1998/0604/sys/src/brazil/port/taslock.c
115a
	if(!l->isilock)
		print("unlock of ilock: pc %lux, held by %lux\n", getcallerpc(l), l->pc);
.
105a
	if(up && p < up->priority)
		up->priority = p;
.
103a
	if(l->isilock)
		print("iunlock of lock: pc %lux, held by %lux\n", getcallerpc(l), l->pc);
.
101a
	int p;

	p = l->pri;
.
95c
	l->p = up;
	l->isilock = 0;
	if(up){
		l->pri = up->priority;
		up->priority = PriLock;
	}
.
82c
			l->p = up;
			l->isilock = 1;
.
67c
		l->p = up;
		l->isilock = 1;
.
61d
58c
	ulong pc;
.
46,48c
			l->p = up;
			l->isilock = 0;
			if(up){
				l->pri = up->priority;
				up->priority = PriLock;
			}
.
43a
		}
.
39,42c
		while(l->key){
			if(conf.nmach < 2){
				if(i++ > 1000){
					i = 0;
					lockloop(l, pc);
				}
				sched();
			} else {
				if(i++ > 100000000){
					i = 0;
					lockloop(l, pc);
				}
.
33c
		l->p = up;
		l->isilock = 0;
		if(up){
			l->pri = up->priority;
			up->priority = PriLock;
		}
.
29d
26c
	ulong pc;
.
19d
15,17c
	if(up && up->state == Running && islo())
.
12c
		l->key, pc, l->pc, l->p ? l->p->pid : 0);
.
## diffname port/taslock.c 1998/0605
## diff -e /n/emeliedump/1998/0604/sys/src/brazil/port/taslock.c /n/emeliedump/1998/0605/sys/src/brazil/port/taslock.c
147a
	if(up) {
		if (--up->nlocks < 0)
			print("number of locks < 0: pc %lux, held by %lux\n",
				getcallerpc(l), l->pc);
	}
.
130,131c
	if(up) {
		if (up != l->p) {
			print("different unlocker 0x%lux pc 0x%lux held by pc 0x%lux proc %d\n",
				l->key, pc, l->pc, l->p ? l->p->pid : 0);
			dumpaproc(up);
		}
		if (--up->nlocks < 0)
			print("number of locks < 0: pc %lux, held by %lux\n",
				getcallerpc(l), l->pc);
		if (p < up->priority)
			up->priority = p;
	}
.
122a
	pc = getcallerpc(l);

.
121a
	ulong pc;
.
111a
		up->nlocks++;
.
92a
			if (up)
			 up->nlocks++;
.
76a
		if (up)
			up->nlocks++;
.
58a
				up->nlocks++;
.
31a
			up->nlocks++;
.
## diffname port/taslock.c 1998/0606
## diff -e /n/emeliedump/1998/0605/sys/src/brazil/port/taslock.c /n/emeliedump/1998/0606/sys/src/brazil/port/taslock.c
174a

	m->splpc = getcallerpc(l);
	splxpc(sr);
.
168,173d
140,151d
131,133d
128,129d
117,121d
102a
			if(cansched){
				up->lockwait = 0;
				up->priority = oldpri;
			}
.
97,98d
91a
lockstats.inglare++;
.
87a
lockstats.glare++;
	cansched = up != nil && up->state == Running;
	if(cansched){
		oldpri = up->priority;
		up->lockwait = 1;
		up->priority = PriLock;
	} else
		oldpri = 0;
.
79,80d
75a
lockstats.locks++;
.
73c
	ulong pc, oldpri;
	int cansched;
.
59,62c
			if(cansched){
				up->lockwait = 0;
				up->priority = oldpri;
.
42c
			if(conf.nmach < 2 && cansched){
.
39a
lockstats.inglare++;
.
38a
lockstats.glare++;
	cansched = up != nil && up->state == Running;
	if(cansched){
		oldpri = up->priority;
		up->lockwait = 1;
		up->priority = PriLock;
	} else
		oldpri = 0;

.
31,35d
26a
lockstats.locks++;
.
22,23c
	int i, cansched;
	ulong pc, oldpri;
.
13a
	if(p != nil)
		dumpaproc(p);
.
12c
		l->key, pc, l->pc, p ? p->pid : 0);
.
10a
	Proc *p;

	p = l->p;
.
7a
struct {
	ulong	locks;
	ulong	glare;
	ulong	inglare;
} lockstats;

.
## diffname port/taslock.c 1998/0825
## diff -e /n/emeliedump/1998/0606/sys/src/brazil/port/taslock.c /n/emeliedump/1998/0825/sys/src/brazil/port/taslock.c
166c
		print("iunlock: not locked: pc %luX\n", getcallerpc(l));
.
152c
		print("unlock: not locked: pc %luX\n", getcallerpc(l));
.
20c
	print("lock loop key 0x%lux pc 0x%lux held by pc 0x%lux proc %lud\n",
.
## diffname port/taslock.c 1999/0319
## diff -e /n/emeliedump/1998/0825/sys/src/brazil/port/taslock.c /n/emeliedump/1999/0319/sys/src/brazil/port/taslock.c
113c
		panic("ilock: no way out: pc %uX held by %uX\n", pc, l->pc);
.
## diffname port/taslock.c 1999/0402
## diff -e /n/emeliedump/1999/0319/sys/src/brazil/port/taslock.c /n/emeliedump/1999/0402/sys/src/brazil/port/taslock.c
113c
		panic("ilock: no way out: pc %uX\n", pc);
.
## diffname port/taslock.c 1999/0501
## diff -e /n/emeliedump/1999/0402/sys/src/brazil/port/taslock.c /n/emeliedump/1999/0501/sys/src/brazil/port/taslock.c
175c
	m->splpc = getcallerpc(&l);
.
168c
		print("unlock of ilock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc);
.
166c
		print("iunlock: not locked: pc %luX\n", getcallerpc(&l));
.
154c
		print("iunlock of lock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc);
.
152c
		print("unlock: not locked: pc %luX\n", getcallerpc(&l));
.
141c
	l->pc = getcallerpc(&l);
.
92c
	pc = getcallerpc(&l);
.
36c
	pc = getcallerpc(&l);
.
## diffname port/taslock.c 1999/0710
## diff -e /n/emeliedump/1999/0501/sys/src/brazil/port/taslock.c /n/emeliedump/1999/0710/sys/src/brazil/port/taslock.c
168c
		print("iunlock of lock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc);
.
154c
		print("unlock of ilock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc);
.
## diffname port/taslock.c 1999/0810
## diff -e /n/emeliedump/1999/0710/sys/src/brazil/port/taslock.c /n/emeliedump/1999/0810/sys/src/brazil/port/taslock.c
104a
if(l->glare++ > 10000){
print("glare %lux\n", l);
l->glare = 0;
}
.
## diffname port/taslock.c 1999/0811
## diff -e /n/emeliedump/1999/0810/sys/src/brazil/port/taslock.c /n/emeliedump/1999/0811/sys/src/brazil/port/taslock.c
120c
		lockstats.inglare++;
.
104,108c
	lockstats.glare++;
.
93c
	lockstats.locks++;
.
56c
		lockstats.inglare++;
.
46c
	lockstats.glare++;
.
38c
	lockstats.locks++;
.
## diffname port/taslock.c 2000/1101
## diff -e /n/emeliedump/1999/0811/sys/src/brazil/port/taslock.c /n/emeliedump/2000/1101/sys/src/9/port/taslock.c
19a
{
ulong x = (ulong)p;
uchar *cp;
int i;
if(x < KTZERO) {
	cp = (uchar*)l;
	for(i = 0; i < 64; i++) print("%2.2ux ", cp[i]);
	print("\n");
}
}
.
## diffname port/taslock.c 2000/1106
## diff -e /n/emeliedump/2000/1101/sys/src/9/port/taslock.c /n/emeliedump/2000/1106/sys/src/9/port/taslock.c
123a
}
.
122a
{
dumplockmem("ilock:", l);
.
20,29d
13a
static void
dumplockmem(char *tag, Lock *l)
{
	uchar *cp;
	int i;

	iprint("%s: ", tag);
	cp = (uchar*)l;
	for(i = 0; i < 64; i++)
		iprint("%2.2ux ", cp[i]);
	iprint("\n");
}

.
## diffname port/taslock.c 2001/0127
## diff -e /n/emeliedump/2000/1106/sys/src/9/port/taslock.c /n/emeliedump/2001/0127/sys/src/9/port/taslock.c
189c
	//coherence();
.
173c
	//coherence();
.
## diffname port/taslock.c 2001/0314
## diff -e /n/emeliedump/2001/0127/sys/src/9/port/taslock.c /n/emeliedump/2001/0314/sys/src/9/port/taslock.c
189c
	coherence();
.
173c
	coherence();
.
## diffname port/taslock.c 2001/0527
## diff -e /n/emeliedump/2001/0314/sys/src/9/port/taslock.c /n/emeliedump/2001/0527/sys/src/9/port/taslock.c
33,34c
	print("lock 0x%lux loop key 0x%lux pc 0x%lux held by pc 0x%lux proc %lud\n",
		l, l->key, pc, l->pc, p ? p->pid : 0);
.
## diffname port/taslock.c 2001/0920
## diff -e /n/emeliedump/2001/0527/sys/src/9/port/taslock.c /n/emeliedump/2001/0920/sys/src/9/port/taslock.c
32a
print("lock loop %p\n", l);
delay(1000);
.
## diffname port/taslock.c 2002/0114
## diff -e /n/emeliedump/2001/0920/sys/src/9/port/taslock.c /n/emeliedump/2002/0114/sys/src/9/port/taslock.c
130c
		panic("ilock: no way out: pc %luX\n", pc);
.
## diffname port/taslock.c 2002/0315
## diff -e /n/emeliedump/2002/0114/sys/src/9/port/taslock.c /n/emeliedump/2002/0315/sys/src/9/port/taslock.c
175a
	if (l->edfwaiting)
		edf_releaselock(l);
.
168d
145c
				up->lockwait = nil;
.
123c
		up->lockwait = l;
.
92c
				up->lockwait = nil;
.
74,75c
			if (isedf(up)){
				/* Edf process waiting for a lock; process holding lock will not
				 * be scheduled unless we give up the processor.  We give up
				 * the processor, but make sure we get awoken when the lock
				 * is released
				 */
				if (edf_waitlock(l))
					sched();
			} else if(conf.nmach < 2 && cansched){
				if (i++ > 1000){
.
66a
		up->lockwait = l;
.
65d
6a
#include "../port/edf.h"
.
## diffname port/taslock.c 2002/0322
## diff -e /n/emeliedump/2002/0315/sys/src/9/port/taslock.c /n/emeliedump/2002/0322/sys/src/9/port/taslock.c
84c
				if (i++ > 5000){
.
## diffname port/taslock.c 2002/0328
## diff -e /n/emeliedump/2002/0322/sys/src/9/port/taslock.c /n/emeliedump/2002/0328/sys/src/9/port/taslock.c
184,185d
75,84c
			if(conf.nmach < 2 && cansched){
				if (i++ > 1000){
.
## diffname port/taslock.c 2002/0402
## diff -e /n/emeliedump/2002/0328/sys/src/9/port/taslock.c /n/emeliedump/2002/0402/sys/src/9/port/taslock.c
174a
	if (up && --up->nlocks == 0 && up->delaysched){
		up->delaysched = 0;
		sched();
	}
.
172a
	if(l->p != up)
		print("unlock: up changed: pc %lux, acquired at pc %lux, lock p 0x%p, unlock up 0x%p\n", getcallerpc(&l), l->pc, l->p, up);
//	decpcref(l);
.
160a
//	incpcref(l);
.
159a
	if (up) up->lastlock = l;
.
158a
	}
.
157c
	if (up) up->nlocks++;
	if(tas(&l->key)){
		if (up) up->nlocks--;
.
140a
			if (up) up->lastlock = l;
.
132c
	}
.
128,130c
	if(conf.nmach < 2){
		dumplockmem("ilock:", l);
.
112a
		if (up) up->lastlock = l;
.
97a
		if (up) up->nlocks--;
.
89a
//			incpcref(l);
.
88a
			if (up) up->lastlock = l;
.
87a
		if (up) up->nlocks++;
.
60a
	if (up) up->nlocks--;	/* didn't get the lock, allow scheding */
.
56a
//		incpcref(l);
.
55a
		if (up) up->lastlock = l;
.
54c
	lockstats.locks++;	/* prevent being scheded */
	if (up) up->nlocks++;
.
14a
typedef struct PC {
	ulong	pc;
	int	count;
} PC;

PC lpcs[1024];

void
incpcref(Lock *l)
{
	int i;

	for(i = 0; i < nelem(lpcs)-1; i++){
		if(lpcs[i].pc == l->pc)
			break;
		if(lpcs[i].pc == 0){
			lpcs[i].pc = l->pc;
			break;
		}
	}
	lpcs[i].count++;
}

void
decpcref(Lock *l)
{
	int i;

	for(i = 0; i < nelem(lpcs)-1; i++){
		if(lpcs[i].pc == l->pc)
			break;
		if(lpcs[i].pc == 0){
			lpcs[i].pc = l->pc;
			break;
		}
	}
	lpcs[i].count--;
}

.
7d
## diffname port/taslock.c 2002/0403
## diff -e /n/emeliedump/2002/0402/sys/src/9/port/taslock.c /n/emeliedump/2002/0403/sys/src/9/port/taslock.c
248c
	l->pc = ~1;
.
227,228c
	l->pc = ~0;
.
212d
210c
	if(up)
		up->lastlock = l;
.
206c
		if(up)
			up->nlocks--;
.
204c
	if(up)
		up->nlocks++;
.
192,195d
168,174d
159c
		if(up)
			up->lastlock = l;
.
151,152c
	ulong pc;
.
143c
		if(up)
			up->nlocks--;
.
137,141c
			return 1;
.
134d
132c
			if(up)
				up->lastlock = l;
.
130c
		if(up)
			up->nlocks++;
.
117,127c
			if(i++ > 100000000){
				i = 0;
				lockloop(l, pc);
.
105,112d
102c
	if(up)
		up->nlocks--;	/* didn't get the lock, allow scheding */
.
100c
		return 0;
.
97d
92,93c
	lockstats.locks++;
	if(up)
		up->nlocks++;	/* prevent being scheded */
.
87,88c
	int i;
	ulong pc;
.
84c
int
.
72,73d
14,52d
8c
struct
{
.
## diffname port/taslock.c 2002/0404
## diff -e /n/emeliedump/2002/0403/sys/src/9/port/taslock.c /n/emeliedump/2002/0404/sys/src/9/port/taslock.c
181d
161d
123c
			if(up)
				up->lastlock = l;
.
87a
	return 0;	/* For the compiler */
.
56c
		if(up)
			up->lastlock = l;
.
## diffname port/taslock.c 2002/0406
## diff -e /n/emeliedump/2002/0404/sys/src/9/port/taslock.c /n/emeliedump/2002/0406/sys/src/9/port/taslock.c
169d
165c
	coherence();

	/* give up the processor if ... */
	if(up && --up->nlocks == 0	/* we've closed the last nexted lock */
	&& up->delaysched		/* we delayed scheduling because of the lock */
	&& up->state == Running){	/* we're in running state */
.
## diffname port/taslock.c 2002/0413
## diff -e /n/emeliedump/2002/0406/sys/src/9/port/taslock.c /n/emeliedump/2002/0413/sys/src/9/port/taslock.c
170,172c
	&& up->state == Running){		/* we're in running state */
		if(!islo())
			buggeredsched++;
		else{
			up->delaysched = 0;
			sched();
		}
.
168c
	if(up && --up->nlocks == 0	/* we've closed the last nested lock */
.
154a
int buggeredsched;
.
## diffname port/taslock.c 2002/0414
## diff -e /n/emeliedump/2002/0413/sys/src/9/port/taslock.c /n/emeliedump/2002/0414/sys/src/9/port/taslock.c
168,178c
	if(up)
		--up->nlocks;
.
155d
## diffname port/taslock.c 2002/0416
## diff -e /n/emeliedump/2002/0414/sys/src/9/port/taslock.c /n/emeliedump/2002/0416/sys/src/9/port/taslock.c
167,168c
	/* give up the processor if ... */
	if(up && --up->nlocks == 0	/* we've closed the last nexted lock */
	&& up->delaysched		/* we delayed scheduling because of the lock */
	&& up->state == Running){	/* we're in running state */
		up->delaysched = 0;
		sched();
	}
.
## diffname port/taslock.c 2002/0418
## diff -e /n/emeliedump/2002/0416/sys/src/9/port/taslock.c /n/emeliedump/2002/0418/sys/src/9/port/taslock.c
184a
	if(islo())
		print("iunlock while lo: pc %lux, held by %lux\n", getcallerpc(&l), l->pc);
.
## diffname port/taslock.c 2002/0420
## diff -e /n/emeliedump/2002/0418/sys/src/9/port/taslock.c /n/emeliedump/2002/0420/sys/src/9/port/taslock.c
192a
	m->ilockdepth--;
.
167,173c
	if(up)
		--up->nlocks;
.
101a
	m->ilockdepth++;
.
39,41d
## diffname port/taslock.c 2002/0421
## diff -e /n/emeliedump/2002/0420/sys/src/9/port/taslock.c /n/emeliedump/2002/0421/sys/src/9/port/taslock.c
122a
			m->ilockdepth++;
.
100a
		m->ilockdepth++;
.
99d
## diffname port/taslock.c 2002/0626
## diff -e /n/emeliedump/2002/0421/sys/src/9/port/taslock.c /n/emeliedump/2002/0626/sys/src/9/port/taslock.c
125c
				up->lastilock = l;
.
102c
			up->lastilock = l;
.
## diffname port/taslock.c 2002/0925
## diff -e /n/emeliedump/2002/0626/sys/src/9/port/taslock.c /n/emeliedump/2002/0925/sys/src/9/port/taslock.c
187a
	if(up)
		up->lastilock = nil;
.
## diffname port/taslock.c 2003/0405
## diff -e /n/emeliedump/2002/0925/sys/src/9/port/taslock.c /n/emeliedump/2003/0405/sys/src/9/port/taslock.c
82a
	if(l->key == 0x55555555)
		panic("lock(7): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
74a
	if(l->key == 0x55555555)
		panic("lock(6): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
72a
	if(l->key == 0x55555555)
		panic("lock(5): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
70a
	if(l->key == 0x55555555)
		panic("lock(4): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
69a
	if(l->key == 0x55555555)
		panic("lock(3): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
66a
	if(l->key == 0x55555555)
		panic("lock(2): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
59a
	if(l->key == 0x55555555)
		panic("lock(1a): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
51a
	if(l->key == 0x55555555)
		panic("lock(1): l %p, key 5*, pc %.lux, %p\n", l, pc, _l);
.
45a
Lock *_l = l;
.
## diffname port/taslock.c 2003/0418
## diff -e /n/emeliedump/2003/0405/sys/src/9/port/taslock.c /n/emeliedump/2003/0418/sys/src/9/port/taslock.c
98,99d
88,89d
84,85d
80,81d
77,78d
72,73d
63,64d
53,54d
46d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].