linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* BUG?  timer_create() with SIGEV_THREAD not working (at least on ppc64)
@ 2008-11-18 16:14 Chris Friesen
  2008-11-18 20:33 ` Chris Friesen
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Friesen @ 2008-11-18 16:14 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, tglx

The code below sets up a simple timer with SIGEV_THREAD.  I compiled the 
code as "g++ timertest.cc -o timertest -lrt -pthread".

Running it on my G5 with 2.6.27 (but with an older glibc), it prints:

Creating timer
Setting timer 268509264 for 5-second expiration...

and then the timer never expires.  I have an old Fedora Core 4 x86 
machine and there it works as expected.

Is there some hard requirement to upgrade glibc?  If not, then this 
looks like a bug somewhere.

Thanks,

Chris



int main(void)
{
     timer_t  timer_id;
     struct itimerspec    its;
     struct sigevent      se;

     // set timer signal event
     se.sigev_notify = SIGEV_THREAD;
     se.sigev_value.sival_ptr = &timer_id;
     se.sigev_notify_function = handler;
     se.sigev_notify_attributes = NULL;

     if ( timer_create(CLOCK_REALTIME, &se, &timer_id) < 0)
     {
         printf("create timer failed\n");
         fflush(0);
         return 0;
     }

     // set timer.
     its.it_value.tv_sec     = 1;
     its.it_value.tv_nsec    = 0;
     its.it_interval.tv_sec  = 1;
     its.it_interval.tv_nsec = 0;
     if ( timer_settime(timer_id, 0, &its, NULL) < 0)
     {
         printf("set timer failed\n");
         fflush(0);
         return 0;
     }

     printf("set timer OK\n");
     fflush(0);

     while(1)
     {  pause();}
     return 0;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: BUG? timer_create() with SIGEV_THREAD not working (at least on ppc64)
  2008-11-18 16:14 BUG? timer_create() with SIGEV_THREAD not working (at least on ppc64) Chris Friesen
@ 2008-11-18 20:33 ` Chris Friesen
  2008-11-18 23:06   ` Chris Friesen
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Friesen @ 2008-11-18 20:33 UTC (permalink / raw)
  To: Chris Friesen; +Cc: linuxppc-dev, linux-kernel, tglx

Chris Friesen wrote:
> The code below sets up a simple timer with SIGEV_THREAD.  I compiled the 
> code as "g++ timertest.cc -o timertest -lrt -pthread".
> 
> Running it on my G5 with 2.6.27 (but with an older glibc), it prints:
> 
> Creating timer
> Setting timer 268509264 for 5-second expiration...
> 
> and then the timer never expires.  I have an old Fedora Core 4 x86 
> machine and there it works as expected.
> 
> Is there some hard requirement to upgrade glibc?  If not, then this 
> looks like a bug somewhere.

I'm getting suspicious of either glibc or my version of strace, as it 
shows the child thread calling rt_sigtimedwait() with an empty signal set.

clone(Process 2663 attached
child_stack=0xf7ffe6c0, 
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED, 
parent_tidptr=0xf7ffeb68, tls=0xf8005f80, child_tidptr=0xf7ffeb68) = 2663
[pid  2662] futex(0xf5f11a4, FUTEX_WAKE, 2147483647) = 0
[pid  2662] timer_create(0, {0x10011050, 32, SIGEV_THREAD_ID, {2663}}, 
{(nil)}) = 0
[pid  2662] timer_settime(0, , {it_interval={1, 0}, it_value={1, 0}}, 
<unfinished ...>
[pid  2663] rt_sigprocmask(SIG_BLOCK, [RTMIN],  <unfinished ...>
[pid  2662] <... timer_settime resumed> NULL) = 0
[pid  2662] fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), 
...}) = 0
[pid  2663] <... rt_sigprocmask resumed> NULL, 8) = 0
[pid  2662] mmap(NULL, 4096, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
[pid  2663] rt_sigtimedwait([],  <unfinished ...>
[pid  2662] <... mmap resumed> )        = 0xf7ffa000
[pid  2662] write(1, "set timer OK\n", 13set timer OK


Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: BUG? timer_create() with SIGEV_THREAD not working (at least on ppc64)
  2008-11-18 20:33 ` Chris Friesen
@ 2008-11-18 23:06   ` Chris Friesen
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Friesen @ 2008-11-18 23:06 UTC (permalink / raw)
  To: Chris Friesen; +Cc: linuxppc-dev, linux-kernel, tglx

Chris Friesen wrote:

> I'm getting suspicious of either glibc or my version of strace, as it 
> shows the child thread calling rt_sigtimedwait() with an empty signal set.

Looks like glibc was the culprit.  It works fine with a newer version. 
Sorry for the false alarm.

Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-18 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-18 16:14 BUG? timer_create() with SIGEV_THREAD not working (at least on ppc64) Chris Friesen
2008-11-18 20:33 ` Chris Friesen
2008-11-18 23:06   ` Chris Friesen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).