Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl Thread Safety / Windows build

20 views
Skip to first unread message

wba...@landacorp.com

unread,
Mar 29, 2006, 2:31:59 PM3/29/06
to
I've read that recent Tcl versions are all thread-safe but notice tht
on Unix there are compiler options that need to be set for the make.

Are these options set by default in the binary Windows distributions?
Or do I need to do my own local build?

Thanks in advance...

Michael Schlenker

unread,
Mar 29, 2006, 6:54:51 PM3/29/06
to
wba...@landacorp.com schrieb:
Recent Tcl versions are thread safe, but as threads are always slower
than the non-threaded builds due to the extra code for locking etc. its
not enabled by default currently. There are also problems if you mix
threads with things like Tclx's fork command unless you really know what
your doing.

Debian ships a threaded Tcl by default, the ActiveTcl 8.4.12 distro (at
least on windows) was built with threads enabled. You can check if your
Tcl is thread enabled by looking at the tcl_platform array, if there is
an entry 'threaded' you have a threaded build.

To acutally create and use threads from the script level you need the
threads extension.

Michael

Donal K. Fellows

unread,
Mar 30, 2006, 4:17:50 AM3/30/06
to
wba...@landacorp.com wrote:
> I've read that recent Tcl versions are all thread-safe but notice tht
> on Unix there are compiler options that need to be set for the make.

Thread support on Unix is not enabled by default, largely because a
number of popular extensions use signals on that platform and signals do
not work very well with pthreads... :-( (Or at least I think that's
still the case. Anyone know better?)

> Are these options set by default in the binary Windows distributions?
> Or do I need to do my own local build?

You'll need to check the documentation for your distribution, but recent
ActiveTcl distributions contain thread support (and certainly have done
for a while on Windows too, but not as far back as the builds based on
Tcl 8.4.7, which is the last time I updated this machine).

Donal.

wba...@landacorp.com

unread,
Mar 30, 2006, 1:24:49 PM3/30/06
to
Thanks, I'm not trying to use threads explicitly but rather just need
to confirm that the Tcl dll handles reentrancy from multiple
simultaneous Tcl interpreters properly. A developer who has left our
company said that Tcl after 8.2 wasn't thread-safe and so we couldn't
upgrade to 8.4, but he never told us what he meant by that.

Donal K. Fellows

unread,
Mar 30, 2006, 4:50:58 PM3/30/06
to
He was partially right. Tcl 8.3 wasn't thread-safe; there were definite
bugs in there! :-) But 8.4 should be pretty good for Tcl and
thread-safety, and 8.5 will include a substantial effort to make Tk
thread-safe too.

On the other hand, it's possible from your description you're trying to
use a single Tcl interpreter (i.e. one Tcl_Interp instance) from
multiple threads. Don't do that; it violates *loads* of deep
assumptions. Send a message to the interpreter's thread instead; that's
supported.

Donal.

Donald Arseneau

unread,
Mar 30, 2006, 5:33:00 PM3/30/06
to
wba...@landacorp.com writes:

Interesting question. I certainly don't know, but I am interested.
Are there any particular sub-versions that should be avoided, because
of bugs in reentrancy?

My understanding is that any Tcl is safe to use in a threaded application
when each thread gets its own interp, and there is no communication
between those Tcl interps. Is my understanding right?


--
Donald Arseneau as...@triumf.ca

0 new messages