diff options
author | jhb <jhb@FreeBSD.org> | 2001-02-22 13:46:09 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-02-22 13:46:09 +0000 |
commit | 13aad95ca7457ac11576f0a6988f9c99e352c179 (patch) | |
tree | 455728b074c70a09de3ef141117fe804e8b5d598 /sys/kern/ksched.c | |
parent | 073b1ca9aa6511f5604c4722ff64cd6fd39ef732 (diff) | |
download | FreeBSD-src-13aad95ca7457ac11576f0a6988f9c99e352c179.zip FreeBSD-src-13aad95ca7457ac11576f0a6988f9c99e352c179.tar.gz |
Lock need_resched with sched_lock.
Reported by: des
Diffstat (limited to 'sys/kern/ksched.c')
-rw-r--r-- | sys/kern/ksched.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c index 27a0899..b729ccf 100644 --- a/sys/kern/ksched.c +++ b/sys/kern/ksched.c @@ -38,9 +38,8 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/proc.h> +#include <sys/mutex.h> #include <sys/resource.h> -#include <machine/cpu.h> /* For need_resched */ -#include <machine/ipl.h> /* For need_resched */ #include <posix4/posix4.h> @@ -174,8 +173,10 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, rtp.type = (policy == SCHED_FIFO) ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; + mtx_lock_spin(&sched_lock); rtp_to_pri(&rtp, &p->p_pri); need_resched(); + mtx_unlock_spin(&sched_lock); } else e = EPERM; @@ -187,6 +188,7 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, { rtp.type = RTP_PRIO_NORMAL; rtp.prio = p4prio_to_rtpprio(param->sched_priority); + mtx_lock_spin(&sched_lock); rtp_to_pri(&rtp, &p->p_pri); /* XXX Simply revert to whatever we had for last @@ -196,6 +198,7 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, * scheduling info alone. */ need_resched(); + mtx_unlock_spin(&sched_lock); } break; } @@ -212,7 +215,9 @@ int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) */ int ksched_yield(register_t *ret, struct ksched *ksched) { + mtx_lock_spin(&sched_lock); need_resched(); + mtx_unlock_spin(&sched_lock); return 0; } |