Re: Concurrent processes
- From: Hal Greenwald <hgreenwald itd nrl navy mil>
- To: Paul Davis <pbd op net>, Valery Avaux <vavaux ulb ac be>
- Cc: gtk-list gnome org
- Subject: Re: Concurrent processes
- Date: Tue, 03 Apr 2001 18:29:39 -0400
My experience has been that it is a big mistake to distribute
GTK calls (or any X based widget set for that matter) among threads.
I use use multi-threading, however the gui controls live in a single
At 05:48 PM 4/3/01 -0400, Paul Davis wrote:
>Is there a way to let me change parameters ? Maybe lookup signals or
>somenthing like that ? I've heard something about threads but I don't
>know what it is.... I'm really a newbie so if someone could give me some
>very detailled way to do this, it would be very nice.
nobody is going to give you a detailed enough account without simply
pointing you at source code.
a thread is bit like a process, except that instead of being an
entirely separate program with its own protected virtual memory, it
runs with complete access to the memory of the thread in which it was
started. when you start a new process, you can't share data without
specific arrangements to do so. when you start a new thread, all data
is shared between all the threads in the process. the different
threads all run "concurrently", where "concurrently" means
time-sharing however many processors your system has with any other
threads in any other processes that are ready to run.
you can start by reading up on the pthreads library. then, from
handler for the adjustment->changed signal, you can do this:
void *my_computationally_intensive_thread (void *arg)
... do the stuff you want here ...
adjustment_changed_handler (GtkWidget *widget)
pthread_create (&thread_id, NULL,
Thats just the bare bones. You'll no doubt need some mutexes to
prevent various bad things from happening, and you should almost
certainly make no calls to GTK or GDK from the separate thread. If you
plan to do that, there's a bit more work you need to do.
I happen to like a book called "Programming With Threads" by Kleiman
et al. but there are many others on the topic floating around.
gtk-list mailing list
gtk-list gnome org
] [Thread Prev