Solved

How to create multiple timers in a process

Posted on 1997-06-13
4
465 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 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks a lot.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now