global interpreter lock not working as it should

James J. Besemer jb at cascade-sys.com
Fri Aug 2 02:16:52 CEST 2002


brueckd at tbye.com wrote:

> Really? Consider:
>
> import threading, time
> def f():
>   while 1:
>     time.sleep(1)
>
> for i in range(3):
>   threading.Thread(target=f).start()
>
> Now from my Linux cmd line:
>
> > ps -aux | grep python
> dave     16839  0.0  0.7  9272 1868 pts/4    S    11:07   0:00 python
> dave     16840  0.0  0.7  9272 1868 pts/4    S    11:07   0:00 python
> dave     16841  0.0  0.7  9272 1868 pts/4    S    11:07   0:00 python
> dave     16842  0.0  0.7  9272 1868 pts/4    S    11:07   0:00 python
>
> On Linux this is especially easy to see because you basically get one
> process per thread,

Just a nit: I believe on Linux you get one proc table entry
per thread but you don't get entire processes.  Newer
Linux versions support real threads but they each
resemble a process on PS listings.

Discrete procs would mean separate address spaces,
file descriptors (among other things), whereas the
threads all in fact share those per-proc resources.
Threads each have distinct priorities, "wait channel",
runtimes (among other things) which shows in "ps"
listings.

Regards

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com






More information about the Python-list mailing list