Threads vs Processes

Carl J. Van Arsdall cvanarsdall at mvista.com
Wed Jul 26 13:54:48 EDT 2006


Alright, based a on discussion on this mailing list, I've started to 
wonder, why use threads vs processes.  So, If I have a system that has a 
large area of shared memory, which would be better?  I've been leaning 
towards threads, I'm going to say why.

Processes seem fairly expensive from my research so far.  Each fork 
copies the entire contents of memory into the new process.  There's also 
a more expensive context switch between processes.  So if I have a 
system that would fork 50+ child processes my memory usage would be huge 
and I burn more cycles that I don't have to.  I understand that there 
are ways of IPC, but aren't these also more expensive?

So threads seems faster and more efficient for this scenario.  That 
alone makes me want to stay with threads, but I get the feeling from 
people on this list that processes are better and that threads are over 
used.  I don't understand why, so can anyone shed any light on this?


Thanks,

-carl

-- 

Carl J. Van Arsdall
cvanarsdall at mvista.com
Build and Release
MontaVista Software




More information about the Python-list mailing list