public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* boot time, process start time, and NOW time
@ 2004-06-22 23:57 Albert Cahalan
  2004-06-28 17:56 ` OGAWA Hirofumi
  0 siblings, 1 reply; 57+ messages in thread
From: Albert Cahalan @ 2004-06-22 23:57 UTC (permalink / raw)
  To: linux-kernel mailing list
  Cc: voland, nicolas.george, kaukasoi, tim, george, johnstul,
	david+powerix, Andrew Morton OSDL

Even with the 2.6.7 kernel, I'm still getting reports of process
start times wandering. Here is an example:

   "About 12 hours since reboot to 2.6.7 there was already a
   difference of about 7 seconds between the real start time
   and the start time reported by ps. Now, 24 hours since reboot
   the difference is 10 seconds."

The calculation used is:

   now - uptime + time_from_boot_to_process_start

The code shown below works great on a 2.4.xx or earlier kernel.
It generally relys on USER_HZ, which is supposedly in our ABI.

I have a feeling we'll forever be chasing bugs related to not
using a PLL to drive the clock tick at exactly HZ ticks per second.
Perhaps the DragonflyBSD code could be stolen. Anyway, the code:

///////////////////////////////////////////////////////////////////////////
unsigned long seconds_since_1970 = time(NULL);
unsigned long seconds_since_boot = uptime(0,0);
unsigned long time_of_boot       = seconds_since_1970 - seconds_since_boot;

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);
}
///////////////////////////////////////////////////////////////////////////





^ permalink raw reply	[flat|nested] 57+ messages in thread

end of thread, other threads:[~2004-09-03  7:55 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox