http://groups.google.com/group/comp.programming.threads?hl=en
comp.programming.threads@googlegroups.com
Today's topics:
* How to implement thread specific timer in a multi-threaded program - 4
messages, 4 authors
http://groups.google.com/group/comp.programming.threads/t/322963722476d567?hl=en
==============================================================================
TOPIC: How to implement thread specific timer in a multi-threaded program
http://groups.google.com/group/comp.programming.threads/t/322963722476d567?hl=en
==============================================================================
== 1 of 4 ==
Date: Tues, Sep 29 2009 6:00 am
From: Mukul Srivastava
On Sep 28, 3:03 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> David Schwartz <dav...@webmaster.com> writes:
> > On Sep 27, 6:09 am, Deepak <dpkshe...@gmail.com> wrote:
> >> Hi,
> >> Can someone provide some pointers on how to implement thread
> >> specific timer in a multi-threaded program.
> >> This is on Linux using pthreads. Any pointers would be appreciated.
>
> > My advice to you would be not to do that. Associate the timer with
> > what the thread is doing, not with the thread.
>
> Yes, instead of having thread-specific timers, have any number of
> generic timers.
>
> cf. the POSIX.1-2001 functions setitimer(2) and getitimer(2),
> or the POSIX.1-2008 functions timer_settime(2) and timer_gettime(2.
>
> --
> __Pascal Bourguignon__
You can store these values in thread specific variable and use it .
== 2 of 4 ==
Date: Wed, Sep 30 2009 3:16 am
From: Deepak
On Sep 27, 7:59 pm, David Schwartz <dav...@webmaster.com> wrote:
> On Sep 27, 6:09 am, Deepak <dpkshe...@gmail.com> wrote:
>
> > Hi,
> > Can someone provide some pointers on how to implement thread
> > specific timer in a multi-threaded program.
> > This is on Linux using pthreads. Any pointers would be appreciated.
>
> My advice to you would be not to do that. Associate the timer with
> what the thread is doing, not with the thread.
>
> DS
I didnt quite understand what you meant by "what the thread is doing"
Vs with the thread. Can you pls elaborate.
== 3 of 4 ==
Date: Wed, Sep 30 2009 7:55 am
From: David Schwartz
On Sep 30, 3:16 am, Deepak <dpkshe...@gmail.com> wrote:
> I didnt quite understand what you meant by "what the thread is doing"
> Vs with the thread. Can you pls elaborate.
Okay, let's start with a simple question -- why would anyone want a
thread-specific timer? What possible function could it serve? Whatever
it is that you want to impose a timeout on, why associate the timer
with a thread?
It makes no sense to say "whatever this thread happens to be doing, I
want it to timeout in X time".
It does make sense to say "I need X to happen in Y time, unless Z",
but what does that have to do with any particular thread?
DS
== 4 of 4 ==
Date: Wed, Sep 30 2009 8:21 am
From: Chris Friesen
On 09/30/2009 08:55 AM, David Schwartz wrote:
> Okay, let's start with a simple question -- why would anyone want a
> thread-specific timer? What possible function could it serve? Whatever
> it is that you want to impose a timeout on, why associate the timer
> with a thread?
>
> It makes no sense to say "whatever this thread happens to be doing, I
> want it to timeout in X time".
I agree with you that most of the time it wouldn't make sense.
This is a bit of a corner case, but it's possible to set up posix timers
to use various clock sources. If you set the timer to use a per-thread
cpu-time clock, then this allows you to trigger a timer to fire in X
amount of runtime.
This can be useful if what you care about is runtime rather than actual
wall clock time.
Chris
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.programming.threads"
group.
To post to this group, visit http://groups.google.com/group/comp.programming.threads?hl=en
To unsubscribe from this group, send email to comp.programming.threads+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.programming.threads/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
No comments:
Post a Comment