From 1eb36d23fd67f0f6ddae37d8fa1f71c9565e540b Mon Sep 17 00:00:00 2001 From: thorpej Date: Sun, 14 Jan 2001 00:10:28 +0000 Subject: [PATCH] - Make ast() loop around astpending; it's possible for a new AST to be posted when delivering signals, or after a process is preempted. - Move all signal posting to ast(). userret() is now a one-liner. --- sys/arch/mips/include/cpu.h | 6 ++--- sys/arch/mips/include/userret.h | 7 +---- sys/arch/mips/mips/trap.c | 45 ++++++++++++++++++++------------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/sys/arch/mips/include/cpu.h b/sys/arch/mips/include/cpu.h index 3f09bc303256..322f717e4051 100644 --- a/sys/arch/mips/include/cpu.h +++ b/sys/arch/mips/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.48 2001/01/11 21:08:18 thorpej Exp $ */ +/* $NetBSD: cpu.h,v 1.49 2001/01/14 00:10:28 thorpej Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -183,8 +183,8 @@ struct clockframe { #define aston() (astpending = 1) -extern int astpending; /* need to trap before returning to user mode */ -extern int want_resched; /* resched() was called */ +extern __volatile int astpending; /* AST pending on return to user mode */ +extern int want_resched; /* resched() was called */ #ifdef MIPS3 extern u_int mips_L2CacheSize; extern int mips_L2CacheIsSnooping; /* L2 cache snoops uncached writes ? */ diff --git a/sys/arch/mips/include/userret.h b/sys/arch/mips/include/userret.h index cc8769338e97..52ac54a63c46 100644 --- a/sys/arch/mips/include/userret.h +++ b/sys/arch/mips/include/userret.h @@ -1,4 +1,4 @@ -/* $NetBSD: userret.h,v 1.1 2001/01/11 18:44:30 thorpej Exp $ */ +/* $NetBSD: userret.h,v 1.2 2001/01/14 00:10:28 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -48,11 +48,6 @@ static __inline void userret(struct proc *p) { - int sig; - - /* take pending signals */ - while ((sig = CURSIG(p)) != 0) - postsig(sig); curcpu()->ci_schedstate.spc_curpriority = p->p_priority = p->p_usrpri; } diff --git a/sys/arch/mips/mips/trap.c b/sys/arch/mips/mips/trap.c index 38ce3b3678a5..c7acb4179b83 100644 --- a/sys/arch/mips/mips/trap.c +++ b/sys/arch/mips/mips/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.154 2001/01/11 18:44:29 thorpej Exp $ */ +/* $NetBSD: trap.c,v 1.155 2001/01/14 00:10:29 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -44,7 +44,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.154 2001/01/11 18:44:29 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.155 2001/01/14 00:10:29 thorpej Exp $"); #include "opt_cputype.h" /* which mips CPU levels do we support? */ #include "opt_ktrace.h" @@ -91,7 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.154 2001/01/11 18:44:29 thorpej Exp $"); #include #endif -int astpending; +__volatile int astpending; int want_resched; const char *trap_type[] = { @@ -691,23 +691,34 @@ ast(pc) unsigned pc; /* program counter where to continue */ { struct proc *p = curproc; + int sig; - uvmexp.softs++; - astpending = 0; + while (astpending) { + uvmexp.softs++; + astpending = 0; - if (p->p_flag & P_OWEUPC) { - p->p_flag &= ~P_OWEUPC; - ADDUPROF(p); + if (p->p_flag & P_OWEUPC) { + p->p_flag &= ~P_OWEUPC; + ADDUPROF(p); + } + + /* Take pending signals. */ + while ((sig = CURSIG(p)) != 0) + postsig(sig); + + if (want_resched) { + /* + * We are being preempted. + */ + preempt(NULL); + + /* Running again; take any new pending signals. */ + while ((sig = CURSIG(p)) != 0) + postsig(sig); + } + + userret(p); } - - if (want_resched) { - /* - * We are being preempted. - */ - preempt(NULL); - } - - userret(p); } /*