Results 1 to 10 of 10
HI,,
i am using sigaction() to handle the SIGALRM generated by setitimer() .
how can i disable the SIGALRM and re-enable it ,assuming i have finished executing the handler and ...
- 07-13-2008 #1Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
SIGALARM disable
HI,,
i am using sigaction() to handle the SIGALRM generated by setitimer().
how can i disable the SIGALRM and re-enable it ,assuming i have finished executing the handler and during the running of setitimer() and before its timer expiration??
??
thanksLast edited by raedbenz; 07-13-2008 at 09:14 AM. Reason: typo
- 07-13-2008 #2There are two ways.how can i disable the SIGALRM and re-enable it
- Use sigaction() (or signal(), if you must) to ignore SIGALRM. See the man pages; use SIG_IGN as the signal handling function name.
Then use sigaction() or signal() to re-establish your function handler when you want to heed the signal again. - Faster code, and simpler:
Have a global which is normally set to zero. When you want to ignore SIGALRM, set the global to one. When you want to heed the signal again, set the global to zero.
Then your signal handler can check the global. If it's nonzero, just return without doing anything.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- Use sigaction() (or signal(), if you must) to ignore SIGALRM. See the man pages; use SIG_IGN as the signal handling function name.
- 07-13-2008 #3Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
thanks,
which one of the two methods the OS executes faster?
raed
- 07-13-2008 #4My guess is that it won't make much difference, unless your intervals are extremely short or you disable the signal extremely often.which one of the two methods the OS executes faster?
If your intervals are extremely short, it's likely that method 1 will work faster. If you disable the signals extremely often, it's likely that method 2 will work faster.
There are so many variables introduced by the rest of your program, and by the operating environment provided by the rest of the hardware, that it's especially important to test both ways yourself. Don't be surprised if you don't get a significant difference between the two.--
Bill
Old age and treachery will overcome youth and skill.
- 07-15-2008 #5Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
- 07-15-2008 #6
If you just want a way for it to work "most of the time", do this at the command line:
If man pages are not installed on your system, google this:Code:man 2 nice
and concentrate on search results which discuss the system call, not the shell command.Code:Linux man nice
You'll find that to bump the priority of your process, you'll need to be root.
On the other hand, if you want a guarantee of top priority execution, you'll need to use a real-time Linux kernel. For more information about real-time Linux, google this:
Code:real-time Linux
--
Bill
Old age and treachery will overcome youth and skill.
- 07-15-2008 #7Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
thanks again,,maybe with an example things are easier:
(I am intending not to use RT-Linux, the idea is to make my applications as real as possible without RT-Linux)
what i have done is using the setitimer() system call to generate a signal (SIGALRM) each 1sec and catch the signal by a handler that prints the "hello world".
what i want is give high priority for the function that prints "hello world" i.e printf(), or high priority for my setitimer(). does this system call do the job : sched_setscheduler()????
thanks
- 07-15-2008 #8Yes, unless you want that scheduling to be absolutely guaranteed; that is, unless your product will die a horrible death if the scheduling fails at rare intervals to work as you ask.what i want is give high priority for the function that prints "hello world" i.e printf(), or high priority for my setitimer(). does this system call do the job : sched_setscheduler()?
In that case, you need a realtime Linux kernel.--
Bill
Old age and treachery will overcome youth and skill.
- 07-15-2008 #9Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
- 07-15-2008 #10I mean the program, or set of programs, you're writing.What do you mean by "your product"?--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote
