|
Home > Archive > Unix Programming > January 2005 > threads and select as timer
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
threads and select as timer
|
|
| Wim Lauwers 2005-01-19, 2:48 am |
| Hello all,
One of our applications deploys two threads using an empty select as a
timer. On Tru64 this works well, but on Solaris 9 one of the threads
gave twice as much timerticks as expected. The truss output showed that
the internal poll issued by select was called with only half the
timervalue as given to select!
After some searching it appeared that this second thread was accidently
started twice from the mainthread, so the solution was obvious. Still
this puzzles me: select is described in the Solaris manpage as
"MT-safe", so this shouldn't happen. Timervalues were passed straight to
select without any interference possible. Is this a bad thread-signal
mix playing up?
What is the most recommended timer system by the way? Preferably
available on most Unix platforms.
Thanks,
Wim
| |
|
| Wim Lauwers wrote:
> Hello all,
>
> One of our applications deploys two threads using an empty select as a
> timer. On Tru64 this works well, but on Solaris 9 one of the threads
> gave twice as much timerticks as expected. The truss output showed that
> the internal poll issued by select was called with only half the
> timervalue as given to select!
>
> After some searching it appeared that this second thread was accidently
> started twice from the mainthread, so the solution was obvious. Still
> this puzzles me: select is described in the Solaris manpage as
> "MT-safe", so this shouldn't happen. Timervalues were passed straight to
> select without any interference possible. Is this a bad thread-signal
> mix playing up?
>
> What is the most recommended timer system by the way? Preferably
> available on most Unix platforms.
>
> Thanks,
> Wim
Gut feeling: HZ=50 vs HZ=100; combined with older versions of (shared?)
libraries.
HTH,
AvK
| |
| David Schwartz 2005-01-19, 5:53 pm |
|
"Wim Lauwers" <wim.lauwers@alcatel.be> wrote in message
news:csktnf$vb6$1@news.alcatel.fr...
> One of our applications deploys two threads using an empty select as a
> timer. On Tru64 this works well, but on Solaris 9 one of the threads gave
> twice as much timerticks as expected. The truss output showed that the
> internal poll issued by select was called with only half the timervalue as
> given to select!
You can't use 'select' this way. It's defined as permitted to return any
time before or after the timeout expires.
> After some searching it appeared that this second thread was accidently
> started twice from the mainthread, so the solution was obvious. Still this
> puzzles me: select is described in the Solaris manpage as "MT-safe", so
> this shouldn't happen. Timervalues were passed straight to select without
> any interference possible. Is this a bad thread-signal mix playing up?
An MT-safe function doesn't mean it will work in code that's not
MT-safe! If you had two threads accessing the same timer structure without
locks, don't blame 'select' for the bad results.
> What is the most recommended timer system by the way? Preferably available
> on most Unix platforms.
Code your own that has the exact features you want.
DS
|
|
|
|
|