Re: Processes vs Threads

From: Casper H.S. Dik <casper_at_fwi.uva.nl>
Date: 15 Nov 1994 11:45:36 +0100
Message-ID: <3aa3gg$7lb_at_mail.fwi.uva.nl>


psb_at_sambusys.demon.co.uk (Paul Beardsell) writes:

>Err, well, yes. But what actually happens when you create a new process
>as opposed to creating a new thread? If you actually count the instructions
>executed, the amount of memory allocated, the overhead of the thread
>scheduler etc etc then it is not obvious that creating/running a thread
>is cheaper than creating/running a process.

In Solaris the main difference between creating a new thread and fork is whether a new address space must be created or not.

For fork() all writable pages need to be marked copy-on-write. This gives fork() an overhead which is linear in the size of the process.

Creating a kernel thread or vfork() take a constant amount of time.

>What type of application other than number crunching doesn't do system
>calls all the time? Please just name a few. Because then I'll save any
>consideration of threads until I have the occasion to write one of the
>apps.

Even on signle processor machine, you can do other things in other threads while one of your threads is waiting for I/O to complete. So even system call bound apps can benefit greatly from multiple threads. (Or didn't I understand what you were asking?)

Casper Received on Tue Nov 15 1994 - 11:45:36 CET

Original text of this message