\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#364: Threading Support: Configuration and Package}
\date{March 19, 2010}
\author{Donal K. Fellows}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#364}&\textbf{Threading Support: Configuration and Package}\\\hline
Author&

Donal K. Fellows \tipmail{donal.k.fellows}{manchester.ac.uk}
\\
Created&Friday, \(\text{19}^{\text{th}}\) March 2010\\
Type&Project\\
Tcl Version&\(8.6\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.4 $\\
Keywords&Tcl\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP changes the the default configuration for building to threaded on all platforms where this is not already the case (primarily Unix other than MacOS X) and adds the Thread package to the set of packages included by default.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

As the world of hardware changes, it is becoming clear that modern computers will increasingly have multiple CPU cores available to them. This is driven by the fact that it is easier for the manufacturers of processors to make them able to do more by increasing the number of cores than by increasing the speed of those cores. It is therefore a strongly-desirable thing to have Tcl able to utilize these resources and, naturally, in a cross-platform way.

Threading is actually an area of considerable strength for Tcl. In particular, we have supported a threaded build of Tcl on all platforms since Tcl 8.1, and the performance cost of this is now minimal. In addition, the Thread package has been in use in production for a long time and provides script-level access to threading facilities. All that we need to do to fully enable Tcl 8.6 for threading for all scripts is to make the Thread package into a standard contributed package and ensure that it can be used on all our main supported platforms. It is this which this TIP proposes.

\section{Proposed Change}

All that is required is to make the Thread package into one of the packages that is handled through the contributed package mechanism (c.f., [incr Tcl] \cite{tip50}, TDBC \cite{tip308}), by locating a copy of it in the \textit{pkgs/} directory of the Tcl sources. However, to make this meaningful it is also necessary to alter the default configuration of Tcl to be threaded. This will have no effect on Windows and OSX, where threaded configurations are default anyway, but will have an impact on other Unixes (Linux, Solaris, etc.) The threaded configuration has had extensive testing over many years on all platforms, so it is known that a majority of Tcl scripts will be wholly unaffected by this.

The main issues arising from this relate to the Expect and TclX packages. This is because they make \textbf{fork} and \textbf{signal} commands available; these APIs are troublesome because of how they interact with Tcl's notifier and the POSIX Thread system in general. However, the importance of threading as a general facility means that it is going to be more important to alter those packages than to keep Tcl defaulting to unthreaded.

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\begin{thebibliography}{TIP \#2}
\addcontentsline{toc}{section}{References}
\bibitem[TIP \#50]{tip50}
Kevin Kenny,
Mark Harrison,
Jeff Hobbs,
Andreas Kupries,
Karl Lehenbauer,
Michael McLennan,
Don Porter,
Brent Welch,
\emph{Bundle [incr Tcl] with the Core Tcl distribution},
on-line at \url{http://purl.org/tcl/tip/50.html}
\bibitem[TIP \#308]{tip308}
Kevin B. Kenny,
Artur Trzewik,
Andreas Leitgeb,
Donal K. Fellows,
\emph{Tcl Database Connectivity (TDBC)},
on-line at \url{http://purl.org/tcl/tip/308.html}
\end{thebibliography}
\end{document}
