From 16c719bebc6ea3163d9ddf789b350b1a6cac9083 Mon Sep 17 00:00:00 2001 From: David Leonard Date: Tue, 16 Jan 2001 04:51:08 +0000 Subject: switch stacks even when restoring a preempted thread. (credit to pefo@) --- lib/libc_r/uthread/uthread_kern.c | 20 ++++++++------------ lib/libpthread/uthread/uthread_kern.c | 20 ++++++++------------ 2 files changed, 16 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c index 716c64f63cb..7b723ba8ddd 100644 --- a/lib/libc_r/uthread/uthread_kern.c +++ b/lib/libc_r/uthread/uthread_kern.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_kern.c,v 1.10 2000/10/04 05:55:35 d Exp $ */ +/* $OpenBSD: uthread_kern.c,v 1.11 2001/01/16 04:51:07 d Exp $ */ /* * Copyright (c) 1995-1998 John Birrell * All rights reserved. @@ -520,6 +520,12 @@ _thread_kern_sched(struct sigcontext * scp) /* Restore errno. */ errno = _thread_run->error; + /* + * Restore the new thread, saving current. + */ + _thread_machdep_switch(&_thread_run->_machdep, + &old_thread_run->_machdep); + /* Check if a signal context was saved: */ if (_thread_run->sig_saved == 1) { /* @@ -542,6 +548,7 @@ _thread_kern_sched(struct sigcontext * scp) thread_run_switch_hook(_last_user_thread, _thread_run); } + _thread_check_cancel(); _thread_sys_sigreturn(&_thread_run->saved_sigcontext); } else { /* @@ -556,18 +563,7 @@ _thread_kern_sched(struct sigcontext * scp) } _thread_check_cancel(); - - /* - * Resume thread _thread_run. - */ - _thread_machdep_switch(&_thread_run->_machdep, - &old_thread_run->_machdep); - /* - * This thread is now the new _thread_run - * again. - */ return; - } /* This point should not be reached. */ diff --git a/lib/libpthread/uthread/uthread_kern.c b/lib/libpthread/uthread/uthread_kern.c index 716c64f63cb..7b723ba8ddd 100644 --- a/lib/libpthread/uthread/uthread_kern.c +++ b/lib/libpthread/uthread/uthread_kern.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_kern.c,v 1.10 2000/10/04 05:55:35 d Exp $ */ +/* $OpenBSD: uthread_kern.c,v 1.11 2001/01/16 04:51:07 d Exp $ */ /* * Copyright (c) 1995-1998 John Birrell * All rights reserved. @@ -520,6 +520,12 @@ _thread_kern_sched(struct sigcontext * scp) /* Restore errno. */ errno = _thread_run->error; + /* + * Restore the new thread, saving current. + */ + _thread_machdep_switch(&_thread_run->_machdep, + &old_thread_run->_machdep); + /* Check if a signal context was saved: */ if (_thread_run->sig_saved == 1) { /* @@ -542,6 +548,7 @@ _thread_kern_sched(struct sigcontext * scp) thread_run_switch_hook(_last_user_thread, _thread_run); } + _thread_check_cancel(); _thread_sys_sigreturn(&_thread_run->saved_sigcontext); } else { /* @@ -556,18 +563,7 @@ _thread_kern_sched(struct sigcontext * scp) } _thread_check_cancel(); - - /* - * Resume thread _thread_run. - */ - _thread_machdep_switch(&_thread_run->_machdep, - &old_thread_run->_machdep); - /* - * This thread is now the new _thread_run - * again. - */ return; - } /* This point should not be reached. */ -- cgit v1.2.3