Threads vs Processes
Carl J. Van Arsdall
cvanarsdall at mvista.com
Wed Jul 26 18:10:14 EDT 2006
Paul Rubin wrote:
> "Carl J. Van Arsdall" <cvanarsdall at mvista.com> writes:
>
>> Processes seem fairly expensive from my research so far. Each fork
>> copies the entire contents of memory into the new process.
>>
>
> No, you get two processes whose address spaces get the data. It's
> done with the virtual memory hardware. The data isn't copied. The
> page tables of both processes are just set up to point to the same
> physical pages. Copying only happens if a process writes to one of
> the pages. The OS detects this using a hardware trap from the VM
> system.
>
Ah, alright. So if that's the case, why would you use python threads
versus spawning processes? If they both point to the same address space
and python threads can't run concurrently due to the GIL what are they
good for?
-c
--
Carl J. Van Arsdall
cvanarsdall at mvista.com
Build and Release
MontaVista Software
More information about the Python-list
mailing list