Question about Python threads

Greg Copeland gtcopeland at earthlink.net
Fri Aug 23 22:35:19 CEST 2002


"Mr. Neutron" <nicktsocanos at charter.net> writes:

> Now suppose i want to write a thread in python and I want it to execute
> on two CPUs. Ok, I have two threads, I will call them CPUA() and CPUB(). 

Okay.

> 
> Ok first, a few questions about C development with threads on Linux.
> 
> First, imagine CPUA() and CPUB() are now C functions. 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.  For the
vast majority of problem domains, you would never want to do this as the
kernel's schedular is almost always going to be smarter than you at under-
standing overall resource needs.

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

I believe this is covered in the various tidbits of documentation and
addressed in many messages.  I invite you to check out google.

> 
> Third, where to look in Python source tree for the threading mechanisms?
> I am studying Python source to learn. I will eventually find it on my
> own, but any experience knowing where to look will speed things up. I
> want to see how it works not that I have much intentions to change
> anything at this point. Purely academic reasons. I am interested in
> interpreted language design. I also study Blackdown JVM too.

Again, the net archives should of been your first stop.  Google.

Most, if not all of your questions have been previously addressed or
documenation is already available on python.org.



-- 
Greg Copeland, Principal Consultant
Copeland Computer Consulting
--------------------------------------------------
PGP/GPG Key at http://www.keyserver.net
5A66 1470 38F5 5E1B CABD  19AF E25A F56E 96DC 2FA9
--------------------------------------------------



More information about the Python-list mailing list