Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 533
  • Last Modified:

How to create multiple timers in a process

I have a multithreaded application. In each thread, I have
to craete a timer. I've gone through setitimer stuff but it
allows only one timer per process.

Any work arounds??
0
rinkoo
Asked:
rinkoo
  • 2
  • 2
1 Solution
 
dhmCommented:
I just went through the man pages about setitimer & alarm on Solaris-2.5.1; it looks like this is currently messy, but may get better when the world becomes POSIX.  (POSIX apparently specifies the semantics you've described: one timer per process.  Maybe your OS is POSIX already?)

Anyway, what I'd do is set up a timekeeper thread...other threads that want to be notified at a certain time would submit a request to the timekeeper; the timekeeper would keep a list of these requests and use the single itimer/alarm clock to wake itself up at the earliest request time.  It'd dispatch the signal to the reqesting thread, pop the request, and then go back to sleep until the next requested wakeup.
0
 
rinkooAuthor Commented:
Hi dhm,

I've heard of POSIX.lb library and POSIX timers. Is there any
such library that can save the effort required??

regards
0
 
dhmCommented:
I doubt it...I don't follow POSIX at all, but the Solaris manual pages make it sound like POSIX is going to have only one timer per process.  Someone may have written the timekeeper I described and released it into the public domain, but I don't know of any code for sure.  Sorry.
0
 
rinkooAuthor Commented:
Thanks a lot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now