How do you create asynchronous timers in OS XC code?

So this question is really "Why is time.h not the same on OS X and Linux?" but I put up with these differences.

To create timers on a Unix system, I followed this tutorial http://www.helsinki.fi/atk/unix/dec_manuals/DOC_40D/APS33DTE/DOCU_007.HTM#timer-type-sec

which requires use <sys/time.h>and calling timer_create(), and then setting up a signal handler for the type of signal. This I know how to do it. The question is, how is this achieved on OS X?

The main thing to note is that these timers must be in real time, that is, in an asynchronous queue, and must use the field sa_sigactionfor struct sigaction, so that metadata associated with the timer signal can be passed to the signal handler. This is described in more detail here http://www.helsinki.fi/atk/unix/dec_manuals/DOC_40D/APS33DTE/DOCU_006.HTM#sigevent-sec .

+3
source share
1 answer

Have you looked setitimer()?

0
source

All Articles