v1.00 August 2001
ScTL was originally developed as part of the Solaris Compatibility Libraries (SCL) for Tru64 UNIX. See http://tru64unix.compaq.com/complibs/ for information about SCL. There is an on-line Users Guide for SCLat http://tru64unix.compaq.com/complibs/documentation/html/scl_ug.html, of which chapters 3 Solaris Threads and 5 Error Logging are relevant to ScTL.
There is a paper about ScTL that was presented at the Usenix 2001 conference at http://www.opensource.compaq.com/the_source/linux_papers/scl_solaris.htm. There is also a web-site for ScTL at http://www.opensource.compaq.com/the_source/linux_papers/stl.htm.
The ScTL source-code is hosted in a SourceForge project at http://sourceforge.net/projects/sctl. The Sourceforge home-page for ScTL is http://sctl.sourceforge.net.
ScTL was known as STL, and many of the build-files, etc. still refer to STL instead of ScTL.
ScTL is provided "as-is", with no formal support. Any problems or queries can be sent to solaris.complib@compaq.com where they will be dealt with on a best-efforts basis.
Operating System | Compiler |
Tru64 UNIX v4.0F | Compaq C |
Tru64 UNIX v5.1 | Compaq C |
Red Hat Linux 7.0 (Alpha, 64-bit) | GNU C |
Red Hat Linux 7.0 (Intel, 32-bit) | GNU C |
FreeBSD 4.2 (Intel, 32-bit) | GNU C |
ScTL is written in the C programming language, and requires an ANSI89 C compiler to build it from source.
ScTL requires that the target operating system has a POSIX 1003.1-1996 -compliant threads library. ScTL also uses POSIX threads extensions from the Single UNIX Specification v2, which defines the UNIX98 brand.
ScTL was originally developed on Tru64 UNIX. It has been ported to Linux and FreeBSD.
The ScTL development makefiles are all named gnumakefile, to make it more obvious that GNU make is required.
To use an ScTL gnumakefile, you must specify a command-line parameter OS that indicates the operating system platform. Recognized values for OS are:
% gnumake -f gnumakefile OS=t64
The tool/MakeSTL script checks that some environment variables have been set, and if they have not then it will prompt you to set them. The environment variables needed are:
SCL_SOURCE_ROOTNote that the environment variables are prefixed by SCL, not ScTL, which betrays ScTL's origin as part of SCL.
-top-level directory for the ScTL source-code.SCL_BUILD_ROOT
-top-level directory for the ScTL build (object files, libraries, executables).
SCL_SOURCE_ROOT must point to the ScTL source code's top-level directory. This directory will have sub-directories of:
If you are building for a single platform only, then you can set SCL_BUILD_ROOT
to be the same as SCL_SOURCE_ROOT.
When you run tool/MakeSTL, it may ask if you want to build the ScTL libraries and/or the tests. Currently you can only build the libraries, because the test source code has not been released.
MakeSTL should build two libraries and a message catalogue:
SCL_BUILD_ROOT/shlib/libthread.soActually MakeSTL also builds debug-built versions of the two libraries (named libthreaddbg.so and libsolutildbg.so), but the debug libraries are mainly used during development.
SCL_BUILD_ROOT/shlib/libsolutil.so
SCL_BUILD_ROOT/lib/nls/msg/scl_message.cat
The MakeSTL script does not require that OS is set, as it sets OS by running the common/scl_os script.
The MakeSTL script can be invoked with a make-target parameter. For example:
% tool/MakeSTL cleanwill invoke all of the gnumakefiles with the target clean, which removes all re-creatable files.
gnumake -check that the gnumake command works
setenv SCL_SOURCE_ROOT /dir/containing/ScTL/sources
setenv SCL_BUILD_ROOT /dir/for/build/files
chmod +x $SCL_SOURCE_ROOT/MakeSTL
cd $SCL_BUILD_ROOT
$SCL_SOURCE_ROOT/tool/MakeSTL
$SCL_SOURCE_ROOT/include/thread.h Solaris thread declarationsYou can build your Solaris applications against the ScTL development files, or you may choose to use a suitable root directory to copy the necessary ScTL files to, so that the building of your Solaris-threaded applications is not interfered with by modifications to the ScTL development builds.
$SCL_SOURCE_ROOT/include/synch.h Solaris thread synchronization-object declarations
$SCL_BUILD_ROOT/shlib/libthread.so Solaris thread shared object library
$SCL_BUILD_ROOT/shlib/libsolutil.so SCL utility library
$SCL_BUILD_ROOT/lib/nls/msg/scl_message.cat SCL message catalogue
$SCL_BUILD_ROOT/bin/tru64_version needed for Tru64 UNIX only
Assume that you are developing on Tru64 UNIX, and that the ScTL development files are copied to /usr/opt/STL. Set the environment variable SCL_ROOT_DIR to this directory. Then copy the above files into (beneath) the target directory, such that you now have the following files on your system:
$SCL_ROOT_DIR/include/thread.h
$SCL_ROOT_DIR/include/synch.h
$SCL_ROOT_DIR/shlib/libthread.so
$SCL_ROOT_DIR/shlib/libsolutil.so
$SCL_ROOT_DIR/lib/nls/msg/scl_message.cat
$SCL_ROOT_DIR/bin/tru64_version needed on Tru64 UNIX only
When building Solaris-threaded applications, note the following
points:
The stl_example.c program is supplied with the following makefiles:
gnumake -f gnumakefile OS=lnxThe makefile.xxx files do not require GNU make, but rather will work with the bundled make on the respective system. To build using the makefile.xxx files, you need to set an environment variable so that the C compiler can find the ScTL include-files, and the linker can find the ScTL libraries. The environment variable SCL_ROOT_DIR needs to be set to the parent directory of the ScTL kit. For example, if the ScTL files reside beneath /home/stl, and C-shell is being used, and you are building on Linux, then do the following:
setenv SCL_ROOT_DIR /home/stlAlternatively you could set SCL_ROOT_DIR on the make command-line. E.g.:
cd $SCL_ROOT_DIR/examples/threads
make -e -f makefile.lnx
make -f makefile.lnx SCL_ROOT_DIR=/home/stlBut then you do not have SCL_ROOT_DIR as an environment variable.
Before running the stl_example program, you should set some environment variables so that the shared libraries, etc., can be found. E.g.
setenv LD_LIBRARY_PATH $SCL_ROOT_DIR/shlibThen run the example program to sum the square of the numbers 1..10 by using worker-threads to calculate each square.
setenv NLSPATH $SCL_ROOT_DIR/lib/nls/msg/%N
setenv SCL_LOG_FILE stdout
./stl_example 10The output should look similar to that below. Note the first and last message about SCL Logfile: you will not see this (and hence not see any potential error messages) if you have not set the SCL_LOG_FILE environment variable.
% ./stl_example 10
0.00000|000003ffc01b3e88: SCL Logfile initializedWill create 10 new threads
New thread 0x0000020000f17600 running; argument is 1
New thread 0x000002000141f600 running; argument is 2
New thread 0x0000020001927600 running; argument is 3
New thread 0x0000020001e2f600 running; argument is 4
New thread 0x0000020002337600 running; argument is 5
New thread 0x000002000283f600 running; argument is 6
New thread 0x0000020002d47600 running; argument is 7
New thread 0x000002000324f600 running; argument is 8
New thread 0x0000020003757600 running; argument is 9
New thread 0x0000020003c5f600 running; argument is 10main thread: all new threads running;
will release them in 2 seconds.Thread 0x0000020000f17600 with argument 1 computed square = 1
Thread 0x000002000141f600 with argument 2 computed square = 4
Thread 0x0000020001927600 with argument 3 computed square = 9
Thread 0x0000020001e2f600 with argument 4 computed square = 16
Thread 0x0000020002337600 with argument 5 computed square = 25
Thread 0x000002000283f600 with argument 6 computed square = 36
Thread 0x0000020002d47600 with argument 7 computed square = 49
Thread 0x000002000324f600 with argument 8 computed square = 64
Thread 0x0000020003757600 with argument 9 computed square = 81
Thread 0x0000020003c5f600 with argument 10 computed square = 100All threads joined; total sum of squares is = 385
2.05078|000003ffc01b3e88: SCL Logfile being closed
%
You may also want to distribute the ScTL example program, stl_example.c,
along with the appropriate makefile.xxx for the platform, so that
ScTL can be tested.