Re: Event loop



Some programs like httpd and inetd fork processes based on need purely.

A DESIGN issue.

While threads have many advantages over processes ( which I don't think is
necessary to go into ). I beleive that if you have two programs that do the
same thing but one coded using threads and another using processes the one
using threads will be signifcantly faster than the other because of the
tighter synchronization that threads allow you to use.

Also you need to consider especially when talking about processes like httpd
and inetd that the threaded libaries are not completed yet and there are
different implelmentations as well. The commonly used library 'pthreads' the
POSIX standard is not fully supported in Linux, also regarding threads Linus
is not a happy about the current inplementations and has started to lay the
ground rules for his implementation.

Of course I am not going to say that the entire system should run with one
process and the rest as threads... But there are clear cases when it is
better to use threads in an application and vice versa. Just keep in mind
that there are many speedups within the threaded model such as shared memory
stacks and fewer context switches which make threaded applications
flyyyyyyyyyyy...

Cheers,
Earle


On Sat, 11 Nov 2000, Earle R. Nietzel wrote:

I think you mean threads not another process...

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

Not always!

Why are not httpd in one big process with a lot of treads?
Why are inted spawning processes instead of just using shared
libs and creating threads???

So this must be a design issue... Good design is not always
easy. Sometimes you must experiment with threads implementations
versus processes.

But to do someting like

  while(1)
  {
     do_one_thing();
     do_another_thing();
     ...
  }

must be wrong. Here you should use thread *or* processes.
If the jobs *must* be done in sequence you should consider
semaphores och some signaling mechanism.

IMHO

G Hasse


----------------------------------------------------------------
Göran Hasse            email: gh raditex se     Tel: 08-6949270
Raditex AB             http://www.raditex.se    Fax: 08-6949280
Sickla Alle 7, 1tr                              Mob: 070-5530148
131 34  NACKA, SWEDEN



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





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