Re: boot time, process start time, and NOW time

From: George Anzinger
Date: Tue Aug 17 2004 - 15:56:53 EST


James Courtier-Dutton wrote:
Albert Cahalan wrote:



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.


While on the subject of time, is it possible to get a monotonic timer with 1ms or better resolution?
We need this for linux multimedia applications, and it is used to sync audio and video. Currently we use gettimeofday(). If a movie is playing, and the user goes and changes the time, or changes the timezone, we do not want that to effect the movie playing. I have not been able to find a monotonic 1ms accurate timer in the linux kernel, that is available to applications, and has little overhead. Some efficient ioctl or function call for uptime to 1ms accuracy would do perfectly.

If all you want is the time try
clock_gettime(CLOCK_MONOTONIC, struct time_spec *tv)

Should work fine on 2.6.x kernels. This is good to what ever the fine structure is on the box, e.g. TCP cycles on most x86 or pm_timer cycles on some, in any case it is good to better than a micro second.

If you want a timer, look into the posix clocks & timers which were added at 2.6.
--
George Anzinger george@xxxxxxxxxx
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/