From d9fa5f6777faa6314b477e1c22a9034e9bb4f722 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Sat, 8 Oct 2005 19:46:51 +0000 Subject: [PATCH] 1:1 Userland threading stage 2.4/4: Introduce p_start and use it. At the moment td_start is zero for all kernel threads (no change) and processes (changed). This field will be filled in a later commit again. --- bin/ps/print.c | 16 ++++++---------- bin/ps/ps.c | 4 ++-- sys/kern/init_main.c | 4 ++-- sys/kern/kern_acct.c | 6 +++--- sys/kern/kern_fork.c | 4 ++-- sys/sys/proc.h | 4 +--- sys/vfs/procfs/procfs_status.c | 6 +++--- sys/vm/vm_glue.c | 5 +---- 8 files changed, 20 insertions(+), 29 deletions(-) diff --git a/bin/ps/print.c b/bin/ps/print.c index def1961a9b..a93999dcad 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.22 2005/06/29 01:25:10 dillon Exp $ + * $DragonFly: src/bin/ps/print.c,v 1.23 2005/10/08 19:46:50 corecode Exp $ */ #include @@ -349,22 +349,18 @@ started(const KINFO *k, const struct varent *vent) if (use_ampm < 0) use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0'); - if (KI_THREAD(k)->td_proc != NULL) { - then = k->ki_u.u_start.tv_sec; - } else { - then = KI_THREAD(k)->td_start.tv_sec; - if (then < btime.tv_sec) { - then = btime.tv_sec; - } + then = k->ki_u.u_start.tv_sec; + if (then < btime.tv_sec) { + then = btime.tv_sec; } tp = localtime(&then); if (!now) time(&now); - if (now - k->ki_u.u_start.tv_sec < 24 * 3600) { + if (now - then < 24 * 3600) { strftime(buf, sizeof(buf) - 1, use_ampm ? "%l:%M%p" : "%k:%M ", tp); - } else if (now - k->ki_u.u_start.tv_sec < 7 * 86400) { + } else if (now - then < 7 * 86400) { strftime(buf, sizeof(buf) - 1, use_ampm ? "%a%I%p" : "%a%H ", tp); } else diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 5c25a297d7..790aa9ebbf 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1990, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)ps.c 8.4 (Berkeley) 4/2/94 * $FreeBSD: src/bin/ps/ps.c,v 1.30.2.6 2002/07/04 08:30:37 sobomax Exp $ - * $DragonFly: src/bin/ps/ps.c,v 1.16 2005/06/26 04:36:34 dillon Exp $ + * $DragonFly: src/bin/ps/ps.c,v 1.17 2005/10/08 19:46:50 corecode Exp $ */ #include @@ -552,7 +552,7 @@ saveuser(KINFO *ki) * If it's here fill in these fields, otherwise, just * leave them 0. */ - usp->u_start = KI_THREAD(ki)->td_start; + usp->u_start = KI_PROC(ki)->p_start; usp->u_ru = KI_EPROC(ki)->e_stats.p_ru; usp->u_cru = KI_EPROC(ki)->e_stats.p_cru; usp->u_valid = 1; diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index da5e30c0ca..9b0b402de3 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,7 +40,7 @@ * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/init_main.c,v 1.45 2005/06/25 20:03:28 dillon Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.46 2005/10/08 19:46:50 corecode Exp $ */ #include "opt_init_path.h" @@ -396,7 +396,7 @@ proc0_post(void *dummy __unused) * time from the file system. Pretend that proc0 started now. */ FOREACH_PROC_IN_SYSTEM(p) { - microtime(&p->p_thread->td_start); + microtime(&p->p_start); } /* diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 876cf3f5e9..ac46a2d4e6 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -38,7 +38,7 @@ * * @(#)kern_acct.c 8.1 (Berkeley) 6/14/93 * $FreeBSD: src/sys/kern/kern_acct.c,v 1.23.2.1 2002/07/24 18:33:55 johan Exp $ - * $DragonFly: src/sys/kern/kern_acct.c,v 1.18 2005/04/20 16:37:09 cpressey Exp $ + * $DragonFly: src/sys/kern/kern_acct.c,v 1.19 2005/10/08 19:46:50 corecode Exp $ */ #include @@ -217,9 +217,9 @@ acct_process(struct proc *p) acct.ac_stime = encode_comp_t(st.tv_sec, st.tv_usec); /* (3) The elapsed time the commmand ran (and its starting time) */ - acct.ac_btime = p->p_thread->td_start.tv_sec; + acct.ac_btime = p->p_start.tv_sec; microtime(&tmp); - timevalsub(&tmp, &p->p_thread->td_start); + timevalsub(&tmp, &p->p_start); acct.ac_etime = encode_comp_t(tmp.tv_sec, tmp.tv_usec); /* (4) The average amount of memory used */ diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index fd71e530d2..6309d4b952 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -37,7 +37,7 @@ * * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 * $FreeBSD: src/sys/kern/kern_fork.c,v 1.72.2.14 2003/06/26 04:15:10 silby Exp $ - * $DragonFly: src/sys/kern/kern_fork.c,v 1.39 2005/10/06 20:01:29 corecode Exp $ + * $DragonFly: src/sys/kern/kern_fork.c,v 1.40 2005/10/08 19:46:50 corecode Exp $ */ #include "opt_ktrace.h" @@ -570,7 +570,7 @@ again: * Set the start time. Note that the process is not runnable. The * caller is responsible for making it runnable. */ - microtime(&p2->p_thread->td_start); + microtime(&p2->p_start); p2->p_acflag = AFORK; /* diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 9dd058c490..0c486c4c89 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.65 2005/10/08 14:31:26 corecode Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.66 2005/10/08 19:46:51 corecode Exp $ */ #ifndef _SYS_PROC_H_ @@ -252,9 +252,7 @@ struct proc { u_long p_code; /* for core dump/debugger XXX */ struct klist p_klist; /* knotes attached to this process */ -#ifdef notyet struct timeval p_start; /* start time for a process */ -#endif /* End area that is zeroed on creation. */ #define p_endzero p_startcopy diff --git a/sys/vfs/procfs/procfs_status.c b/sys/vfs/procfs/procfs_status.c index 1b49fe2348..163819dce6 100644 --- a/sys/vfs/procfs/procfs_status.c +++ b/sys/vfs/procfs/procfs_status.c @@ -38,7 +38,7 @@ * * From: * $FreeBSD: src/sys/miscfs/procfs/procfs_status.c,v 1.20.2.4 2002/01/22 17:22:59 nectar Exp $ - * $DragonFly: src/sys/vfs/procfs/procfs_status.c,v 1.9 2005/01/29 08:34:00 dillon Exp $ + * $DragonFly: src/sys/vfs/procfs/procfs_status.c,v 1.10 2005/10/08 19:46:51 corecode Exp $ */ #include @@ -125,8 +125,8 @@ procfs_dostatus(struct proc *curp, struct proc *p, struct pfsnode *pfs, calcru(p, &ut, &st, (struct timeval *) NULL); ps += snprintf(ps, psbuf + sizeof(psbuf) - ps, " %ld,%ld %ld,%ld %ld,%ld", - p->p_thread ? p->p_thread->td_start.tv_sec : 0, - p->p_thread ? p->p_thread->td_start.tv_usec : 0, + p->p_start.tv_sec, + p->p_start.tv_usec, ut.tv_sec, ut.tv_usec, st.tv_sec, st.tv_usec); } else diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index a98f615255..a389c8715e 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -60,7 +60,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_glue.c,v 1.94.2.4 2003/01/13 22:51:17 dillon Exp $ - * $DragonFly: src/sys/vm/vm_glue.c,v 1.33 2005/10/08 12:24:26 corecode Exp $ + * $DragonFly: src/sys/vm/vm_glue.c,v 1.34 2005/10/08 19:46:51 corecode Exp $ */ #include "opt_vm.h" @@ -257,9 +257,6 @@ vm_fork(struct proc *p1, struct proc *p2, int flags) } bzero(&up->u_stats, sizeof(struct pstats)); - bcopy(&p1->p_thread->td_start, &p2->p_thread->td_start, - sizeof(struct timeval)); - /* * cpu_fork will copy and update the pcb, set up the kernel stack, -- 2.39.1