Re: [PATCH] RTC: Add mmap method to rtc character driver

Edgar Toernig
2006-07-29T23:18:23Z

Keith Packard wrote:
>
> A jiffy counter is sufficient for the X server; all I need is some
> indication that time has passed with a resolution of 10 to 20 ms. I
> check this after each X request is processed as that is the scheduling
> granularity. An X request can range in time from .1us to 100 seconds, so
> I really want to just check after each request rather than attempt some
> heuristic.

That's exactly what the mmap interface of /dev/itimer does.
See: http://marc.theaimsgroup.com/?m=115412412427996

Example code:

volatile unsigned long *counter;
...
fd=open("/dev/itimer", O_RDWR);
write(fd, "20/1000\n", 8);
counter = mmap(0, sizeof(*counter), PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);

Now, "*counter" is incremented every 20 ms by the kernel.

Ciao, ET.