index

kernel-time

Time

This section addresses the question of Time keeping inside X server.

previous situation:

X server uses its GetTimeInMillis() call (which keeps a monotonic time). The linux evdev events are marked w/ gettimeofday. I had to somehow find a common time.

solution:

In the end I found out, that linux kernel has a monotonic time (time since boot, note: I don't know how it interacts with "software suspend").

So, I made a patch for kernel to provide a new system call to get this monotonic time, and changed evdev to mark events w/ it as well.

history:

My first attempt was to use gettimeofday in GetTimeInMillis, but I decided that using gettimeofday for input events was just stupid: if somehow settimeofday is called, X would just see unreal duration of key presses. This is imho a bug in (the specifications of) evdev kernel driver.

code:

http://www.ruska.it/comp/x/kernel-monotonic-time.patch

how to call the new system call:

I have only this raw code:

GetTimeInMillis(void)
{
#ifdef MONOTONIC_TIME
   struct timeval  tp;
   syscall(289, &tv);
   return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
#else
....