Re: Idle Function Not Getting Called

2009-09-12 Thread Marshall Lake


The important point in looking at out-of-order locking (or other 
locking issues) is that the idle handler runs in the thread in which 
the main program loop runs, not the thread which called g_idle_add()/ 
g_idle_add_full(), and that it runs at a time not of that calling 
thread's choosing.


I don't quite understand this.  Don't all idle functions run in the 
main program loop thread?



Yes.


Then I don't understand what you mean by "the idle handler runs in the 
thread in which the main program loop runs, not the thread which called 
g_idle_add()/g_idle_add_full()".


Maybe I don't know what idle "handler" is but isn't that a moot point 
since the idle function (handler?) always runs in the main program loop 
thread?


--
Marshall Lake -- ml...@mlake.net -- http://mlake.net
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Idle Function Not Getting Called

2009-09-12 Thread Chris Vine
On Sat, 12 Sep 2009 12:00:11 -0400 (EDT)
Marshall Lake  wrote:
[...]
Me:
> > The important point in looking at out-of-order locking (or other
> > locking issues) is that the idle handler runs in the thread in
> > which the main program loop runs, not the thread which called
> > g_idle_add()/ g_idle_add_full(), and that it runs at a time not of
> > that calling thread's choosing.
> 
> I don't quite understand this.  Don't all idle functions run in the
> main program loop thread?

Yes.

Chris


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Idle Function Not Getting Called

2009-09-12 Thread Marshall Lake



The mutex locks/unlocks are only in a secondary thread and an idle
function.  I assume there's no problems with idle functions using
mutexes?


There is no problem provided that any mutex acquired by the idle 
function does not block (it immediately acquires), or if it does block 
then it only does so transiently.  If the secondary thread undertakes a 
lengthy operation holding a lock which the idle function may also want 
to acquire, then there is a bottleneck in the code.  If at the same time 
the secondary thread is waiting for the idle handler to complete, there 
is a deadlock.


In my case the secondary thread adds the idle function and then waits (via 
GCond) for it to finish.  The idle function consists of a simple modal 
dialog.


The important point in looking at out-of-order locking (or other locking 
issues) is that the idle handler runs in the thread in which the main 
program loop runs, not the thread which called g_idle_add()/ 
g_idle_add_full(), and that it runs at a time not of that calling 
thread's choosing.


I don't quite understand this.  Don't all idle functions run in the main 
program loop thread?


--
Marshall Lake -- ml...@mlake.net -- http://mlake.net
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Idle Function Not Getting Called

2009-09-12 Thread Chris Vine
On Sat, 12 Sep 2009 00:18:59 -0400 (EDT)
Marshall Lake  wrote:
[snip]
> I can't find a non-commercial deadlock checker for Linux.  I agree
> that the multi-threaded facet of the code is causing my problem but
> so far I'm having trouble using breakpoints/debug code to isolate the
> exact cause.
> 
> The mutex locks/unlocks are only in a secondary thread and an idle 
> function.  I assume there's no problems with idle functions using
> mutexes?

There is no problem provided that any mutex acquired by the idle
function does not block (it immediately acquires), or if it does block
then it only does so transiently.  If the secondary thread undertakes a
lengthy operation holding a lock which the idle function may also want
to acquire, then there is a bottleneck in the code.  If at the same
time the secondary thread is waiting for the idle handler to complete,
there is a deadlock.

The important point in looking at out-of-order locking (or other
locking issues) is that the idle handler runs in the thread in which the
main program loop runs, not the thread which called g_idle_add()/
g_idle_add_full(), and that it runs at a time not of that calling
thread's choosing.

Chris
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list