threading support in python
Bryan Olson
fakeaddress at nowhere.org
Tue Sep 5 11:28:13 EDT 2006
Paul Rubin wrote:
> "sjdevnull at yahoo.com" <sjdevnull at yahoo.com> writes:
>> If it's read/write data or you're not on a Unix platform, you can use
>> shared memory to shared it between many processes.
>>
>> Threads are way overused in modern multiexecution programming. The
>> decision on whether to use processes or threads should come down to
>> whether you want to share everything, or whether you have specific
>> pieces of data you want to share.
>
> Shared memory means there's a byte vector (the shared memory region)
> accessible to multiple processes. The processes don't use the same
> machine addresses to reference the vector. Any data structures
> (e.g. those containing pointers) shared between the processes have to
> be marshalled in and out of the byte vector instead of being accessed
> normally.
I think it's even worse. The standard Python library offers
shared memory, but not cross-process locks. Sharing read-write
memory looks like an automatic race condition. I guess one could
implement one of the primitive spin-lock based mutual exclusion
algorithms, but I think even that would depend on non-portable
assumptions about cache consistency.
--
--Bryan
More information about the Python-list
mailing list