0

I created a program containing the single signal hander to handle multiple timer. This timer is used to call the specific task for every 2ms, 10ms and so on. But it is not working. Could anyone help me in this :(

http://www.graphics-muse.org/wp/?p=868 how to solve this multiple linux timer with single signal handler

Community
  • 1
  • 1

1 Answers1

0

You could implement the following:

  1. Setup your signal handler with sigaction, ensuring the handler's signature is void handler(int, siginfo_t*, void*).

  2. Create a number of timers with timer_create, each specifying a different sigevent structure (in particular the sigev_value).

  3. In the signal handler, process the siginfo_t structure and use either of the following fields to determine which timer expired si_int, si_ptr (one of these will correspond to the sigev_value in step 2) or use si_timerid. Of course, if you use the si_timerid field, there's no need to define sigev_value in step 2.

That way, the signal handler can identify which timer triggered the signal and can appropriate action.

isedev
  • 18,848
  • 3
  • 60
  • 59