Protect p_stat with the sched_lock.

Reviewed by:	jake
This commit is contained in:
jhb 2000-12-02 01:58:15 +00:00
parent 4886182e27
commit 1bd3c0064c
2 changed files with 36 additions and 2 deletions

View File

@ -158,8 +158,12 @@ procfs_control(curp, p, op)
break;
default:
if (!TRACE_WAIT_P(curp, p))
mtx_enter(&sched_lock, MTX_SPIN);
if (!TRACE_WAIT_P(curp, p)) {
mtx_exit(&sched_lock, MTX_SPIN);
return (EBUSY);
}
mtx_exit(&sched_lock, MTX_SPIN);
}
@ -234,20 +238,28 @@ procfs_control(curp, p, op)
case PROCFS_CTL_WAIT:
error = 0;
if (p->p_flag & P_TRACED) {
mtx_enter(&sched_lock, MTX_SPIN);
while (error == 0 &&
(p->p_stat != SSTOP) &&
(p->p_flag & P_TRACED) &&
(p->p_pptr == curp)) {
mtx_exit(&sched_lock, MTX_SPIN);
error = tsleep((caddr_t) p,
PWAIT|PCATCH, "procfsx", 0);
mtx_enter(&sched_lock, MTX_SPIN);
}
if (error == 0 && !TRACE_WAIT_P(curp, p))
error = EBUSY;
mtx_exit(&sched_lock, MTX_SPIN);
} else {
mtx_enter(&sched_lock, MTX_SPIN);
while (error == 0 && p->p_stat != SSTOP) {
mtx_exit(&sched_lock, MTX_SPIN);
error = tsleep((caddr_t) p,
PWAIT|PCATCH, "procfs", 0);
mtx_enter(&sched_lock, MTX_SPIN);
}
mtx_exit(&sched_lock, MTX_SPIN);
}
return (error);
@ -255,8 +267,10 @@ procfs_control(curp, p, op)
panic("procfs_control");
}
mtx_enter(&sched_lock, MTX_SPIN);
if (p->p_stat == SSTOP)
setrunnable(p);
mtx_exit(&sched_lock, MTX_SPIN);
return (0);
}
@ -297,13 +311,16 @@ procfs_doctl(curp, p, pfs, uio)
} else {
nm = vfs_findname(signames, msg, xlen);
if (nm) {
mtx_enter(&sched_lock, MTX_SPIN);
if (TRACE_WAIT_P(curp, p)) {
p->p_xstat = nm->nm_val;
#ifdef FIX_SSTEP
FIX_SSTEP(p);
#endif
setrunnable(p);
mtx_exit(&sched_lock, MTX_SPIN);
} else {
mtx_exit(&sched_lock, MTX_SPIN);
psignal(p, nm->nm_val);
}
error = 0;

View File

@ -158,8 +158,12 @@ procfs_control(curp, p, op)
break;
default:
if (!TRACE_WAIT_P(curp, p))
mtx_enter(&sched_lock, MTX_SPIN);
if (!TRACE_WAIT_P(curp, p)) {
mtx_exit(&sched_lock, MTX_SPIN);
return (EBUSY);
}
mtx_exit(&sched_lock, MTX_SPIN);
}
@ -234,20 +238,28 @@ procfs_control(curp, p, op)
case PROCFS_CTL_WAIT:
error = 0;
if (p->p_flag & P_TRACED) {
mtx_enter(&sched_lock, MTX_SPIN);
while (error == 0 &&
(p->p_stat != SSTOP) &&
(p->p_flag & P_TRACED) &&
(p->p_pptr == curp)) {
mtx_exit(&sched_lock, MTX_SPIN);
error = tsleep((caddr_t) p,
PWAIT|PCATCH, "procfsx", 0);
mtx_enter(&sched_lock, MTX_SPIN);
}
if (error == 0 && !TRACE_WAIT_P(curp, p))
error = EBUSY;
mtx_exit(&sched_lock, MTX_SPIN);
} else {
mtx_enter(&sched_lock, MTX_SPIN);
while (error == 0 && p->p_stat != SSTOP) {
mtx_exit(&sched_lock, MTX_SPIN);
error = tsleep((caddr_t) p,
PWAIT|PCATCH, "procfs", 0);
mtx_enter(&sched_lock, MTX_SPIN);
}
mtx_exit(&sched_lock, MTX_SPIN);
}
return (error);
@ -255,8 +267,10 @@ procfs_control(curp, p, op)
panic("procfs_control");
}
mtx_enter(&sched_lock, MTX_SPIN);
if (p->p_stat == SSTOP)
setrunnable(p);
mtx_exit(&sched_lock, MTX_SPIN);
return (0);
}
@ -297,13 +311,16 @@ procfs_doctl(curp, p, pfs, uio)
} else {
nm = vfs_findname(signames, msg, xlen);
if (nm) {
mtx_enter(&sched_lock, MTX_SPIN);
if (TRACE_WAIT_P(curp, p)) {
p->p_xstat = nm->nm_val;
#ifdef FIX_SSTEP
FIX_SSTEP(p);
#endif
setrunnable(p);
mtx_exit(&sched_lock, MTX_SPIN);
} else {
mtx_exit(&sched_lock, MTX_SPIN);
psignal(p, nm->nm_val);
}
error = 0;