POSIX 1003.1b timer patches for Linux

This is a patch to add POSIX 1003.1b (aka POSIX.4) clocks and timers to Linux. And some stuff for sysconf(3) in older patches (no longer maintained).

The code is derived from a patch from the university of Kansas. However it has been so much modified that hardly any of their code (except some of the structure) is left.

The patch includes modifications for all architectures for the system call numbers and some other stuff. The core facilities are architecture independent.

The original patch consisted of two related modifications:

The enhancements for the non RT signals have been added to the kernel, making that part of my patch obsolete.

POSIX timer patch

This patch adds the following system calls to the kernel:

There is no way to emulate these calls in user space, for instance by using setitimer(). Firstly POSIX timers can fire any signal (RT and non RT), whereas setitimer can only send SIGALRM. Secondly the setitimer() does not count overruns. Thirdly, you can have multiple POSIX timers in one process, whereas you can only have one setitimer.

Adding support for other timers becomes easier. Just add a driver for the timer and add some glue code to the timer_* functions in the kernel. (An APIC based timer for example.

POSIX clock patch

Clocks are now handled in user space. Only two parameters needed for clock_getres() are read using sysctl(2).

CLOCK_REALTIME is the standard POSIX clock. I have added CLOCK_LINUX_COUNTER, which uses the hardware counter of the processor or system. This counter is entirely handled from user space and requires no system calls. Except the first time when it needs to know the frequency of the counter or has to set up things.

I have only implemented the counter for Intel Pentium processors with TSC. Other platforms require other implementations, which can be implemented later.

sysctl additions

Additions to sysctl make it possible to implement all clock_*() functions in user space. Further additions enable sysconf(3) to read the kernel parameter values it needs.

These additions are currently not available for recent versions of the development kernel. You can download an old patch containing (among other things) the sysctl additions.

System call and test code

I have written code to perform the new system calls and some test code which exercises all functionality and tests all possible inputs (good and bad).


Linux 2.4.0-test4 version

Linux 2.4.0-test5 version

Linux 2.4.0-test6 version

Linux 2.4.0-test7 version

Linux 2.4.0-test8 version

Linux 2.4.0-test9 version

Linux 2.4.0-test10 version

Linux 2.4.0-test12 version

Linux 2.4.0 version

Linux 2.4.1 version

Linux 2.4.2 version

Linux 2.4.3 version

Linux 2.4.4 version

Linux 2.4.5 version

Linux 2.4.6 version

Linux 2.4.8 version

POSIX timer patches

POSIX timer patch for Linux 2.2.14-5.0 (redhat 6.2) (updated 28-7-2000 to remove duplicate delta)

POSIX timer patch for Linux 2.4.0-test3

POSIX timer patch for Linux 2.4.0-test4

POSIX timer patch for Linux 2.4.0-test5

POSIX timer patch for Linux 2.4.0-test6

POSIX timer patch for Linux 2.4.0-test7

POSIX timer patch for Linux 2.4.0-test8

POSIX timer patch for Linux 2.4.0-test9

POSIX timer patch for Linux 2.4.0-test10

POSIX timer patch for Linux 2.4.0-test12

POSIX timer patch for Linux 2.4.0

POSIX timer patch for Linux 2.4.1

POSIX timer patch for Linux 2.4.2

POSIX timer patch for Linux 2.4.3

POSIX timer patch for Linux 2.4.4

POSIX timer patch for Linux 2.4.5

POSIX timer patch for Linux 2.4.6

POSIX timer patch for Linux 2.4.8 (latest)

Test and system call code

This test code is maintained only for the latest version (i.e. for the latest development kernel). That means that the code may need some tweaking to get it to work for older patches.

Test code and system call code for Redhat 6.2 (updated September 10, 2000)

Test code and system call code for Redhat 7.0 or 7.1 (updated October 15, 2000)

Old Stuff

Older patches I have put in this directory. Beware! This stuff contains bugs I have fixed in later versions. In fact I can guarantee them for some patches. The only reason I have put them here is that some people may be interested in some of those to use as a starting point.


The High Res POSIX timers project at Source Forge

APIC based timer

High-resolution timers

Last update: January 25, 2005