git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@794 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
atantar 2007-11-20 13:40:15 +00:00
commit aecc5ba8fc
35 changed files with 498 additions and 262 deletions

View file

@ -93,5 +93,9 @@ void Communicable :: resume () {
sem_post (& sem_stop);
}
void initCommunicableEnv () {
key_to_comm.resize (1);
comm_to_key.clear ();
Communicable :: num_comm = 0;
}

View file

@ -39,6 +39,7 @@
#include <semaphore.h>
typedef unsigned COMM_ID;
class Communicable {
@ -56,7 +57,11 @@ public :
void stop (); /* It suspends the current process */
void resume (); /* It resumes ___________ */
public :
static unsigned num_comm;
protected :
COMM_ID key;
@ -64,10 +69,10 @@ protected :
sem_t sem_lock;
sem_t sem_stop;
static unsigned num_comm;
};
extern void initCommunicableEnv ();
extern Communicable * getCommunicable (COMM_ID __key);
//extern COMM_ID getKey (const Communicable * __comm);

View file

@ -41,6 +41,7 @@
#include "messaging.h"
template <class EOT> void pack (const eoPop <EOT> & __pop) {
pack ((unsigned) __pop.size ());
@ -57,4 +58,5 @@ template <class EOT> void unpack (eoPop <EOT> & __pop) {
for (unsigned i = 0; i < n; i ++)
unpack (__pop [i]);
}
#endif

View file

@ -41,6 +41,7 @@
#include "messaging.h"
template <class F, class T> void pack (const eoVector <F, T> & __v) {
pack (__v.fitness ()) ;

View file

@ -83,7 +83,6 @@ template <class U, class V> void pack (const std :: pair <U, V> & __pair) {
}
//
/* Char */
extern void unpack (char & __c);

View file

@ -78,24 +78,28 @@ void endDebugging () {
for (unsigned i = 0; i < files.size (); i ++)
if (files [i] != stdout)
fclose (files [i]);
files.clear();
}
void printDebugMessage (const char * __mess) {
return;
if (debug) {
char buff [MAX_BUFF_SIZE];
char localTime [MAX_BUFF_SIZE];
time_t t = time (0);
/* Date */
sprintf (buff, "[%s][%s: ", host, ctime (& t));
* strchr (buff, '\n') = ']';
strcpy( localTime, ctime (& t) );
localTime[ strlen( localTime )-1 ] = ']';
sprintf (buff, "[%s][%s: ", host, localTime );
for (unsigned i = 0; i < files.size (); i ++)
fprintf (files [i], buff);
/* Message */
sprintf (buff, "%s", __mess);
for (unsigned i = 0; i < files.size (); i ++) {
fputs (buff, files [i]);
fputs ("\n", files [i]);

View file

@ -39,7 +39,6 @@
#include "runner.h"
#include "rmc.h"
void peo :: finalize () {
printDebugMessage ("waiting for the termination of all threads");

View file

@ -38,7 +38,7 @@
#define __peo_finalize_h
namespace peo {
extern void finalize ();
}

View file

@ -41,6 +41,27 @@
#include "peo_debug.h"
#include "rmc.h"
extern void initCommunicableEnv ();
extern void initThreadsEnv ();
extern void initReactiveThreadsEnv ();
extern void initRunnersEnv ();
extern void initWorkersEnv ();
static void initExecutionEnv() {
initCommunicableEnv ();
initThreadsEnv ();
initReactiveThreadsEnv ();
initRunnersEnv ();
initWorkersEnv ();
}
namespace peo {
int * argc;
@ -52,13 +73,16 @@ namespace peo {
argc = & __argc;
argv = & __argv;
/* Initializing the execution environment */
initExecutionEnv();
/* Initializing the the Resource Management and Communication */
initRMC (__argc, __argv);
/* Loading the common parameters */
loadParameters (__argc, __argv);
/* */
initDebugging ();
}

View file

@ -40,7 +40,7 @@
#include "runner.h"
void peo :: run () {
startRunners ();
runRMC ();

View file

@ -56,9 +56,18 @@ void ReactiveThread :: wakeUp () {
sem_post (& sem);
}
void initReactiveThreadsEnv () {
the_end = false;
reac_threads.clear ();
}
void stopReactiveThreads () {
the_end = true;
for (unsigned i = 0; i < reac_threads.size (); i ++)
reac_threads [i] -> wakeUp ();
reac_threads [i] -> wakeUp ();
reac_threads.clear ();
}
bool theEnd () { return the_end; }

View file

@ -41,6 +41,7 @@
#include "thread.h"
class ReactiveThread : public Thread {
public:
@ -51,13 +52,16 @@ public:
void sleep ();
void wakeUp ();
private:
sem_t sem;
};
extern void initReactiveThreadsEnv ();
extern void stopReactiveThreads ();
#endif /*THREAD_H_*/
extern bool theEnd ();
#endif /*REAC_THREAD_H_*/

View file

@ -44,6 +44,9 @@
#include "../rmc/mpi/mess.h"
#include "../rmc/mpi/tags.h"
#include "../rmc/mpi/node.h"
#include "../rmc/mpi/schema.h"
static std :: vector <pthread_t *> ll_threads; /* Low-level runner threads */
@ -63,8 +66,11 @@ extern int getNumberOfNodes ();
Runner :: Runner () {
exec_id = 0;
def_id = ++ num_def_runners;
the_runners.push_back (this);
sem_init (& sem_start, 0, 0);
sem_init (& sem_cntxt, 0, 0);
}
@ -76,7 +82,12 @@ RUNNER_ID Runner :: getDefinitionID () {
RUNNER_ID Runner :: getExecutionID () {
return def_id;
return exec_id;
}
void Runner :: setExecutionID (const RUNNER_ID& execution_id) {
exec_id = execution_id;
}
Runner * getRunner (RUNNER_ID __key) {
@ -101,7 +112,6 @@ void unpackExecutionContext () {
void initializeContext () {
initMessage ();
packExecutionContext ();
sendMessageToAll (EXECUTION_CONTEXT_TAG);
@ -121,6 +131,13 @@ void initializeContext () {
cleanBuffers ();
// setting up the execution IDs
for (unsigned i = 0; i < the_runners.size (); i ++)
the_runners [i] -> setExecutionID ( my_node -> execution_id_run[ i ] );
// synchronizing - all the nodes have to finish initializing
// the context before actually executing the runners
synchronizeNodes ();
for (unsigned i = 0; i < the_runners.size (); i ++)
@ -163,6 +180,7 @@ void startRunners () {
void joinRunners () {
joinThreads (ll_threads);
the_runners.clear();
}
bool atLeastOneActiveRunner () {
@ -201,3 +219,13 @@ void unpackTerminationOfRunner () {
stopReactiveThreads ();
}
}
void initRunnersEnv () {
ll_threads.clear ();
the_runners.clear ();
num_def_runners = 0;
num_local_exec_runners = 0;
num_exec_runners = 0;
}

View file

@ -56,6 +56,8 @@ public :
RUNNER_ID getExecutionID ();
void setExecutionID (const RUNNER_ID& execution_id);
bool isAssignedLocally ();
void waitStarting ();
@ -80,9 +82,12 @@ private :
sem_t sem_cntxt;
unsigned def_id;
unsigned exec_id;
};
extern void initRunnersEnv ();
extern Runner * getRunner (RUNNER_ID __key);
extern void initializeContext ();
@ -97,5 +102,4 @@ extern unsigned numberOfActiveRunners ();
extern void unpackTerminationOfRunner ();
#endif

View file

@ -51,9 +51,8 @@ Service * getService (SERVICE_ID __key) {
return dynamic_cast <Service *> (getCommunicable (__key));
}
void Service :: notifySendingData () {
void Service :: notifySendingData () { }
}
void Service :: notifySendingResourceRequest () {
num_sent_rr --;
@ -61,26 +60,14 @@ void Service :: notifySendingResourceRequest () {
notifySendingAllResourceRequests ();
}
void Service :: notifySendingAllResourceRequests () {
void Service :: notifySendingAllResourceRequests () { }
}
void Service :: packData () {}
void Service :: packData () {
void Service :: unpackData () {}
}
void Service :: execute () {}
void Service :: unpackData () {
void Service :: packResult () {}
}
void Service :: execute () {
}
void Service :: packResult () {
}
void Service :: unpackResult () {
}
void Service :: unpackResult () {}

View file

@ -40,6 +40,7 @@
#include "communicable.h"
#include "thread.h"
typedef unsigned SERVICE_ID;
class Service : public Communicable {

View file

@ -73,6 +73,12 @@ void Thread :: setPassive () {
}
}
void initThreadsEnv () {
threads.clear ();
num_act = 0;
}
bool atLeastOneActiveThread () {
return num_act;
@ -95,6 +101,9 @@ void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads
void joinThreads (std :: vector <pthread_t *> & __threads) {
for (unsigned i = 0; i < __threads.size (); i ++)
pthread_join (* __threads [i], 0);
for (unsigned i = 0; i < __threads.size (); i ++) {
pthread_join (* __threads [i], 0);
delete __threads [i];
}
__threads.clear();
}

View file

@ -39,8 +39,8 @@
#include <vector>
/* A high-level thread */
/* A high-level thread */
class Thread {
public:
@ -63,6 +63,8 @@ private :
bool act;
};
extern void initThreadsEnv ();
extern void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads);
extern void joinThreads (std :: vector <pthread_t *> & __ll_threads);