Project

General

Profile

Actions

Bug #262

closed

Threadding issue

Added by elekktretterr over 17 years ago. Updated over 17 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html

Can someone please fix it? Its really bugging me, and Im not the only
one to have that issue. Some people say growisofs does the same.

Thank you,

Petr

Actions #1

Updated by qhwt+dfly about 18 years ago

On Thu, Jul 27, 2006 at 02:42:29PM +1000, Petr Janda wrote:

http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html

Can someone please fix it? Its really bugging me, and Im not the only
one to have that issue. Some people say growisofs does the same.

IIUC, libc_r's thread scheduler may call sys_set_tls_area() at most twice
per call, so if the application tries to switch between threads very
frequently, it can call sys_set_tls_area() very often. There are many
places in libc_r's code where the thread scheduler is called, but the
easiest way to make it happen is calling sched_yield().
For example, src/engine.c in gxine has the following code:

static gboolean js_queue_cb (GtkWidget *widget, GdkEventClient *event,
gpointer data) {
exec_t *js;
while ((js = g_async_queue_try_pop (js_queue))) {
/* spin; play_exec gets this & the GDK lock in reverse order /
while (pthread_mutex_trylock (&widgets_update_lock))
sched_yield ();
pthread_mutex_unlock (&widgets_update_lock); /
JS 'play()' needs it */
engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
free (js->cmd);
free (js->src);
free (js);
}
return TRUE;
}

I wonder what happens if you use libthread_xu instead of libc_r
(not sure if it's easy to replace the use of pthead library).

Actions #2

Updated by elekktretterr about 18 years ago

1) I can bzip the whole ktrace dump and put it on my webserver, will
that help you?
2) How do i switch to libthread_xu?

Petr

YONETANI Tomokazu wrote:

On Thu, Jul 27, 2006 at 02:42:29PM +1000, Petr Janda wrote:

http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html

Can someone please fix it? Its really bugging me, and Im not the only
one to have that issue. Some people say growisofs does the same.

IIUC, libc_r's thread scheduler may call sys_set_tls_area() at most twice
per call, so if the application tries to switch between threads very
frequently, it can call sys_set_tls_area() very often. There are many
places in libc_r's code where the thread scheduler is called, but the
easiest way to make it happen is calling sched_yield().
For example, src/engine.c in gxine has the following code:

static gboolean js_queue_cb (GtkWidget *widget, GdkEventClient *event,
gpointer data) {
exec_t *js;
while ((js = g_async_queue_try_pop (js_queue))) {
/* spin; play_exec gets this & the GDK lock in reverse order /
while (pthread_mutex_trylock (&widgets_update_lock))
sched_yield ();
pthread_mutex_unlock (&widgets_update_lock); /
JS 'play()' needs it */
engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
free (js->cmd);
free (js->src);
free (js);
}
return TRUE;
}

I wonder what happens if you use libthread_xu instead of libc_r
(not sure if it's easy to replace the use of pthead library).

Actions #3

Updated by joerg about 18 years ago

On Thu, Jul 27, 2006 at 08:52:25PM +0900, YONETANI Tomokazu wrote:

static gboolean js_queue_cb (GtkWidget *widget, GdkEventClient *event,
gpointer data) {
exec_t *js;
while ((js = g_async_queue_try_pop (js_queue))) {
/* spin; play_exec gets this & the GDK lock in reverse order /
while (pthread_mutex_trylock (&widgets_update_lock))
sched_yield ();
pthread_mutex_unlock (&widgets_update_lock); /
JS 'play()' needs it */
engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
free (js->cmd);
free (js->src);
free (js);
}
return TRUE;
}

ARGH! IDIOTS! Ok, thanks Yonetani, I'll take care of this instance.

Joerg

Actions #4

Updated by joerg about 18 years ago

On Thu, Jul 27, 2006 at 10:05:53PM +1000, Petr Janda wrote:

1) I can bzip the whole ktrace dump and put it on my webserver, will
that help you?
2) How do i switch to libthread_xu?

I'll look at fixing this, now that I got a hint on what is going wrong,
fixing it is easy. growisofs will be a bit more work, since it has to be
done carefully.

Joerg

Actions #5

Updated by justin about 18 years ago

On Thu, July 27, 2006 12:42 am, Petr Janda wrote:

http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html

Can someone please fix it? Its really bugging me, and Im not the only
one to have that issue. Some people say growisofs does the same.

If I'm recalling it correctly, this was solved with growisofs with this
patch:

http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/pkgsrc/sysutils/dvd+rw-tools/patches/patch-ad.diff?r1=1.2;r2=1.3;f=h

This may apply to xine too.

Actions #6

Updated by steve about 18 years ago

On Thu, 27 Jul 2006 10:46:38 -0400 (EDT)
"Justin C. Sherrill" <> wrote:

On Thu, July 27, 2006 12:42 am, Petr Janda wrote:

http://leaf.dragonflybsd.org/mailarchive/users/2006-07/msg00184.html

Can someone please fix it? Its really bugging me, and Im not the only
one to have that issue. Some people say growisofs does the same.

If I'm recalling it correctly, this was solved with growisofs with this
patch:

http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/pkgsrc/sysutils/dvd+rw-tools/patches/patch-ad.diff?r1=1.2;r2=1.3;f=h

No. That patch is necessary for growisofs to work at all on
DragonFly. I have had that patch since some time before it went into the
pkgsrc repository. The high CPU usage and slow burning is new.

Actions #7

Updated by corecode about 18 years ago

YONETANI Tomokazu wrote:

exec_t *js;
while ((js = g_async_queue_try_pop (js_queue))) {
/* spin; play_exec gets this & the GDK lock in reverse order /
while (pthread_mutex_trylock (&widgets_update_lock))
sched_yield ();
pthread_mutex_unlock (&widgets_update_lock); /
JS 'play()' needs it */

ehm? are they using the event of unlocking a mutex as some kind of signaling? and why wouldn't they just use get the lock?

engine_exec_obj (js->cmd, js->obj, js->cb, js->cb_data, js->ecb, js->src);
free (js->cmd);
free (js->src);
free (js);
}
return TRUE;
}

I wonder what happens if you use libthread_xu instead of libc_r
(not sure if it's easy to replace the use of pthead library).

I'm not sure how much works with libthread_xu. We're at least missing signaling bits in the kernel.

cheers
simon

Actions #8

Updated by elekktretterr about 18 years ago

This is what beep-media-player does upon I try to exit it. The GUI part
disappears, but according to 'top' it stays in the process list, and has
nearly 100% CPU usage and generates thousands of these errors untill i
kill -9 it. This is the extract of ktrace:

1343 beep-media-playe CALL  poll(0x28a44e40,0x1,0)
1343 beep-media-playe RET poll 0
1343 beep-media-playe CALL poll(0x28a16000,0x1,0)
1343 beep-media-playe RET poll 0
1343 beep-media-playe CALL sys_set_tls_area(0,0x28a09f98,0x8)
1343 beep-media-playe RET sys_set_tls_area 123/0x7b
1343 beep-media-playe CALL poll(0x28a16000,0x2,0x2563)
1343 beep-media-playe RET poll 1
1343 beep-media-playe CALL gettimeofday(0x2890c378,0)
1343 beep-media-playe RET gettimeofday 0
1343 beep-media-playe CALL sys_set_tls_area(0,0x28a09f98,0x8)
1343 beep-media-playe RET sys_set_tls_area 123/0x7b
1343 beep-media-playe CALL
_pread(0x6,0xbfbff8a0,0x20,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET __pread 32/0x20
1343 beep-media-playe CALL
_pread(0x6,0xbfbff898,0x8,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET _pread 8
1343 beep-media-playe CALL
_pwrite(0x6,0x28a49000,0xc,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET _pwrite 12/0xc
1343 beep-media-playe CALL
_pread(0x6,0xbfbff8a0,0x20,0x80000,0xffffffff,0xffffffff)
1343 beep-media-playe RET __pread -1 errno 35 Resource temporarily
unavailable

It seems to be the same problem as with growisofs, gmplayer, xine,
gxine. It seems unlikely that all of these programs would share the same
bug.

Any further feedback would be nice..

Petr

Actions #9

Updated by elekktretterr about 18 years ago

Share the same bug as in, the bug is in the actual programs and not in
DragonFly. This list probably doesn't end yet, its only these i know
about. Im running HEAD about 1-2 weeks old at around the time of the 1.6
release.

Actions #10

Updated by corecode about 18 years ago

not our bug, fixed in pkgsrc

Actions

Also available in: Atom PDF