Implementing POSIX timers
Posted: Thu Jan 24, 2013 9:02 am
Apparently, part of the POSIX signal interface is timer signals. One might suspect that these would be used for instance by the TCP/IP stack in order to avoid explicit "push" operations. There are other possible uses. POSIX defines these timers with a very high precision, but it is not clear what precision / resolution is required.
But how would these be implemented? In the DOS/BIOS environment, timers where typically using int 8 / 0x1c, and applications would hook these. However, POSIX is in user-space, and I don't think it is a good idea to provide hooks for hardware IRQs in kernel that call user-space. Neither would I allow kernel timers to do callbacks into user-space.
One possible solution would be to start an additional thread at process-creation time that would be responsible for implementing user-space timers, and possibly some other signal-functions as well. The thread would use the existing wait-functions, which are pretty accurate.
How do others implement this?
But how would these be implemented? In the DOS/BIOS environment, timers where typically using int 8 / 0x1c, and applications would hook these. However, POSIX is in user-space, and I don't think it is a good idea to provide hooks for hardware IRQs in kernel that call user-space. Neither would I allow kernel timers to do callbacks into user-space.
One possible solution would be to start an additional thread at process-creation time that would be responsible for implementing user-space timers, and possibly some other signal-functions as well. The thread would use the existing wait-functions, which are pretty accurate.
How do others implement this?