The design approach (and APIs used) to set up and use a modern POSIX timer follows; the sequence is typically in the order shown here:
- Signal(s) setup.
- Assuming the notification mechanism being used is a signal, first trap the signal(s) via sigaction(2).
- Create and initialize the timer(s).
- Decide on the clock type (or source) to use to measure the elapsed time.
- Decide on the timer-expiry event-notification mechanism to be used by your application—typically, whether to use (the usual) signals or a (newly spawned) thread.
- The aforementioned decisions are implemented via the timer_create(2) system call; thereby it allows one to create a timer, and, of course, we can create multiple timers by invoking it multiple ...