DragonFly BSD
DragonFly bugs List (threaded) for 2006-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Threadding issue

From: YONETANI Tomokazu <qhwt+dfly@xxxxxxxxxx>
Date: Thu, 27 Jul 2006 20:52:25 +0900

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).

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]