Python and system vs process scope threads (was Re: python ports broken (sem_destroy: Resource temporarily)

Hye-Shik Chang freebsdports at pipiband.com
Fri Feb 6 18:12:00 PST 2004


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


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


More information about the freebsd-ports mailing list