I’m looking for an open source timer library written in C. The library should have Timer callback functions, etc.
On searching I see POSIX timers or setitimer(), which use a signal based approach that may lead to problems in multithreaded code.
Say if I use POSIX Timers inside threaded code, the signals won’t be reaching to the correct place. If I use several timers in a process then each one should use different signals. Are there any other alternatives?
Since you are running Linux, I would recommend using the built in POSIX timer API’s.
Here is a link to some documentation showing how to use POSIX timers which provide support for callback functions.
Regarding multiple timers in a process, the documentation says this:
Note that POSIX timers can be used in a threaded application by setting up notification using SIGEV_THREAD_ID as shown below: