diff options
author | John Baldwin <jhb@FreeBSD.org> | 2001-02-10 02:20:34 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2001-02-10 02:20:34 +0000 |
commit | 142ba5f3d79d3fa27e8d3cb464677c9a8c26382b (patch) | |
tree | a479934b0a3b95d7cd72ce5a2c13c832691a3ca6 /sys/kern/subr_trap.c | |
parent | 90b99402a95be74bf848e84c54a79cecc9fcab13 (diff) | |
download | src-142ba5f3d79d3fa27e8d3cb464677c9a8c26382b.tar.gz src-142ba5f3d79d3fa27e8d3cb464677c9a8c26382b.zip |
- Make astpending and need_resched process attributes rather than CPU
attributes. This is needed for AST's to be properly posted in a preemptive
kernel. They are backed by two new flags in p_sflag: PS_ASTPENDING and
PS_NEEDRESCHED. They are still accesssed by their old macros:
aston(), astoff(), etc. For completeness, an astpending() macro has been
added to check for a pending AST, and clear_resched() has been added to
clear need_resched().
- Rename syscall2() on the x86 back to syscall() to be consistent with
other architectures.
Notes
Notes:
svn path=/head/; revision=72276
Diffstat (limited to 'sys/kern/subr_trap.c')
-rw-r--r-- | sys/kern/subr_trap.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 533d7914be4e..d34e4b1850f6 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -105,7 +105,7 @@ int (*pmath_emulate) __P((struct trapframe *)); extern void trap __P((struct trapframe frame)); extern int trapwrite __P((unsigned addr)); -extern void syscall2 __P((struct trapframe frame)); +extern void syscall __P((struct trapframe frame)); extern void ast __P((struct trapframe frame)); static int trap_pfault __P((struct trapframe *, int, vm_offset_t)); @@ -212,7 +212,7 @@ userret(p, frame, oticks) if (!mtx_owned(&Giant)) mtx_lock(&Giant); mtx_lock_spin(&sched_lock); - addupc_task(p, frame->tf_eip, + addupc_task(p, TRAPF_PC(frame), (u_int)(p->p_sticks - oticks) * psratio); } curpriority = p->p_priority; @@ -1075,7 +1075,7 @@ int trapwrite(addr) } /* - * syscall2 - MP aware system call request C handler + * syscall - MP aware system call request C handler * * A system call is essentially treated as a trap except that the * MP lock is not held on entry or return. We are responsible for @@ -1086,7 +1086,7 @@ int trapwrite(addr) * the current stack is allowed without having to hold MP lock. */ void -syscall2(frame) +syscall(frame) struct trapframe frame; { caddr_t params; @@ -1278,10 +1278,22 @@ ast(frame) struct proc *p = CURPROC; u_quad_t sticks; + KASSERT(TRAPF_USERMODE(&frame), ("ast in kernel mode")); + + /* + * We check for a pending AST here rather than in the assembly as + * acquiring and releasing mutexes in assembly is not fun. + */ mtx_lock_spin(&sched_lock); + if (!(astpending() || resched_wanted())) { + mtx_unlock_spin(&sched_lock); + return; + } + sticks = p->p_sticks; - + astoff(); + mtx_intr_enable(&sched_lock); atomic_add_int(&cnt.v_soft, 1); if (p->p_sflag & PS_OWEUPC) { p->p_sflag &= ~PS_OWEUPC; |