aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/channel.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2007-08-22 11:14:30 -0400
committerRuss Cox <rsc@swtch.com>2007-08-22 11:14:30 -0400
commit47ede89e4a832de2dada80599c1260f456275f19 (patch)
tree13a3c18def343a39c2124a0674a79ee8cbce6870 /src/libthread/channel.c
parentacecbb161981dcbe1f1e356c3ad586741a2240b9 (diff)
downloadplan9port-47ede89e4a832de2dada80599c1260f456275f19.tar.gz
plan9port-47ede89e4a832de2dada80599c1260f456275f19.tar.bz2
plan9port-47ede89e4a832de2dada80599c1260f456275f19.zip
libthread: simplify alt tracking, possibly fixing bug
Diffstat (limited to 'src/libthread/channel.c')
-rw-r--r--src/libthread/channel.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libthread/channel.c b/src/libthread/channel.c
index 903889a4..080f84de 100644
--- a/src/libthread/channel.c
+++ b/src/libthread/channel.c
@@ -234,8 +234,8 @@ altexec(Alt *a)
i = rand()%ar->n;
other = ar->a[i];
altcopy(a, other);
- altalldequeue(other->xalt);
- other->xalt[0].xalt = other;
+ altalldequeue(other->thread->alt);
+ other->thread->alt = other;
_threadready(other->thread);
}else
altcopy(a, nil);
@@ -256,10 +256,9 @@ chanalt(Alt *a)
canblock = a[i].op == CHANEND;
t = proc()->thread;
- for(i=0; i<n; i++){
+ for(i=0; i<n; i++)
a[i].thread = t;
- a[i].xalt = a;
- }
+ t->alt = a;
qlock(&chanlock);
if(dbgalt) print("alt ");
ncan = 0;
@@ -307,9 +306,11 @@ if(dbgalt)print("\n");
/*
* the guy who ran the op took care of dequeueing us
- * and then set a[0].alt to the one that was executed.
+ * and then set t->alt to the one that was executed.
*/
- return a[0].xalt - a;
+ if(t->alt < a || t->alt >= a+n)
+ sysfatal("channel bad alt");
+ return t->alt - a;
}
static int