Re: GUI Locks with gthreads
- From: Daniel Miralles García <namarie oasi upc es>
- To: Miraclesoa Miraclesoa <miraclesoa yahoo es>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GUI Locks with gthreads
- Date: Wed, 10 Mar 2004 09:12:21 +0100 (CET)
Hi all
Hi! ;)
I have a problem with my GUI and gthreads.
[...]
Check this:
g_mutex_lock(gmx);
if (zfin==0) {
{
if (gmx != NULL)
{
zini=g_timer_elapsed(zparo,NULL);
while(zini==0 && zfin==0)
{
zini=g_timer_elapsed(zparo,NULL);
}
g_timer_stop(zparo);
zini=0;
if(zfin==1)
{
self = g_thread_self();
g_mutex_unlock(gmx);
g_thread_exit(self);
}
}
}
if(zfin==1)
<<< Why not an "else"? If you enter this one it's because you haven't
entered into the other.
{
g_mutex_unlock(gmx);
g_thread_exit(self);
}
g_mutex_unlock(gmx);
}
}
I'll suggest to make a simple "wait" for a few miliseconds, just to let
the second process run a little. It's something I found in my
multithreading program (maybe some Linux guru can help to this?)
When you have two threads that are into a "while(1)", you think they will
run 1-2-1-1-2-1-2-2-2-1-1-2-1-2-1-2-1-1-2.... but the reality is
"1-1-1-1-1-1-1-1-2-2-2-2-2-2-2-2-2-1-1-1-1-1-1". If you add a little wait
(wait 20 miliseconds) just after the mutex_unlock, it will be
1-2-1-2-1-2-1-2 (at least that's what it happens with my program).
By the way, who sets the Zfin flag to "1"? I haven't found. Is there a
third thread? Are you using "zini" in
zini=g_timer_elapsed(zparo,NULL);
when you want "zfin"?
.-:Namarie:-.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]