Solved

How to create multiple timers in a process

Posted on 1997-06-13
4
486 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 288
countEvens challenge 2 97
sum28 challenge 31 111
EvenOdd challenge 10 105
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

806 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