When should I use sleep()
and a reconfiguration of SIG_ALRM
?
For example, I'm thinking of scheduling some task at some specific time. I could spawn a thread with an sleep()
call inside and when sleep()
returns, do some task, or I could specify a handler for SIG_ALRM and do the task inside the alarm interrupt. Do they take the same CPU usage and time? (besides the thread).
I've done some "tests" looking at the processes with ps
command, showing me a CPU % and a CPU TIME of 0, but I'm wondering if I'm missing something or I'm looking at the wrong data.
BTW, I'm using Linux.