Question about Python threads

Gerhard Häring gerhard.haering at gmx.de
Fri Aug 23 22:56:14 CEST 2002


* Greg Copeland <gtcopeland at earthlink.net> [2002-08-23 15:35 -0500]:
> "Mr. Neutron" <nicktsocanos at charter.net> writes:
> > How do I specifically tell in C using pthreads, that I want CPUA()
> > on CPU0 and CPUB() on CPU1? My understanding is you can't specify
> > this on Linux, but I hope I am just limited in my understanding
> 
> You can't specify this on most OS'.  This is called CPU affinity.

AFAIK the Mindcraft benchmark exploited that Windows can set CPU
affinity, while Linux can't. That may be one reason why there are now
cpu affinity patches to the Linux kernel. Though I have a (crappy) SMP
machine here, I've never tried these patches myself.

> > Second, how in C do I access the GIL in python? Where do I look for
> > this or are there any examples of this?

Py_BEGIN_ALLOW_THREADS / Py_END_ALLOW_THREADS

Be cautious with these, it's easy to make errors.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))




More information about the Python-list mailing list