//ThreadTest.h #ifndef THREADTEST_H #define THREADTEST_H #include "TThread.h" #include "TSemaphore.h" #include "TCondition.h" #include "TMutex.h" class ThreadTest{ private: Int_t nextSection; //Next section to be analyzed const Int_t N; //Number of threads const Int_t sections; //Number of sections to be analyzed const Int_t iterations; //Number of iterations Double_t *data; //Double_t[sections] TThread **thread; //TThread*[N] TSemaphore s1; //Wait to start semaphore TSemaphore s2; //Wait for completion semaphore TMutex mutex; //Mutex used in getNextSection() Int_t getNextSection(); //Thread safe read/increment nextSection void analyzeSection(Int_t); //A make-work function used by exec(void*) static void *exec(void*); //Wait for s1, analyze sections while getNextSection()>=0, post to s2 public: ThreadTest(Int_t); //Initiailize data & threads, run threads ~ThreadTest(); void run(); //Post N times to s1 and wait N times for s2, measure runtime }; #endif