From: Albert Cahalan <albert@users.sf.net>
To: george@mvista.com
Cc: Tim Schmielau <tim@physik3.uni-rostock.de>,
Andrew Morton OSDL <akpm@osdl.org>,
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
albert@users.sourceforge.net, lkml <linux-kernel@vger.kernel.org>,
voland@dmz.com.pl, nicolas.george@ens.fr,
kaukasoi@elektroni.ee.tut.fi, johnstul@us.ibm.com,
david+powerix@blue-labs.org
Subject: Re: boot time, process start time, and NOW time
Date: 16 Aug 2004 18:32:25 -0400 [thread overview]
Message-ID: <1092695544.2301.1227.camel@cube> (raw)
In-Reply-To: <412151CA.4060902@mvista.com>
On Mon, 2004-08-16 at 20:31, George Anzinger wrote:
> Hm... That patch was for a reason... It seems to me that doing anything short
> of putting "xtime" (or better, clock_gettime() :)) in at fork time is not going
> to fix anything. As written the start_time in the task_struct is fixed. If
> "now - uptime + time_from_boot_to_process_start" it is wandering, it must be the
> fault of "now - uptime". Since this seems to be wandering, and we corrected
> uptime in the referenced patch, is it safe to assume that "now" is actually
> being computed from "jiffies" rather than a gettimeofday()?
>
> Seems like that is where we should be changing things.
That's userspace, which works fine on a 2.4.xx kernel.
If userspace were to change, it wouldn't work OK for
a 2.4.xx kernel anymore. So consider that cast in stone.
"now" is the time() function. Using gettimeofday()
would only make sense if I decided to pay the cost
of asking for the time every time I look at a task.
Here is the "now - uptime + time_from_boot_to_process_start"
calculation, unsimplified, ripped from the procps code:
////////////////////////////////////////////////////////////////
unsigned long seconds_since_boot = -1;
static unsigned long seconds_since_1970;
static unsigned long time_of_boot;
some_init_function(){
seconds_since_boot = uptime(0,0);
seconds_since_1970 = time(NULL);
time_of_boot = seconds_since_1970 - seconds_since_boot;
}
static int pr_stime(char *restrict const outbuf, const proc_t *restrict const pp){
struct tm *proc_time;
struct tm *our_time;
time_t t;
const char *fmt;
int tm_year;
int tm_yday;
our_time = localtime(&seconds_since_1970); /* not reentrant */
tm_year = our_time->tm_year;
tm_yday = our_time->tm_yday;
t = time_of_boot + pp->start_time / Hertz;
proc_time = localtime(&t); /* not reentrant, this corrupts our_time */
fmt = "%H:%M"; /* 03:02 23:59 */
if(tm_yday != proc_time->tm_yday) fmt = "%b%d"; /* Jun06 Aug27 */
if(tm_year != proc_time->tm_year) fmt = "%Y"; /* 1991 2001 */
return strftime(outbuf, 42, fmt, proc_time);
}
////////////////////////////////////////////////////////////////
next prev parent reply other threads:[~2004-08-17 1:05 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-22 23:57 boot time, process start time, and NOW time Albert Cahalan
2004-06-28 17:56 ` OGAWA Hirofumi
2004-08-16 19:41 ` Andrew Morton
2004-08-16 21:49 ` john stultz
2004-08-16 23:08 ` Tim Schmielau
2004-08-16 23:56 ` Tim Schmielau
2004-08-17 0:21 ` john stultz
2004-08-17 0:37 ` George Anzinger
2004-08-17 0:49 ` john stultz
2004-08-17 0:31 ` George Anzinger
2004-08-16 22:32 ` Albert Cahalan [this message]
2004-08-17 1:26 ` George Anzinger
2004-08-16 23:08 ` Albert Cahalan
2004-08-17 1:54 ` James Courtier-Dutton
2004-08-17 2:03 ` Lee Revell
2004-08-17 20:52 ` George Anzinger
2004-08-17 6:56 ` Tim Schmielau
2004-08-17 20:07 ` john stultz
2004-08-17 20:13 ` [RFC] New timeofday implementation proposal john stultz
2004-08-17 20:58 ` [RFC] New timeofday code john stultz
2004-09-01 23:16 ` [RFC] New timeofday implementation proposal Christoph Lameter
2004-08-16 23:24 ` boot time, process start time, and NOW time Albert Cahalan
2004-08-17 19:00 ` john stultz
2004-08-17 17:41 ` Albert Cahalan
2004-08-17 20:58 ` john stultz
2004-08-17 20:25 ` [PATCH] " Tim Schmielau
2004-08-17 22:24 ` George Anzinger
2004-08-17 22:37 ` john stultz
2004-08-17 23:07 ` Tim Schmielau
2004-08-18 0:11 ` john stultz
2004-08-17 22:19 ` Albert Cahalan
2004-08-18 1:09 ` john stultz
2004-08-17 22:45 ` Albert Cahalan
2004-08-18 7:42 ` Tim Schmielau
2004-08-19 19:15 ` Petri Kaukasoina
2004-08-26 11:04 ` Andrew Morton
2004-08-26 12:07 ` Tim Schmielau
2004-08-30 23:00 ` Tim Schmielau
2004-08-30 23:38 ` john stultz
2004-08-31 0:37 ` Albert Cahalan
2004-08-31 0:49 ` Tim Schmielau
2004-08-31 0:45 ` Tim Schmielau
2004-08-31 1:23 ` john stultz
2004-08-31 1:34 ` john stultz
2004-08-31 6:07 ` Tim Schmielau
2004-08-31 19:27 ` George Anzinger
2004-08-31 20:56 ` john stultz
2004-08-31 21:10 ` David Ford
2004-09-02 20:39 ` George Anzinger
2004-09-01 19:14 ` OGAWA Hirofumi
2004-09-02 20:58 ` George Anzinger
2004-09-02 21:38 ` OGAWA Hirofumi
2004-09-03 0:59 ` George Anzinger
2004-09-03 3:35 ` OGAWA Hirofumi
2004-09-03 7:31 ` George Anzinger
2004-09-03 7:51 ` Tim Schmielau
2004-09-03 7:15 ` Tim Schmielau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1092695544.2301.1227.camel@cube \
--to=albert@users.sf.net \
--cc=akpm@osdl.org \
--cc=albert@users.sourceforge.net \
--cc=david+powerix@blue-labs.org \
--cc=george@mvista.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=johnstul@us.ibm.com \
--cc=kaukasoi@elektroni.ee.tut.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.george@ens.fr \
--cc=tim@physik3.uni-rostock.de \
--cc=voland@dmz.com.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox