diff options
author | jhb <jhb@FreeBSD.org> | 2000-12-02 01:58:15 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2000-12-02 01:58:15 +0000 |
commit | ad7f89f777bc9c019822aa529881538a3367c50c (patch) | |
tree | af97f27672da39420f04c54c99ef5059d697634d /sys/fs | |
parent | 6dfe475f408580855e7e48216b477daf39091bc4 (diff) | |
download | FreeBSD-src-ad7f89f777bc9c019822aa529881538a3367c50c.zip FreeBSD-src-ad7f89f777bc9c019822aa529881538a3367c50c.tar.gz |
Protect p_stat with the sched_lock.
Reviewed by: jake
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/procfs/procfs_ctl.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c index d96bcb3..72ad575 100644 --- a/sys/fs/procfs/procfs_ctl.c +++ b/sys/fs/procfs/procfs_ctl.c @@ -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; |