Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to create multiple timers in a process

Posted on 1997-06-13
4
Medium Priority
?
527 Views
Last Modified: 2013-12-26
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
Comment
Question by:rinkoo
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
dhm earned 150 total points
ID: 1293428
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
 

Author Comment

by:rinkoo
ID: 1293429
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
 
LVL 3

Expert Comment

by:dhm
ID: 1293430
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
 

Author Comment

by:rinkoo
ID: 1293431
Thanks a lot.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question