Don't call pthread__locked_switch() to switch to ourself. Bad stack

mangling results.

Fixes regression in test yield2, dating to 2003/1/2 when
pthread__locked_switch() was changed to not store the saved-context
pointer until after switching stacks.

Note to self: regression tests exist to be run.
This commit is contained in:
nathanw 2003-04-04 01:08:25 +00:00
parent 167192b8c4
commit 4777259ff2

View File

@ -1,4 +1,4 @@
/* $NetBSD: pthread_run.c,v 1.8 2003/03/08 08:03:35 lukem Exp $ */ /* $NetBSD: pthread_run.c,v 1.9 2003/04/04 01:08:25 nathanw Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__RCSID("$NetBSD: pthread_run.c,v 1.8 2003/03/08 08:03:35 lukem Exp $"); __RCSID("$NetBSD: pthread_run.c,v 1.9 2003/04/04 01:08:25 nathanw Exp $");
#include <ucontext.h> #include <ucontext.h>
@ -78,7 +78,11 @@ sched_yield(void)
next = PTQ_FIRST(&pthread__runqueue); next = PTQ_FIRST(&pthread__runqueue);
PTQ_REMOVE(&pthread__runqueue, next, pt_runq); PTQ_REMOVE(&pthread__runqueue, next, pt_runq);
next->pt_state = PT_STATE_RUNNING; next->pt_state = PT_STATE_RUNNING;
pthread__locked_switch(self, next, &pthread__runqueue_lock); if (next != self)
pthread__locked_switch(self, next,
&pthread__runqueue_lock);
else
pthread_spinunlock(self, &pthread__runqueue_lock);
} }
return 0; return 0;