Simplethreads Instructions

These instructions are adapted from a CSE 451 project at the University of Washington.

To start, copy ~cs537-2/public/code/simplethreads-1.10.tar.gz to your working directory. In your working directory, unzip the file with tar -xvzf simplethreads-1.10.tar.gz. Simplethreads contains a fair amount of files; here are the ones you should know about:

lib/ The simplethreads thread library itself
lib/sthread_user.c Your part 1-2 implementation goes here
lib/sthread_ctx.{c,h} Support for creating new stacks and switching between them
lib/sthread_switch_i386.h Assembly functions for saving registers and switching stacks
lib/sthread_queue.h A simple queue which you can use for part 1.
include/ Look at sthread.h, the public API to the library
test/ Library test programs, add your tests here
web/ The webserver for part 4

The procedure to build simplethreads is similar to that of many UNIX applications. First, run ./configure to determine the build parameters appropriate for the machine you are using and to generate Makefiles with these parameters. Simplethreads can be configured to use either kernel-level threads or the user-level threads that you'll implement. In both cases simplethreads provides the same interface; this way you can run the test programs and your solution with either implementation. If you run configure with the argument --with-pthreads the simplethreads library you build will use kernel-level threads, default is user-level threads. To switch back and forth, re-run configure and then run make clean.

Type make to build the package. This command will also recompile and source files after you have made changes to them. You do not have to re-run configure if you only change source files. In summary, the steps are:
  1. Copy ~cs537-2/public/code/simplethreads-1.10.tar.gz to your working directory
  2. tar -xvzf simplethreads-1.10.tar.gz
  3. cd simplethreads-1.10
  4. ./configure [--with-pthreads]
  5. make
  6. make check to run the programs in test/
To add a source file:
  1. Edit the Makefile.am in the directory containing the new file, adding it to the _SOURCES for the library/executable the file is a part of. E.g., to add a new file in the lib/ directory that will become part of the sthread library, add it to the libsthread_la_SOURCES line.
  2. The edited Makefile.am has to be processed by the automake tool before it can be used by make. From the top-level directory run autoreconf
  3. Also from the top-level directory, run ./configure.
  4. Your file is now added; run make as usual to build it.
To add a new test program:
  1. Edit test/Makefile.am. Add your program to the list bin_PROGRAMS. Create new variables prog_SOURCES and prog_LDADD following the examples of the programs already there. E.g., if the new program is named test-klaus, add
    test_klaus_SOURCES = test-klaus.c other sources listed here
    test_klaus_LDADD = $(ldadd)
  2. Follow steps 2-4 above
To add a new arbitrary file:
  1. Edit the Makefile.am in the directory containing your file. Add your file to the list EXTRA_DIST (see top-level Makefile.am for an example).
  2. Follow steps 2-4 above