From aa2dc0a5d9e7a19420c153cd414fefa8498eab71 Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 29 Jun 2002 17:26:22 +0000 Subject: Part 1 of KSE-III The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals.. --- sys/fs/procfs/procfs_ctl.c | 15 ++++++++------- sys/fs/procfs/procfs_dbregs.c | 2 +- sys/fs/procfs/procfs_fpregs.c | 2 +- sys/fs/procfs/procfs_ioctl.c | 6 ++++-- sys/fs/procfs/procfs_regs.c | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) (limited to 'sys/fs/procfs') diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c index 0f35370..15ed718 100644 --- a/sys/fs/procfs/procfs_ctl.c +++ b/sys/fs/procfs/procfs_ctl.c @@ -62,7 +62,7 @@ * relative to process (curp) */ #define TRACE_WAIT_P(curp, p) \ - ((p)->p_stat == SSTOP && \ + (P_SHOULDSTOP(p) && \ (p)->p_pptr == (curp) && \ ((p)->p_flag & P_TRACED)) @@ -262,6 +262,7 @@ out: */ case PROCFS_CTL_RUN: PROC_UNLOCK(p); + p->p_flag &= ~P_STOPPED_SGNL; /* this uses SIGSTOP */ break; /* @@ -272,27 +273,26 @@ out: case PROCFS_CTL_WAIT: if (p->p_flag & P_TRACED) { while (error == 0 && - (p->p_stat != SSTOP) && + (P_SHOULDSTOP(p)) && (p->p_flag & P_TRACED) && (p->p_pptr == td->td_proc)) error = msleep((caddr_t) p, &p->p_mtx, PWAIT|PCATCH, "procfsx", 0); if (error == 0 && !TRACE_WAIT_P(td->td_proc, p)) error = EBUSY; - } else - while (error == 0 && p->p_stat != SSTOP) + } else { + while (error == 0 && P_SHOULDSTOP(p)) error = msleep((caddr_t) p, &p->p_mtx, PWAIT|PCATCH, "procfs", 0); + } PROC_UNLOCK(p); return (error); - default: panic("procfs_control"); } mtx_lock_spin(&sched_lock); - if (p->p_stat == SSTOP) - setrunnable(FIRST_THREAD_IN_PROC(p)); /* XXXKSE */ + thread_unsuspend(p); /* If it can run, let it do so. */ mtx_unlock_spin(&sched_lock); return (0); } @@ -349,6 +349,7 @@ procfs_doprocctl(PFS_FILL_ARGS) #endif mtx_lock_spin(&sched_lock); /* XXXKSE: */ + p->p_flag &= ~P_STOPPED_SGNL; setrunnable(FIRST_THREAD_IN_PROC(p)); mtx_unlock_spin(&sched_lock); } else diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c index 361f34b..442521c 100644 --- a/sys/fs/procfs/procfs_dbregs.c +++ b/sys/fs/procfs/procfs_dbregs.c @@ -90,7 +90,7 @@ procfs_doprocdbregs(PFS_FILL_ARGS) if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (p->p_stat != SSTOP) + if (!P_SHOULDSTOP(p)) /* XXXKSE should be P_TRACED? */ error = EBUSY; else /* XXXKSE: */ diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c index afabb33..f1401f3 100644 --- a/sys/fs/procfs/procfs_fpregs.c +++ b/sys/fs/procfs/procfs_fpregs.c @@ -84,7 +84,7 @@ procfs_doprocfpregs(PFS_FILL_ARGS) if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (p->p_stat != SSTOP) + if (!P_SHOULDSTOP(p)) error = EBUSY; else /* XXXKSE: */ diff --git a/sys/fs/procfs/procfs_ioctl.c b/sys/fs/procfs/procfs_ioctl.c index 09aef86..9d49be9 100644 --- a/sys/fs/procfs/procfs_ioctl.c +++ b/sys/fs/procfs/procfs_ioctl.c @@ -94,9 +94,11 @@ procfs_ioctl(PFS_IOCTL_ARGS) #if 0 mtx_lock_spin(&sched_lock); p->p_step = 0; - if (p->p_stat == SSTOP) { + if (P_SHOULDSTOP(p)) { p->p_xstat = sig; - setrunnable(FIRST_THREAD_IN_PROC(p)); + p->p_flag &= ~(P_STOPPED_TRACE|P_STOPPED_SGNL); + FOREACH_THREAD_IN_PROC(p, td) + setrunnable(td); /* XXX Totally bogus */ mtx_unlock_spin(&sched_lock); } else { mtx_unlock_spin(&sched_lock); diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c index 5fcb450..6cefe7e 100644 --- a/sys/fs/procfs/procfs_regs.c +++ b/sys/fs/procfs/procfs_regs.c @@ -86,7 +86,7 @@ procfs_doprocregs(PFS_FILL_ARGS) error = uiomove(kv, kl, uio); PROC_LOCK(p); if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (p->p_stat != SSTOP) + if (!P_SHOULDSTOP(p)) error = EBUSY; else /* XXXKSE: */ -- cgit v1.1