aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2000-12-02 01:32:51 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2000-12-02 01:32:51 +0000
commit0ebabc93a454467be57821c02ac5182e1bb34699 (patch)
treee0485694c6bebbb0c0ec0f54c58628afedc6c3cb /sys/kern/tty.c
parent3cd59d7b9c74c4bfb7e5559b4fd3652020a2e473 (diff)
downloadsrc-0ebabc93a454467be57821c02ac5182e1bb34699.tar.gz
src-0ebabc93a454467be57821c02ac5182e1bb34699.zip
Protect p_stat with sched_lock.
Notes
Notes: svn path=/head/; revision=69506
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 1117708cb982..ce11ea52017c 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -2254,6 +2254,7 @@ ttyinfo(tp)
if (proc_compare(pick, p))
pick = p;
+ mtx_enter(&sched_lock, MTX_SPIN);
ttyprintf(tp, " cmd: %s %d [%s] ", pick->p_comm, pick->p_pid,
pick->p_stat == SRUN ? "running" :
pick->p_wmesg ? pick->p_wmesg : "iowait");
@@ -2278,6 +2279,7 @@ ttyinfo(tp)
pick->p_stat == SIDL || pick->p_stat == SWAIT ||
pick->p_stat == SZOMB ? 0 :
(long)pgtok(vmspace_resident_count(pick->p_vmspace)));
+ mtx_exit(&sched_lock, MTX_SPIN);
}
tp->t_rocount = 0; /* so pending input will be retyped if BS */
}
@@ -2308,15 +2310,20 @@ proc_compare(p1, p2)
if (p1 == NULL)
return (1);
+
+ mtx_enter(&sched_lock, MTX_SPIN);
/*
* see if at least one of them is runnable
*/
switch (TESTAB(ISRUN(p1), ISRUN(p2))) {
case ONLYA:
+ mtx_exit(&sched_lock, MTX_SPIN);
return (0);
case ONLYB:
+ mtx_exit(&sched_lock, MTX_SPIN);
return (1);
case BOTH:
+ mtx_exit(&sched_lock, MTX_SPIN);
/*
* tie - favor one with highest recent cpu utilization
*/
@@ -2331,12 +2338,17 @@ proc_compare(p1, p2)
*/
switch (TESTAB(p1->p_stat == SZOMB, p2->p_stat == SZOMB)) {
case ONLYA:
+ mtx_exit(&sched_lock, MTX_SPIN);
return (1);
case ONLYB:
+ mtx_exit(&sched_lock, MTX_SPIN);
return (0);
case BOTH:
+ mtx_exit(&sched_lock, MTX_SPIN);
return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
+ mtx_exit(&sched_lock, MTX_SPIN);
+
/*
* pick the one with the smallest sleep time
*/