University of Heidelberg

This is an archive of our old website and not updated anymore

The current website can be found at conan.iwr.uni-heidelberg.de

Sorry, this page is only available in german.

ThreadTools Download

threadtools.zip
In the Linux console unpack with

unzip threadtools.zip
.

Hints to the Threadtools

The Threadtools provide tools for thread handling, classes, that pack the PThread functionality and some application examples. The most important class is

BasicThread.
It substitutes the class
ActiveObject
from the lecture.

There are similar object oriented implementations for the Threads as the BasicThreads/ActiveObjects from the lecture, e.g. by Nokia/Trolltech there is a QT based variant.

The most important classes

  • BasicThread The ActiveObjects from the lecture.
  • Mutex Wraps a PThread mutex.
  • Condition Wraps a PThread condition.
  • Flag A flag, that urges the waiting on another process.
  • Barrier A barrier for a fixed number of processen.
  • Semaphore A semaphore build up from a condition.

Some additional examples

  • example.cc Some examples for application of ThreadTools.
  • peterson.cc Implementation of the Peterson algorithm with BasicThreads.

Building your own applications

For using the ThreadTools you have to include the file tt.hh. For compilation of your own applications these have to be added to the already present Makefile:

  • Have a look at the other targets, e.g. PETERSON_APPL. This example implements the Peterson algorithm with BasicThreads.
  • First the application has to be defined and has to be added to the target all:
    
    MYAPPL          = myapp
    MYAPPL_OBJECTS  = myapp.o basicthread.o semaphore.o condition.o mutex.o barrier.o flag.o
    ...
    all : ... ${MYAPPL}
            
  • The application will probably have some dependencies from other parts:
    
    ${MYAPPL} : ${MYAPPL_OBJECTS} Makefile
        ${LINK} ${LLDFLAGS} -o ${EXAMPLE_APPL} ${EXAMPLE_OBJECTS} ${LIBS}
            
  • Caution: For indentation in Makefiles never spaces may be used, but only tabs!
Now the application can be compiled by the command make.


Revision: 2242     Last changed: 2016-10-07 11