libthread: simplify alt tracking, possibly fixing bug
This commit is contained in:
parent
acecbb1619
commit
47ede89e4a
3 changed files with 9 additions and 8 deletions
|
|
@ -82,7 +82,6 @@ struct Alt
|
||||||
void *v;
|
void *v;
|
||||||
uint op;
|
uint op;
|
||||||
_Thread *thread;
|
_Thread *thread;
|
||||||
Alt *xalt;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Altarray
|
struct _Altarray
|
||||||
|
|
|
||||||
|
|
@ -234,8 +234,8 @@ altexec(Alt *a)
|
||||||
i = rand()%ar->n;
|
i = rand()%ar->n;
|
||||||
other = ar->a[i];
|
other = ar->a[i];
|
||||||
altcopy(a, other);
|
altcopy(a, other);
|
||||||
altalldequeue(other->xalt);
|
altalldequeue(other->thread->alt);
|
||||||
other->xalt[0].xalt = other;
|
other->thread->alt = other;
|
||||||
_threadready(other->thread);
|
_threadready(other->thread);
|
||||||
}else
|
}else
|
||||||
altcopy(a, nil);
|
altcopy(a, nil);
|
||||||
|
|
@ -256,10 +256,9 @@ chanalt(Alt *a)
|
||||||
canblock = a[i].op == CHANEND;
|
canblock = a[i].op == CHANEND;
|
||||||
|
|
||||||
t = proc()->thread;
|
t = proc()->thread;
|
||||||
for(i=0; i<n; i++){
|
for(i=0; i<n; i++)
|
||||||
a[i].thread = t;
|
a[i].thread = t;
|
||||||
a[i].xalt = a;
|
t->alt = a;
|
||||||
}
|
|
||||||
qlock(&chanlock);
|
qlock(&chanlock);
|
||||||
if(dbgalt) print("alt ");
|
if(dbgalt) print("alt ");
|
||||||
ncan = 0;
|
ncan = 0;
|
||||||
|
|
@ -307,9 +306,11 @@ if(dbgalt)print("\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the guy who ran the op took care of dequeueing us
|
* 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
|
static int
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ struct _Thread
|
||||||
char name[256];
|
char name[256];
|
||||||
char state[256];
|
char state[256];
|
||||||
void *udata;
|
void *udata;
|
||||||
|
Alt *alt;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Procrendez
|
struct _Procrendez
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue