Re: deadlock
- From: "Brian J. Tarricone" <bjt23 cornell edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: deadlock
- Date: Thu, 10 Mar 2005 16:48:48 -0800
Dirk Huenniger wrote:
Hello everybody,
My name is Dirk, I'm writing a control programm for a 1m telescope in
Germany. The current status of the device is periodically displayed in
GTK using a thread. When the user clicks the quit butten a callback
routine is
started. At the same time my thread does a gtk_threads_enter(). But
it cannot enter because the callback is running so it waits inside the
gtk_threads_enter
routine. My callback routine askes the thread to quit and waits for that
to happen. But the thread cannot react because it is waiting inside
gtk_threads_enter(). So everything is hanging now.
Yeah, this is a somewhat yucky situation. The best way (that I've
found) is to call g_idle_add() from the thread (instead of locking Gdk
and doing your processing there), and handle the processing in the idle
function (which runs in the main thread). You still need
gdk_threads_enter/leave() in the idle function, but the deadlock
condition with the thread quitting is no longer there. Of course, this
means that the GUI processing occurs somewhat later - when the glib
mainloop processes idle functions - but it usually isn't a big deal,
though I don't know how time-sensitive your display needs to be.
-brian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]