Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Feb 2004 18:52:52 -0800 (PST)
From:      Julian Elischer <julian@elischer.org>
To:        Hye-Shik Chang <freebsdports@pipiband.com>
Cc:        Daniel Eischen <eischen@vigrid.com>
Subject:   Re: Python and system vs process scope threads (was Re: pythonports broken (sem_destroy: Resource temporarily)
Message-ID:  <Pine.BSF.4.21.0402061845060.24800-100000@InterJet.elischer.org>
In-Reply-To: <20040207021409.GA33111@i18n.org>

next in thread | previous in thread | raw e-mail | index | archive | help


On Sat, 7 Feb 2004, Hye-Shik Chang wrote:

> On Fri, Feb 06, 2004 at 06:11:57PM -0500, Daniel Eischen wrote:
> > A brief synopsis:
> > 
> > The python port uses system scope threads, or at least the
> > test_threaded_import.py test in /usr/local/lib/python2.3/test
> > does.  Is there a reason python uses system scope threads
> > instead of process scope threads?  It is more efficient
> > and consumes less resources in FreeBSD if it were to use
> > scope process threads.
> 
> Python uses system scope threads to make thread running run
> like more human-expected. (The discussion was here:
> http://groups.google.com/groups?threadm=slrn9ppgeb.mvb.bbrox%40bbland.bbrox.com&rnum=2)
> With system scope, it runs:
> 
> % python ~/testthread.py
> thread 0 begin
> thread 1 begin
> thread 2 begin
> thread 3 begin
> thread 4 begin
> thread 0 end
> thread 1 end
> thread 3 end
> thread 2 end
> thread 4 end
> 
> But with process scope, it runs:
> 
> % ./python ~/testthread.py
> thread 0 begin
> thread 0 end
> thread 1 begin
> thread 1 end
> thread 2 begin
> thread 2 end
> thread 3 begin
> thread 3 end
> thread 4 begin
> thread 4 end
> 

what the threads do will effect when they are scheduled..

if you had 2 processors you ay also see:
> thread 0 begin
> thread 1 begin
> thread 0 end
> thread 1 end
> thread 2 begin
> thread 3 begin
> thread 2 end
> thread 3 end
> thread 4 begin
> thread 4 end

The link mentionnedabove is i think misguided..
they are trying to make threads run concurrently, but..
"why?"  If there is no dependency between the threads then
what does it matter what order they are scheduled in, and if there IS a
dependency, then teh threading package is supposed to take that into
account, as one thread will block waiting for the other and the other
will be allowed to run..

Also even in Process-scope mode, threads will be round-robbinned
a bit.. the test program probably doesn't wait long enough..
(isn't that right Dan?)

I don't see why the "concurrency" asked for in the mail shown above is
important (other than looking pretty).
I'd like to see a real-world example of why this is important.


> 
> Because our libc_r did system scope threads similar as process
> scope, python threads have been scheduled like the latter one on
> the previous FreeBSD releases. So even patching to use process scope
> threads on the port will not hurt backward-compatibility.
> 
> Okay. I'll fix it on the port. Thanks for your investigation!
> KSE rocks! ;)
> 
> 
> Cheers,
> Hye-Shik
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0402061845060.24800-100000>