Re: broken lock API in gtk_main ()
- From: Sebastian Wilhelmi <wilhelmi ira uka de>
- To: Tim Janik <timj gtk org>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: broken lock API in gtk_main ()
- Date: Mon, 28 May 2001 12:17:54 +0200
Hi Tim ,
> gtk_main() behaves as follows:
>
> 1)
> /* gdk-lock locked by other thread */
> gtk_main (); /* wait for other thread to release lock, then acquire,
> operate */
> /* gdk-lock acquired */
>
> 2)
> /* gdk-lock released */
> gtk_main (); /* acquire, operate */
> /* gdk-lock acquired */
>
> 3)
> /* gdk-lock acquired by self */
> gtk_main (); /* operate */
> /* gdk-lock acquired */
>
> the behaviour of (3) is fine for calling gtk_main() recursively (modal
> dialogs).
> (2) is what happens in main () { [...] gtk_main(); }, it actually works
> just out of luck, that is, releasing a non acquired lock works on most
> platforms nonetheless, while (1) is fundamentally broken.
>
> cases (1) and (2) have asymetric lock behaviour (not locked by self upon
> entry, locked by self upon return) and need to be fixed.
> (2) could be hacked around (this is the common main() case) with
> figuring lock state via g_mutex_trylock() upon entry and releasing
> the lock upon return if FALSE was returned. that'll still maintain
> (3) but unfortunately break (1) (note that (1) is broken already).
Actually I don't see this happening, but I'm not very intimate with the
details of GTK+ anyway.
> to ultimately fix all three cases, i.e. get:
>
> 1)
> /* gdk-lock locked by other thread */
> gtk_main (); /* wait for other thread to release lock, then acquire,
> operate */
> /* gdk-lock RELEASED */
>
> 2)
> /* gdk-lock released */
> gtk_main (); /* acquire, operate */
> /* gdk-lock RELEASED */
>
> 3)
> /* gdk-lock acquired by self */
> gtk_main (); /* operate */
> /* gdk-lock acquired */
>
> we need to be able to check if the lock is acquired by self upon
> entry.
> sebastian, is anything to the extend of gboolean
> g_mutex_locked_by_self (m) feasible to implement?
Yes, and it's called GStaticRecMutex. It's not possible for GMutex without
adding just what GStaticRecMutex has.
Bye,
Sebastian
--
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]