comm.cpp

00001 // "comm.cpp"
00002 
00003 // (c) OPAC Team, LIFL, August 2005
00004 
00005 /* 
00006    Contact: paradiseo-help@lists.gforge.inria.fr
00007 */
00008 
00009 
00010 #include <mpi.h>
00011 
00012 #include "comm.h"
00013 #include "mess.h"
00014 #include "node.h"
00015 #include "param.h"
00016 #include "../../core/peo_debug.h"
00017 #include "../../core/runner.h"
00018 #include "send.h"
00019 #include "recv.h"
00020 #include "scheduler.h"
00021 
00022 static sem_t sem_comm_init;
00023 
00024 static Communicator * the_thread;
00025 
00026 Communicator :: Communicator (int * __argc, char * * * __argv) {
00027 
00028   the_thread = this;  
00029   initNode  (__argc, __argv);
00030   loadRMCParameters (* __argc, * __argv);  
00031   sem_post (& sem_comm_init);
00032 }
00033 
00034 void Communicator :: start () {
00035 
00036   while (true) {
00037     
00038     /* Zzz Zzz Zzz :-))) */
00039     sleep ();
00040     sendMessages ();
00041 
00042     if (! atLeastOneActiveRunner ())     
00043       break;
00044     receiveMessages ();    
00045   }
00046   waitBuffers ();  
00047   printDebugMessage ("finalizing");
00048   MPI_Finalize ();  
00049 }
00050 
00051 void initCommunication () {
00052 
00053   sem_init (& sem_comm_init, 0, 0);
00054 }
00055 
00056 void waitNodeInitialization () {
00057 
00058   sem_wait (& sem_comm_init);
00059 }
00060 
00061 void wakeUpCommunicator () {
00062 
00063   the_thread -> wakeUp ();
00064 }
00065 
00066 
00067 

Generated on Tue Jan 9 15:47:37 2007 for ParadisEO-PEO by  doxygen 1.4.7