What are the other timer APIs in Linux apart from POSIX timers?
I want to design a timer in Linux, but due to some system constraints and design requirements i cannot use the POSIX timer APIs.
Can somebody kindly let me know, what 开发者_如何学运维are the other timer design mechanisms available in Linux apart from the POSIX timers? (timer_create, timer_settime etc to avoid)
Thanks in advance.
EDIT: P.S: Any mechanism you provide, requesting you to kindly give me some useful links or example links
NOTE: We can't use any third party library (Like ACE library) as our code is a proprietory code.
Check out my answer. One of the timers I find useful is timerfd_create() API provided in Linux system call. This blends well when your application is structured on an event loop.
If you are looking for 3rd party, there is an ACE library that can be downloaded for free. They have timers, queues, threads etc
The simplest and most portable way is probably just to use pthread_create
and clock_nanosleep
to implement your own timer. It shouldn't take more than about 50 lines of code for something simple, and maybe 100-150 for a fully general API with overrun counts, etc.
精彩评论