Solved

How to create multiple timers in a process

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 140
zeroFront challenge 7 111
canBalance challenge 34 96
Problem to open Excel file 15 174
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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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