LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Threads, fork etc

[ILUG] Threads, fork etc

Mel mel at csn.ul.ie
Tue Feb 8 23:47:14 GMT 2000


On Sat, 5 Feb 2000, Justin Mason wrote:

> allsop said:
> 
> > I'm working on developing a network server program at the moment, and I'd
> > better way of doing it?
> 
> Do it UNIX-wise -- use fork(), and fork a process to handle each request
> if possible.  Threads are a big reliability sacrifice, for obvious
> reasons -- if you coredump in one thread, the whole comes
> down around your ears -- coredump in a process, and only that proc will
> die.
> 

Depends on the size of the process. Fork is "heavier" than threading. I
don't think you should expect your processes to be coredumping
either. Threads have a speed advantage to fork depending on the thread
implementation. Also bear in mind, that he might want the processes to
share information

> Forking is slower than threads -- but threadsafe development itself
> incurs a performance penalty, as locks are required around shared (or
> possibly-shared) data structures.
> 

yeah, but with locking in the right place, it's negliable. You can use
thread unique data to avoid collisions. With fork, you have to use shared
memory and semaphores which is even bigger

> But to answer the q you actually asked ;)  -- you shouldn't have any
> problem forking processes from within a subthread AFAIK.
> 

oohhhhh. very messy. under POSIX, the new process only has one thread. If
there is mutex's involved, it's very easy to deadlock and you have a right
problem on your hand. You have to declare fork handlers before ou can fork
safely and thats bothersome.

back to the problem, if the sub processes need to share data, then thread
- it's the way of the future. If the subprocesses are big, thread. In
fact, it's only if each process is small, truely self contained and so on,
is fork a better idea.

		Mel





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell