From: Simon Schubert Date: Sun, 18 Feb 2007 16:12:43 +0000 (+0000) Subject: 1:1 Userland threading stage 2.13/4: X-Git-Tag: v2.0.1~3493 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/9a379a4ace7aa61d2193727302b23d8b70163560 1:1 Userland threading stage 2.13/4: Move P_SINTR and P_BREAKTSLEEP into lwp_flag. Introduce proc_stop and proc_unstop to handle the transition of a complete proc to and from stopped state. This is influenced by NetBSD. --- diff --git a/bin/ps/print.c b/bin/ps/print.c index f83945098c..8b7dc5a4df 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -32,7 +32,7 @@ * * @(#)print.c 8.6 (Berkeley) 4/16/94 * $FreeBSD: src/bin/ps/print.c,v 1.36.2.4 2002/11/30 13:00:14 tjr Exp $ - * $DragonFly: src/bin/ps/print.c,v 1.29 2007/02/16 23:11:39 corecode Exp $ + * $DragonFly: src/bin/ps/print.c,v 1.30 2007/02/18 16:12:42 corecode Exp $ */ #include @@ -182,7 +182,7 @@ state(const KINFO *k, const struct varent *vent) case SACTIVE: switch (KI_LWP(k, stat)) { case LSSLEEP: - if (flag & P_SINTR) /* interruptable (long) */ + if (KI_LWP(k, flags) & LWP_SINTR) /* interruptable (long) */ *cp = KI_LWP(k, slptime) >= MAXSLP ? 'I' : 'S'; else if (KI_LWP(k, tdflags) & TDF_SINTR) *cp = 'S'; diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index bc43dbce51..864ee5ce99 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -31,7 +31,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" $FreeBSD: src/bin/ps/ps.1,v 1.24.2.7 2002/06/20 22:43:33 charnier Exp $ -.\" $DragonFly: src/bin/ps/ps.1,v 1.13 2007/02/16 12:45:12 corecode Exp $ +.\" $DragonFly: src/bin/ps/ps.1,v 1.14 2007/02/18 16:12:43 corecode Exp $ .\" .Dd April 6, 2006 .Dt PS 1 @@ -197,37 +197,7 @@ The percentage of real memory used by this process. .It Cm flags The flags associated with the process as in the include file -.In sys/proc.h : -.Bl -column P_BREAKTSLEEP 0x10000000 -.It Dv "P_ADVLOCK" Ta No "0x00001 Process may hold a POSIX advisory lock" -.It Dv "P_CONTROLT" Ta No "0x00002 Has a controlling terminal" -.It Dv "P_SWAPPEDOUT" Ta No "0x00004 Swapped out of memory" -.It Dv "P_BREAKTSLEEP" Ta No "0x00008 Event pending, break tsleep on sigcont" -.It Dv "P_PPWAIT" Ta No "0x00010 Parent is waiting for child to exec/exit" -.It Dv "P_PROFIL" Ta No "0x00020 Has started profiling" -.It Dv "P_SELECT" Ta No "0x00040 Selecting; wakeup/waiting danger" -.It Dv "P_SINTR" Ta No "0x00080 Sleep is interruptible" -.It Dv "P_SUGID" Ta No "0x00100 Had set id privileges since last exec" -.It Dv "P_SYSTEM" Ta No "0x00200 System proc: no sigs, stats or swapping" -.It Dv "P_STOPPED" Ta No "0x00400 SIGSTOP status" -.It Dv "P_TRACED" Ta No "0x00800 Debugged process being traced" -.It Dv "P_WAITED" Ta No "0x01000 SIGSTOP status was returned by wait3/4" -.It Dv "P_WEXIT" Ta No "0x02000 Working on exiting" -.It Dv "P_EXEC" Ta No "0x04000 Process called exec" -.It Dv "P_UPCALLPEND" Ta No "0x20000 An upcall is pending" -.It Dv "P_SWAPWAIT" Ta No "0x40000 Waiting for a swapin" -.It Dv "P_ZOMBIE" Ta No "0x80000 Now in a zombied state" -.It Dv "P_ONRUNQ" Ta No "0x100000 On a user scheduling run queue" -.It Dv "P_KTHREADP" Ta No "0x200000 Process is really a kernel thread" -.It Dv "P_IDLESWAP" Ta No "0x400000 Swapout was due to idleswap, not load" -.It Dv "P_DEADLKTREAT" Ta No "0x800000 Lock aquisition - deadlock treatment" -.It Dv "P_JAILED" Ta No "0x1000000 Process is in jail" -.It Dv "P_OLDMASK" Ta No "0x2000000 Need to restore mask before pause" -.It Dv "P_ALTSTACK" Ta No "0x4000000 have alternate signal stack" -.It Dv "P_INEXEC" Ta No "0x8000000 Process is in execve()" -.It Dv "P_PASSIVE_ACQ" Ta No "0x10000000 Passive acquire cpu (see kern_switch)" -.It Dv "P_UPCALLWAIT" Ta No "0x20000000 Wait for upcall or signal" -.El +.In sys/proc.h . .It Cm lim The soft limit on memory used, specified via a call to .Xr setrlimit 2 . diff --git a/share/man/man9/sleep.9 b/share/man/man9/sleep.9 index 742386b473..f2b2f0cbf3 100644 --- a/share/man/man9/sleep.9 +++ b/share/man/man9/sleep.9 @@ -56,7 +56,7 @@ .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD: src/share/man/man9/sleep.9,v 1.18.2.5 2001/12/17 11:30:19 ru Exp $ -.\" $DragonFly: src/share/man/man9/sleep.9,v 1.6 2006/10/19 18:44:00 swildner Exp $ +.\" $DragonFly: src/share/man/man9/sleep.9,v 1.7 2007/02/18 16:12:43 corecode Exp $ .\" " .Dd May 10, 2004 .Os @@ -139,7 +139,7 @@ ignores priority information because it is not required by the .Tn LWKT subsystem. Sleeps without the -.Dv P_SINTR +.Dv LWP_SINTR flag set are assumed to be disk-waits, otherwise they are normal sleeps. .Sh RETURN VALUES diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index eaec8a58e6..90185cf168 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -37,7 +37,7 @@ * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 * $FreeBSD: src/sys/kern/kern_exit.c,v 1.92.2.11 2003/01/13 22:51:16 dillon Exp $ - * $DragonFly: src/sys/kern/kern_exit.c,v 1.70 2007/02/16 23:11:39 corecode Exp $ + * $DragonFly: src/sys/kern/kern_exit.c,v 1.71 2007/02/18 16:12:43 corecode Exp $ */ #include "opt_compat.h" @@ -448,7 +448,7 @@ loop: * two-line hack restores this effect. */ while (q->p_stat == SSTOP) - tstop(q); + tstop(); nfound = 0; LIST_FOREACH(p, &q->p_children, p_sibling) { diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 1f3f5dc57b..c7c23424d9 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -37,7 +37,7 @@ * * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 * $FreeBSD: src/sys/kern/kern_sig.c,v 1.72.2.17 2003/05/16 16:34:34 obrien Exp $ - * $DragonFly: src/sys/kern/kern_sig.c,v 1.63 2007/02/16 23:11:39 corecode Exp $ + * $DragonFly: src/sys/kern/kern_sig.c,v 1.64 2007/02/18 16:12:43 corecode Exp $ */ #include "opt_ktrace.h" @@ -915,7 +915,7 @@ ksignal(struct proc *p, int sig) * be noticed when the process returns through * trap() or syscall(). */ - if ((p->p_flag & P_SINTR) == 0) + if ((lp->lwp_flag & LWP_SINTR) == 0) goto out; /* @@ -933,7 +933,7 @@ ksignal(struct proc *p, int sig) * If the process is sleeping and SA_CONT, and the signal * mode is SIG_DFL, then make the process runnable. * - * However, do *NOT* set P_BREAKTSLEEP. We do not want + * However, do *NOT* set LWP_BREAKTSLEEP. We do not want * a SIGCONT to terminate an interruptable tsleep early * and generate a spurious EINTR. */ @@ -965,12 +965,8 @@ ksignal(struct proc *p, int sig) * lwps should stop as soon as they safely can. */ SIGDELSET(p->p_siglist, sig); - p->p_stat = SSTOP; - p->p_flag &= ~P_WAITED; p->p_xstat = sig; - wakeup(p->p_pptr); - if ((p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP) == 0) - ksignal(p->p_pptr, SIGCHLD); + proc_stop(p, 1); goto out; } @@ -995,8 +991,10 @@ ksignal(struct proc *p, int sig) * If the process is stopped and receives a KILL signal, * make the process runnable. */ - if (sig == SIGKILL) - goto run; + if (sig == SIGKILL) { + proc_unstop(p); + goto out; + } /* * If the process is stopped and receives a CONT signal, @@ -1013,14 +1011,10 @@ ksignal(struct proc *p, int sig) */ if (action == SIG_DFL) SIGDELSET(p->p_siglist, sig); + proc_unstop(p); if (action == SIG_CATCH) goto run; - - /* - * Make runnable but do not break a tsleep unless - * some other signal was pending. - */ - goto run_no_break; + goto out; } /* @@ -1035,11 +1029,11 @@ ksignal(struct proc *p, int sig) /* * Otherwise the process is sleeping interruptably but - * is stopped, just set the P_BREAKTSLEEP flag and take + * is stopped, just set the LWP_BREAKTSLEEP flag and take * no further action. The next runnable action will wake * the process up. */ - p->p_flag |= P_BREAKTSLEEP; + lp->lwp_flag |= LWP_BREAKTSLEEP; goto out; } @@ -1084,9 +1078,9 @@ run: /* * Make runnable and break out of any tsleep as well. */ - p->p_flag |= P_BREAKTSLEEP; + lp->lwp_flag |= LWP_BREAKTSLEEP; run_no_break: - setrunnable(p); + setrunnable(lp); out: crit_exit(); } @@ -1114,6 +1108,27 @@ signotify_remote(void *arg) #endif +void +proc_stop(struct proc *p, int notify) +{ + /* XXX lwp */ + p->p_stat = SSTOP; + p->p_flag &= ~P_WAITED; + wakeup(p->p_pptr); + if (notify > 1 || + notify && (p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP) == 0) + ksignal(p->p_pptr, SIGCHLD); +} + +void +proc_unstop(struct proc *p) +{ + struct lwp *lp = FIRST_LWP_IN_PROC(p); /* XXX lwp */ + + p->p_stat = SACTIVE; + setrunnable(lp); +} + static int kern_sigtimedwait(sigset_t waitset, siginfo_t *info, struct timespec *timeout) { @@ -1350,13 +1365,10 @@ issignal(struct lwp *lp) * XXX not sure if this is still true */ p->p_xstat = sig; - p->p_stat = SSTOP; - p->p_flag &= ~P_WAITED; - ksignal(p->p_pptr, SIGCHLD); + proc_stop(p, 2); do { - tstop(p); + tstop(); } while (!trace_req(p) && (p->p_flag & P_TRACED)); - p->p_stat = SACTIVE; /* * If parent wants us to take the signal, @@ -1430,13 +1442,9 @@ issignal(struct lwp *lp) prop & SA_TTYSTOP)) break; /* == ignore */ p->p_xstat = sig; - p->p_stat = SSTOP; - p->p_flag &= ~P_WAITED; - - if ((p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP) == 0) - ksignal(p->p_pptr, SIGCHLD); + proc_stop(p, 1); while (p->p_stat == SSTOP) { - tstop(p); + tstop(); } break; } else if (prop & SA_IGNORE) { diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index e8ec17cf13..4695a58ef9 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -37,7 +37,7 @@ * * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 * $FreeBSD: src/sys/kern/kern_synch.c,v 1.87.2.6 2002/10/13 07:29:53 kbyanc Exp $ - * $DragonFly: src/sys/kern/kern_synch.c,v 1.73 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/kern/kern_synch.c,v 1.74 2007/02/18 16:12:43 corecode Exp $ */ #include "opt_ktrace.h" @@ -413,7 +413,7 @@ tsleep(void *ident, int flags, const char *wmesg, int timo) /* * Causes ksignal to wake us up when. */ - p->p_flag |= P_SINTR; + lp->lwp_flag |= LWP_SINTR; } /* @@ -523,7 +523,8 @@ resume: error = ERESTART; } } - p->p_flag &= ~(P_BREAKTSLEEP | P_SINTR | P_MAILBOX); + lp->lwp_flag &= ~(LWP_BREAKTSLEEP | LWP_SINTR); + p->p_flag &= ~P_MAILBOX; } logtsleep(tsleep_end); crit_exit_quick(td); @@ -596,7 +597,7 @@ msleep(void *ident, struct spinlock *spin, int flags, /* * Implement the timeout for tsleep. * - * We set P_BREAKTSLEEP to indicate that an event has occured, but + * We set LWP_BREAKTSLEEP to indicate that an event has occured, but * we only call setrunnable if the process is not stopped. * * This type of callout timeout is scheduled on the same cpu the process @@ -606,7 +607,7 @@ static void endtsleep(void *arg) { thread_t td = arg; - struct proc *p; + struct lwp *lp; ASSERT_MP_LOCK_HELD(curthread); crit_enter(); @@ -619,10 +620,10 @@ endtsleep(void *arg) if (td->td_flags & TDF_TSLEEPQ) { td->td_flags |= TDF_TIMEOUT; - if ((p = td->td_proc) != NULL) { - p->p_flag |= P_BREAKTSLEEP; - if (p->p_stat != SSTOP) - setrunnable(p); + if ((lp = td->td_lwp) != NULL) { + lp->lwp_flag |= LWP_BREAKTSLEEP; + if (lp->lwp_proc->p_stat != SSTOP) + setrunnable(lp); } else { unsleep_and_wakeup_thread(td); } @@ -899,22 +900,22 @@ wakeup_domain_one(void *ident, int domain) * * Make a process runnable. The MP lock must be held on call. This only * has an effect if we are in SSLEEP. We only break out of the - * tsleep if P_BREAKTSLEEP is set, otherwise we just fix-up the state. + * tsleep if LWP_BREAKTSLEEP is set, otherwise we just fix-up the state. * * NOTE: With the MP lock held we can only safely manipulate the process * structure. We cannot safely manipulate the thread structure. */ void -setrunnable(struct proc *p) +setrunnable(struct lwp *lp) { - /* XXX lwp */ - struct lwp *lp = FIRST_LWP_IN_PROC(p); + enum lwpstat stat; + crit_enter(); ASSERT_MP_LOCK_HELD(curthread); - p->p_stat = SACTIVE; /* XXX lwp */ - if (lp->lwp_stat == LSSLEEP && (p->p_flag & P_BREAKTSLEEP)) { + stat = lp->lwp_stat; + lp->lwp_stat = LSRUN; + if (stat == LSSLEEP && (lp->lwp_flag & LWP_BREAKTSLEEP)) unsleep_and_wakeup_thread(lp->lwp_thread); - } crit_exit(); } @@ -926,18 +927,19 @@ setrunnable(struct proc *p) * because the parent may check the child's status before the child actually * gets to this routine. * - * This routine is called with the current process only, typically just + * This routine is called with the current lwp only, typically just * before returning to userland. * - * Setting P_BREAKTSLEEP before entering the tsleep will cause a passive + * Setting LWP_BREAKTSLEEP before entering the tsleep will cause a passive * SIGCONT to break out of the tsleep. */ void -tstop(struct proc *p) +tstop(void) { - wakeup((caddr_t)p->p_pptr); - p->p_flag |= P_BREAKTSLEEP; - tsleep(p, 0, "stop", 0); + struct lwp *lp = curthread->td_lwp; + + lp->lwp_flag |= LWP_BREAKTSLEEP; + tsleep(lp->lwp_proc, 0, "stop", 0); } /* diff --git a/sys/kern/kern_threads.c b/sys/kern/kern_threads.c index b720cf824a..5cdfeecfc8 100644 --- a/sys/kern/kern_threads.c +++ b/sys/kern/kern_threads.c @@ -47,7 +47,7 @@ * and I certainly make no claims as to its fitness for *any* purpose. * * $FreeBSD: src/sys/kern/kern_threads.c,v 1.15 1999/08/28 00:46:15 peter Exp $ - * $DragonFly: src/sys/kern/kern_threads.c,v 1.11 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/kern/kern_threads.c,v 1.12 2007/02/18 16:12:43 corecode Exp $ */ #include @@ -81,6 +81,7 @@ int sys_thr_sleep(struct thr_sleep_args *uap) { struct proc *p = curproc; + struct lwp *lp = curthread->td_lwp; int sleepstart; struct timespec ts; struct timeval atv; @@ -110,9 +111,9 @@ sys_thr_sleep(struct thr_sleep_args *uap) uap->sysmsg_result = 0; if (p->p_wakeup == 0) { sleepstart = ticks; - p->p_flag |= P_SINTR; + lp->lwp_flag |= LWP_SINTR; error = tsleep(p, 0, "thrslp", timo); - p->p_flag &= ~P_SINTR; + lp->lwp_flag &= ~LWP_SINTR; if (error == EWOULDBLOCK) { p->p_wakeup = 0; uap->sysmsg_result = EAGAIN; diff --git a/sys/kern/lwkt_msgport.c b/sys/kern/lwkt_msgport.c index 89199a0e86..01d38df736 100644 --- a/sys/kern/lwkt_msgport.c +++ b/sys/kern/lwkt_msgport.c @@ -34,7 +34,7 @@ * NOTE! This file may be compiled for userland libraries as well as for * the kernel. * - * $DragonFly: src/sys/kern/lwkt_msgport.c,v 1.36 2007/02/03 17:05:58 corecode Exp $ + * $DragonFly: src/sys/kern/lwkt_msgport.c,v 1.37 2007/02/18 16:12:43 corecode Exp $ */ #ifdef _KERNEL @@ -695,7 +695,7 @@ lwkt_default_waitport(lwkt_port_t port, lwkt_msg_t msg) /* * XXX set TDF_SINTR so 'ps' knows the difference between * an interruptable wait and a disk wait. YYY eventually - * move P_SINTR to TDF_SINTR to reduce duplication. + * move LWP_SINTR to TDF_SINTR to reduce duplication. */ td->td_flags |= TDF_SINTR | TDF_BLOCKED; lwkt_deschedule_self(td); diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 7fa93f9851..bc9f4e7842 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -37,7 +37,7 @@ * * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/sys_generic.c,v 1.55.2.10 2001/03/17 10:39:32 peter Exp $ - * $DragonFly: src/sys/kern/sys_generic.c,v 1.41 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/kern/sys_generic.c,v 1.42 2007/02/18 16:12:43 corecode Exp $ */ #include "opt_ktrace.h" @@ -1120,9 +1120,9 @@ selwakeup(struct selinfo *sip) * setrunnable is called, but only call setrunnable * here if the process is not in a stopped state. */ - p->p_flag |= P_BREAKTSLEEP; + lp->lwp_flag |= LWP_BREAKTSLEEP; if (p->p_stat != SSTOP) - setrunnable(p); + setrunnable(lp); } else if (p->p_flag & P_SELECT) { p->p_flag &= ~P_SELECT; } diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 7651e1fc30..47d268f379 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -29,7 +29,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/sys_process.c,v 1.51.2.6 2003/01/08 03:06:45 kan Exp $ - * $DragonFly: src/sys/kern/sys_process.c,v 1.28 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/kern/sys_process.c,v 1.29 2007/02/18 16:12:43 corecode Exp $ */ #include @@ -452,13 +452,13 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data, int *re sendsig: /* * Deliver or queue signal. If the process is stopped - * force it to SRUN again. + * force it to be SACTIVE again. */ crit_enter(); if (p->p_stat == SSTOP) { p->p_xstat = data; - p->p_flag |= P_BREAKTSLEEP; - setrunnable(p); + lp->lwp_flag |= LWP_BREAKTSLEEP; + proc_unstop(p); } else if (data) { ksignal(p, data); } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index f0871a2c00..6fde73e92c 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -37,7 +37,7 @@ * * @(#)tty.c 8.8 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/tty.c,v 1.129.2.5 2002/03/11 01:32:31 dd Exp $ - * $DragonFly: src/sys/kern/tty.c,v 1.37 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/kern/tty.c,v 1.38 2007/02/18 16:12:43 corecode Exp $ */ /*- @@ -2430,7 +2430,7 @@ ttyinfo(struct tty *tp) * with the highest cpu utilization is picked (p_cpticks). Ties are * broken by picking the highest pid. * 3) The sleeper with the shortest sleep time is next. With ties, - * we pick out just "short-term" sleepers (P_SINTR == 0). + * we pick out just "short-term" sleepers (LWP_SINTR == 0). * 4) Further ties are broken by picking the highest pid. */ #define ISRUN(lp) ((lp)->lwp_stat == LSRUN) @@ -2489,9 +2489,9 @@ proc_compare(struct proc *p1, struct proc *p2) /* * favor one sleeping in a non-interruptible sleep */ - if (p1->p_flag & P_SINTR && (p2->p_flag & P_SINTR) == 0) + if (lp1->lwp_flag & LWP_SINTR && (lp2->lwp_flag & LWP_SINTR) == 0) return (1); - if (p2->p_flag & P_SINTR && (p1->p_flag & P_SINTR) == 0) + if (lp2->lwp_flag & LWP_SINTR && (lp1->lwp_flag & LWP_SINTR) == 0) return (0); return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ } diff --git a/sys/platform/pc32/i386/trap.c b/sys/platform/pc32/i386/trap.c index 74b6bdd4fb..48bd63b727 100644 --- a/sys/platform/pc32/i386/trap.c +++ b/sys/platform/pc32/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.98 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.99 2007/02/18 16:12:43 corecode Exp $ */ /* @@ -252,7 +252,7 @@ recheck: */ if (p->p_stat == SSTOP) { get_mplock(); - tstop(p); + tstop(); rel_mplock(); goto recheck; } diff --git a/sys/platform/vkernel/i386/trap.c b/sys/platform/vkernel/i386/trap.c index 7e717d4c12..46e82adb20 100644 --- a/sys/platform/vkernel/i386/trap.c +++ b/sys/platform/vkernel/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/trap.c,v 1.17 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/trap.c,v 1.18 2007/02/18 16:12:43 corecode Exp $ */ /* @@ -238,7 +238,7 @@ recheck: */ if (p->p_stat == SSTOP) { get_mplock(); - tstop(p); + tstop(); rel_mplock(); goto recheck; } diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 18e83715bb..c867a389ec 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.93 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.94 2007/02/18 16:12:43 corecode Exp $ */ #ifndef _SYS_PROC_H_ @@ -308,11 +308,11 @@ struct proc { #define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */ #define P_CONTROLT 0x00002 /* Has a controlling terminal. */ #define P_SWAPPEDOUT 0x00004 /* Swapped out of memory */ -#define P_BREAKTSLEEP 0x00008 /* Event pending, break tsleep on sigcont */ +#define P_UNUSED3 0x00008 /* was: Event pending, break tsleep on sigcont */ #define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */ #define P_PROFIL 0x00020 /* Has started profiling. */ #define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */ -#define P_SINTR 0x00080 /* Sleep is interruptible. */ +#define P_UNUSED4 0x00080 /* was: Sleep is interruptible. */ #define P_SUGID 0x00100 /* Had set id privileges since last exec. */ #define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */ #define P_UNUSED2 0x00400 /* was: SIGSTOP status */ @@ -346,6 +346,8 @@ struct proc { #define LWP_ALTSTACK 0x0000001 /* have alternate signal stack */ #define LWP_OLDMASK 0x0000002 /* need to restore mask before pause */ +#define LWP_BREAKTSLEEP 0x0000004 /* Event pending, break tsleep on sigcont */ +#define LWP_SINTR 0x0000008 /* Sleep is interruptible. */ #define FIRST_LWP_IN_PROC(p) LIST_FIRST(&(p)->p_lwps) #define FOREACH_LWP_IN_PROC(lp, p) \ @@ -461,8 +463,9 @@ void mi_switch (struct proc *p); void procinit (void); void relscurproc(struct proc *curp); int p_trespass (struct ucred *cr1, struct ucred *cr2); -void setrunnable (struct proc *); -void clrrunnable (struct proc *); +void setrunnable (struct lwp *); +void proc_stop (struct proc *, int); +void proc_unstop (struct proc *); void sleep_gdinit (struct globaldata *); int suser (struct thread *td); int suser_cred (struct ucred *cred, int flag); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index cd71a96847..03386a9a2e 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -37,7 +37,7 @@ * * @(#)systm.h 8.7 (Berkeley) 3/29/95 * $FreeBSD: src/sys/sys/systm.h,v 1.111.2.18 2002/12/17 18:04:02 sam Exp $ - * $DragonFly: src/sys/sys/systm.h,v 1.65 2007/01/15 20:51:16 dillon Exp $ + * $DragonFly: src/sys/sys/systm.h,v 1.66 2007/02/18 16:12:43 corecode Exp $ */ #ifndef _SYS_SYSTM_H_ @@ -331,7 +331,7 @@ extern watchdog_tickle_fn wdog_tickler; int tsleep (void *, int, const char *, int); int msleep (void *, struct spinlock *, int, const char *, int); void tsleep_interlock (void *chan); -void tstop (struct proc *); +void tstop (void); void wakeup (void *chan); void wakeup_one (void *chan); void wakeup_mycpu (void *chan); diff --git a/sys/vfs/procfs/procfs_ctl.c b/sys/vfs/procfs/procfs_ctl.c index e649aadc12..4cad697087 100644 --- a/sys/vfs/procfs/procfs_ctl.c +++ b/sys/vfs/procfs/procfs_ctl.c @@ -38,7 +38,7 @@ * * From: * $FreeBSD: src/sys/miscfs/procfs/procfs_ctl.c,v 1.20.2.2 2002/01/22 17:22:59 nectar Exp $ - * $DragonFly: src/sys/vfs/procfs/procfs_ctl.c,v 1.10 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/vfs/procfs/procfs_ctl.c,v 1.11 2007/02/18 16:12:43 corecode Exp $ */ #include @@ -268,11 +268,11 @@ procfs_control(struct proc *curp, struct proc *p, int op) /* * If the process is in a stopped state, make it runnable again. - * Do not set P_BREAKTSLEEP - that is, do not break a tsleep that + * Do not set LWP_BREAKTSLEEP - that is, do not break a tsleep that * might be in progress. */ if (p->p_stat == SSTOP) - setrunnable(p); + proc_unstop(p); return (0); } @@ -319,7 +319,7 @@ procfs_doctl(struct proc *curp, struct proc *p, struct pfsnode *pfs, * Make the process runnable but do not * break its tsleep. */ - setrunnable(p); + proc_unstop(p); } else { ksignal(p, nm->nm_val); } diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index f51a7bbfbe..3df2e04a14 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -32,7 +32,7 @@ * * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94 * $FreeBSD: src/sys/vm/vm_meter.c,v 1.34.2.7 2002/10/10 19:28:22 dillon Exp $ - * $DragonFly: src/sys/vm/vm_meter.c,v 1.12 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/sys/vm/vm_meter.c,v 1.13 2007/02/18 16:12:43 corecode Exp $ */ #include @@ -153,7 +153,7 @@ do_vmtotal_callback(struct proc *p, void *data) return(0); case LSSLEEP: if ((p->p_flag & P_SWAPPEDOUT) == 0) { - if ((p->p_flag & P_SINTR) == 0) + if ((lp->lwp_flag & LWP_SINTR) == 0) totalp->t_dw++; else if (lp->lwp_slptime < maxslp) totalp->t_sl++; diff --git a/usr.bin/w/proc_compare.c b/usr.bin/w/proc_compare.c index 2d0f090cb7..f8fb5de9d6 100644 --- a/usr.bin/w/proc_compare.c +++ b/usr.bin/w/proc_compare.c @@ -32,7 +32,7 @@ * * @(#)proc_compare.c 8.2 (Berkeley) 9/23/93 * - * $DragonFly: src/usr.bin/w/proc_compare.c,v 1.7 2007/02/16 23:11:40 corecode Exp $ + * $DragonFly: src/usr.bin/w/proc_compare.c,v 1.8 2007/02/18 16:12:43 corecode Exp $ */ #include @@ -51,7 +51,7 @@ * with the highest cpu utilization is picked (p_estcpu). Ties are * broken by picking the highest pid. * 3) The sleeper with the shortest sleep time is next. With ties, - * we pick out just "short-term" sleepers (P_SINTR == 0). + * we pick out just "short-term" sleepers (LWP_SINTR == 0). * 4) Further ties are broken by picking the highest pid. * * If you change this, be sure to consider making the change in the kernel @@ -111,9 +111,9 @@ proc_compare(struct kinfo_proc *p1, struct kinfo_proc *p2) /* * favor one sleeping in a non-interruptible sleep */ - if (p1->kp_flags & P_SINTR && (p2->kp_flags & P_SINTR) == 0) + if (p1->kp_lwp.kl_flags & LWP_SINTR && (p2->kp_lwp.kl_flags & LWP_SINTR) == 0) return (1); - if (p2->kp_flags & P_SINTR && (p1->kp_flags & P_SINTR) == 0) + if (p2->kp_lwp.kl_flags & LWP_SINTR && (p1->kp_lwp.kl_flags & LWP_SINTR) == 0) return (0); return (p2->kp_pid > p1->kp_pid); /* tie - return highest pid */ }