commit 47ede89e4a832de2dada80599c1260f456275f19 from: Russ Cox date: Wed Aug 22 15:14:30 2007 UTC libthread: simplify alt tracking, possibly fixing bug commit - acecbb161981dcbe1f1e356c3ad586741a2240b9 commit + 47ede89e4a832de2dada80599c1260f456275f19 blob - 2301191d7738c27508f6cab69b9a3e7b02de0fcc blob + 739fe0fefef9dcc076c72679289b95a441e81c68 --- include/thread.h +++ include/thread.h @@ -82,7 +82,6 @@ struct Alt void *v; uint op; _Thread *thread; - Alt *xalt; }; struct _Altarray blob - 903889a4ea95c2f69834f89092b68d9f1881605c blob + 080f84de18c8c95374e63541bc055982b7e6b228 --- src/libthread/channel.c +++ 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; ialt = 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 blob - 2a69d4975762dc1098914da59a877350d2310003 blob + bc18d3a4c7489ada9da5c8ddaf6f1b0d7b1266ad --- src/libthread/threadimpl.h +++ src/libthread/threadimpl.h @@ -114,6 +114,7 @@ struct _Thread char name[256]; char state[256]; void *udata; + Alt *alt; }; struct _Procrendez