timer_create problem

207 views
Skip to first unread message

henry....@gmail.com

unread,
Feb 15, 2009, 10:13:53 PM2/15/09
to android-porting
hi,

i played with timer_create routine with the following code. it seems
the timer is working, but the cpu utilization is really high(over 90%)
if i run "top". Any idea what's going on on G1?

Thanks!

-----------------------------------------------------------------------------------------------------
se.sigev_notify = SIGEV_THREAD;
se.sigev_notify_function = timer_handler;
se.sigev_signo = SIGUSR1;
timer_create(CLOCK_REALTIME, &se, &tid);

memset(&ts, 0, sizeof(struct itimerspec));
ts.it_value.tv_sec = 0;
ts.it_value.tv_nsec = 30000000;
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 30000000;
result = timer_settime(tid, 0, &ts, 0);

David Turner

unread,
Feb 16, 2009, 4:27:19 AM2/16/09
to android...@googlegroups.com
this one's for me :-)

Can you send me a small compilable test program to reproduce this (it'd be much better for me since
I don't know what your timer_handler function is doing there).

It might be a bug in the SIGEV_THREAD timer implementation, I checked and tested it for correctness but didn't look at CPU usage, I admit.

By the way, sigev_signo isn't used with SIGEV_THREAD timers.

David Turner

unread,
Feb 16, 2009, 4:49:54 AM2/16/09
to android...@googlegroups.com
ok, I found the bug in the timer implementation, a fix is coming soon.

henry....@gmail.com

unread,
Feb 16, 2009, 2:48:26 PM2/16/09
to android-porting
That's great. I found similar problem for SIGEV_SIGNAL. Could you
please let me know when the fix is released?

Thanks!

On Feb 16, 1:49 am, David Turner <di...@android.com> wrote:
> ok, I found the bug in the timer implementation, a fix is coming soon.
>
> On Mon, Feb 16, 2009 at 10:27 AM, David Turner <di...@android.com> wrote:
> > this one's for me :-)
>
> > Can you send me a small compilable test program to reproduce this (it'd be
> > much better for me since
> > I don't know what your timer_handler function is doing there).
>
> > It might be a bug in the SIGEV_THREAD timer implementation, I checked and
> > tested it for correctness but didn't look at CPU usage, I admit.
>
> > By the way, sigev_signo isn't used with SIGEV_THREAD timers.
>

henry....@gmail.com

unread,
Feb 16, 2009, 2:57:03 PM2/16/09
to android-porting
That will be great if you could also mention the source code location
of the fix so that i could make sure i have the fix once you publish
it.

Thanks again!

On Feb 16, 1:49 am, David Turner <di...@android.com> wrote:
> ok, I found the bug in the timer implementation, a fix is coming soon.
>
> On Mon, Feb 16, 2009 at 10:27 AM, David Turner <di...@android.com> wrote:
> > this one's for me :-)
>
> > Can you send me a small compilable test program to reproduce this (it'd be
> > much better for me since
> > I don't know what your timer_handler function is doing there).
>
> > It might be a bug in the SIGEV_THREAD timer implementation, I checked and
> > tested it for correctness but didn't look at CPU usage, I admit.
>
> > By the way, sigev_signo isn't used with SIGEV_THREAD timers.
>

David Turner

unread,
Feb 17, 2009, 3:40:56 AM2/17/09
to android...@googlegroups.com
On Mon, Feb 16, 2009 at 8:48 PM, henry....@gmail.com <henry....@gmail.com> wrote:

That's great. I found similar problem for SIGEV_SIGNAL. Could you
please let me know when the fix is released?

I think I nailed that one too. All fixes are in bionic/libc/bionic/pthread-timers.c, essentially:

- in timer_settime() replace the call to __timer_gettime() to __timer_settime() with proper parameters (silly typo)
- in the worker thread implementation, a subtraction reversal when computing the timeout (should be "expires - now" instead of "now - expires")

 

David Turner

unread,
Feb 17, 2009, 3:41:25 AM2/17/09
to android...@googlegroups.com
They should be available in the next code drop to the open source repository, but I don't know when this will happen

Girish

unread,
Feb 17, 2009, 4:20:02 AM2/17/09
to android-porting
Hi David,

Can this bug be updated in both cupcake and open source ? Can you send
the quick fix for a solution temporarily . May be u can attach !

Regards
Girish

henry....@gmail.com

unread,
Feb 20, 2009, 2:43:18 PM2/20/09
to android-porting
Hi David:

It looks like it's still not in the main yet. Can you please do me a
favor to send the patch to me?

Thanks!

henry....@gmail.com

unread,
Mar 2, 2009, 7:36:09 PM3/2/09
to android-porting
Hi David:

It looks like the fix is still not in the main yet. I need to have the
fix ASAP. Is there anyway i could get it quicker?

Thanks a lot!

On Feb 20, 11:43 am, "henry.lon...@gmail.com" <henry.lon...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages