Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timers in linux

Status
Not open for further replies.

scienzia

Programmer
Feb 21, 2002
160
IT
Hi,

Working in linux, I need to put some timers in a program I am making.
Actually I would like the timers to be independent from one another (as I could do in VisualC++ applications), so I would like to know if there is a better solution than using SIGALRM based functions (alarm, setitimer,...).

Thanks in advance
 
Actually I would like to generate a sort of interrupt after a certain amount of time. The way SIGALRM works is fine for me, the problem is that I can set SIGALRM only for one timer.

To use the sleep I should run different threads with:

Code:
while(1)
{
      usleep(mytime);
      myfunc();
}

but I'm not so sure usleep is thread-safe, but I don't think soo.

Thanks


 
Thankyou.

I understood that sleep is thread-safe, but I don't get how.
Somewhere I read that sleep may be implemented using SIGALRM.
Can signals be delivered to a specific thread? Aren't signals sent to processes (which may have different threads)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top