-NOTE
+NOTE: This documentation describes the style of threading that was
+available in 5.005. Perl v5.6 also has the early beginnings of
+interpreter-based threads support (which is what will be enabled by
+default when you simply ask for -Dusethreads). However, be advised
+that interpreter threads cannot as yet be created from the Perl level
+yet. If you're looking to create threads from within Perl, chances
+are you _don't_ want interpreter threads, but want the older support
+for threads described below, enabled with:
+
+ sh Configure -Dusethreads -Duse5005threads
+
+The rest of this document only applies to the use5005threads style of
+threads.
+---------------------------------------------------------------------------
-Threading is a highly experimental feature. There are still a
-few race conditions that show up under high contention on SMP
+Support for threading is still in the highly experimental stages. There
+are known race conditions that show up under high contention on SMP
machines. Internal implementation is still subject to changes.
It is not recommended for production use at this time.
If your system is in the following list you should be able to just:
- ./Configure -Dusethreads -des
+ ./Configure -Dusethreads -Duse5005threads -des
make
and ignore the rest of this "Building" section. If not, continue
information may be in a platform-specific "hints" file in the hints/
subdirectory.
-First of all, because threads are such an experimentral feature
-there's a failsafe in Configure that stops unknown platforms
-from using threads. Search for "is not known to support threads".
-About five lines above that is a line that has a list of operating
-system names separated with |-signs. Append your operating system
-(perl -le 'print $^O') to that list.
-
-On other platforms that use Configure to build perl, omit the -d
-from your ./Configure arguments. For example, use:
+On platforms that use Configure to build perl, omit the -d from your
+./Configure arguments. For example, use:
- ./Configure -Dusethreads
+ ./Configure -Dusethreads -Duse5005threads
When Configure prompts you for ccflags, insert any other arguments in
-there that your compiler needs to use POSIX threads. When Configure
-prompts you for linking flags, include any flags required for
-threading (usually nothing special is required here). Finally, when
-Configure prompts you for libraries, include any necessary libraries
-(e.g. -lpthread). Pay attention to the order of libraries. It is
-probably necessary to specify your threading library *before* your
-standard C library, e.g. it might be necessary to have -lpthread -lc,
-instead of -lc -lpthread. You may also need to use -lc_r instead
+there that your compiler needs to use POSIX threads (-D_REENTRANT,
+-pthreads, -threads, -pthread, -thread, are good guesses). When
+Configure prompts you for linking flags, include any flags required
+for threading (usually nothing special is required here). Finally,
+when Configure prompts you for libraries, include any necessary
+libraries (e.g. -lpthread). Pay attention to the order of libraries.
+It is probably necessary to specify your threading library *before*
+your standard C library, e.g. it might be necessary to have -lpthread
+-lc, instead of -lc -lpthread. You may also need to use -lc_r instead
of -lc.
Once you have specified all your compiler flags, you can have Configure
Building the Thread extension
The Thread extension is now part of the main perl distribution tree.
-If you did Configure -Dusethreads then it will have been added to
-the list of extensions automatically.
+If you did Configure -Dusethreads -Duse5005threads then it will have been
+added to the list of extensions automatically.
You can try some of the tests with
cd ext/Thread