#include <PsnBarrier.h>
Public Methods | |
| PsnBarrier (const int nbproc) | |
| constructor | |
| ~PsnBarrier () | |
| Destructor. | |
| void | Sync () |
| Sync wait for all threads to call this synchronisation barrier. | |
Protected Attributes | |
| int | _count |
| number of threads having called sync | |
| int | _nbThreads |
| number of threads waited for | |
| pthread_mutex_t | _mylock |
| pthread_cond_t | _cond |
Definition at line 33 of file PsnBarrier.h.
|
|
constructor
Definition at line 25 of file PsnBarrier.cxx. References _cond, and _mylock.
00025 : 00026 _count ( 1 ), 00027 _nbThreads ( nbProc ) 00028 { 00029 #ifdef _SPROC 00030 if (_handle == NULL) 00031 { 00032 perror("PsnBarrier :: constructeur :: Impossible de créer le usptr nécessaire"); 00033 exit(1); 00034 } 00035 _barriere = new_barrier( _handle ); 00036 if(_barriere == NULL) 00037 { 00038 perror("PsnBarrier :: constructeur :: impossible de créer une nouvelle barrière"); 00039 exit(1); 00040 } 00041 #else 00042 pthread_mutex_init ( &_mylock , NULL ) ; 00043 pthread_cond_init ( &_cond , NULL ) ; 00044 #endif 00045 } |
|
|
Destructor.
Definition at line 47 of file PsnBarrier.cxx. References _cond, and _mylock.
|
|
|
Sync wait for all threads to call this synchronisation barrier.
Definition at line 57 of file PsnBarrier.cxx. References _cond, _count, _mylock, and _nbThreads. Referenced by PsnMultiThreadedScheduler::run(), PsnMultiThreadedBenchmarkingScheduler::run(), PsnMultiThreadedBenchedScheduler::run(), PsnMultiThreadedScheduler::runStep(), and PsnMultiThreadedBenchmarkingScheduler::runStep().
00057 {
00058 #ifdef _SPROC
00059 barrier(_barriere,_nbThreads);
00060 #ifdef _DEBUG
00061 cout<<"une syncronisation"<<endl;
00062 #endif
00063 #else
00064 #ifdef _DEBUGLOCK
00065 cout<<"PsnBarrier::"<<this<<"::"<<pthread_self()<<"::Sync()";
00066 #endif
00067 pthread_mutex_lock ( &_mylock ) ;
00068 if (_count < _nbThreads)
00069 {
00070 _count++;
00071 pthread_cond_wait ( &_cond,
00072 &_mylock ) ;
00073
00074 pthread_mutex_unlock ( &_mylock ) ;
00075 }
00076 else
00077 {
00078 pthread_mutex_unlock ( &_mylock ) ;
00079 _count = 1;
00080 pthread_cond_broadcast ( &_cond ) ;
00081 }
00082 #ifdef _DEBUGLOCK
00083 cerr<<" passée par "<<pthread_self()<<endl;
00084 #endif
00085 #endif
00086 }
|
|
|
Definition at line 67 of file PsnBarrier.h. Referenced by PsnBarrier(), Sync(), and ~PsnBarrier(). |
|
|
number of threads having called sync
Definition at line 56 of file PsnBarrier.h. Referenced by Sync(). |
|
|
Definition at line 66 of file PsnBarrier.h. Referenced by PsnBarrier(), Sync(), and ~PsnBarrier(). |
|
|
number of threads waited for
Definition at line 59 of file PsnBarrier.h. Referenced by Sync(). |
| Documentation generated on Mon Nov 25 15:25:52 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |