Reputation: 965
Is it possible (preferably in an OS-independent fashion, although I happen to be using Windows) to request a timer interrupt in a userspace program?
Here is some pseudo-code which may illustrate what kind of functionality I'm looking for:
#include <time_library_x.h> //For setHandler() and set_timer_for_ms()
void timerInterruptHandler() {
update_something();
set_timer_for_ms(50);
}
void main() {
setHandler(timerInterruptHandler);
set_timer_for_ms(50);
while(1) {
very_boring_data_collection();
}
}
Anyone know what "library x" is?
Upvotes: 3
Views: 1081
Reputation: 151
In Windows, there is Timers object to create Timer object and register callback function.
In Linux using SIGALRM and setitimer is common to implement timer things, but I have not seen such libraries which integrates those for mult-platform use.
Windows Timers Example : https://msdn.microsoft.com/en-us/library/windows/desktop/ms644901(v=vs.85).aspx
Upvotes: 2