Re: Event loop



On 11 Nov, Earle R. Nietzel wrote:
I think you mean threads not another process...

Threads are a much better solution than creating another process...

Depends on the OS, the application, and the threading library you use,
IMHO.

On Linux the difference between threads and processes isn't very big. AFAIK
a thread uses the same memory-page for it's data as it's parent, while a
process does not. Both are created with clone(2), so I'd think there's no
big difference in overhead between creating a thread and a process.

Besides, access to the parent's memory can be a mixed blessing. Especially
if the app gets bigger, and you forget to lock a variable with a semaphore.

If you divide your app into separate processes, you can test and debug the
background (work) process seperately. There is some overhead, as you must
define the communication means and messages between the processes, using
files, message queues or whatever. But you don't have to worry about
different threads overwriting the same variable.

If you use a threading library that is contained within a single process,
it will make your GTK+ interface less responsive, if it's doing heavy
processes.

Besides, once you've written some helper functions, using and communicating
with different child processes isn't that hard. My own implementation is
under a thousand lines of C code. If anybody is interested, I'll place it
on my web page.

Just my $0.02

Roland
-- 
Roland Smith                        "When life hands you a lemon,
r s m i t h @ x s 4 a l l . n l      make lemonade."
http://www.xs4all.nl/~rsmith/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]