fix scheduler bug; see plt-scheme 2007-Feb-5 post and reply

svn: r5552
This commit is contained in:
Matthew Flatt 2007-02-05 14:26:41 +00:00
parent 73d0e1ca10
commit e3a513aa0d
3 changed files with 10 additions and 9 deletions

View File

@ -385,7 +385,7 @@ typedef struct Scheme_Security_Guard {
/* Always allocated on the stack: */
typedef struct {
int false_positive_ok; /* non-zero => return 1 to swap in thread rather than running Scheme code */
Scheme_Thread *false_positive_ok; /* non-zero => return 1 to swap in thread rather than running Scheme code */
int potentially_false_positive; /* => returning 1 to swap thread in, but truth may be 0 */
Scheme_Object *current_syncing;
double sleep_end;

View File

@ -430,7 +430,10 @@ static void ext_get_into_line(Scheme_Object *ch, Scheme_Schedule_Info *sinfo)
/* Get into line */
w = MALLOC_ONE_RT(Scheme_Channel_Syncer);
w->so.type = scheme_channel_syncer_type;
w->p = scheme_current_thread;
if (sinfo->false_positive_ok)
w->p = sinfo->false_positive_ok;
else
w->p = scheme_current_thread;
w->syncing = (Syncing *)sinfo->current_syncing;
w->obj = ch;
w->syncing_i = sinfo->w_i;
@ -459,8 +462,8 @@ static int try_channel(Scheme_Sema *sema, Syncing *syncing, int pos, Scheme_Obje
w = w->next;
} else {
Scheme_Channel_Put *chp = (Scheme_Channel_Put *)w->obj;
if (!w->syncing->result && !pending_break(w->p)) {
if (!w->syncing->result && !pending_break(w->p)) {
w->picked = 1;
w->syncing->result = w->syncing_i + 1;
if (w->syncing->disable_break)

View File

@ -3288,9 +3288,7 @@ END_XFORM_SKIP;
#endif
#define FALSE_POS_OK_INIT 1
static void init_schedule_info(Scheme_Schedule_Info *sinfo, int false_pos_ok,
static void init_schedule_info(Scheme_Schedule_Info *sinfo, Scheme_Thread *false_pos_ok,
double sleep_end)
{
sinfo->false_positive_ok = false_pos_ok;
@ -3647,7 +3645,7 @@ void scheme_thread_block(float sleep_time)
if (next->block_check) {
Scheme_Ready_Fun_FPC f = (Scheme_Ready_Fun_FPC)next->block_check;
Scheme_Schedule_Info sinfo;
init_schedule_info(&sinfo, FALSE_POS_OK_INIT, next->sleep_end);
init_schedule_info(&sinfo, next, next->sleep_end);
if (f(next->blocker, &sinfo))
break;
next->sleep_end = sinfo.sleep_end;
@ -3795,7 +3793,7 @@ void scheme_thread_block(float sleep_time)
if (p->block_check) {
Scheme_Ready_Fun_FPC f = (Scheme_Ready_Fun_FPC)p->block_check;
Scheme_Schedule_Info sinfo;
init_schedule_info(&sinfo, FALSE_POS_OK_INIT, sleep_end);
init_schedule_info(&sinfo, p, sleep_end);
if (f(p->blocker, &sinfo)) {
sleep_end = 0;
} else {