Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 17 Dec 2004 21:29:11 +0000 (21:29 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 17 Dec 2004 21:29:11 +0000 (21:29 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@679 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/msg/msg.h
src/msg/gos.c
src/msg/m_process.c
src/msg/private.h
src/msg/task.c

index 98d685d..a36cefd 100644 (file)
@@ -77,7 +77,7 @@ MSG_error_t MSG_task_put(m_task_t task, m_host_t dest,
                         m_channel_t channel);
 MSG_error_t MSG_task_execute(m_task_t task);
 int MSG_task_Iprobe(m_channel_t channel);
-void MSG_process_sleep(long double nb_sec);
+MSG_error_t MSG_process_sleep(long double nb_sec);
 MSG_error_t MSG_get_errno(void);
 
 /************************** Deprecated ***************************************/
index ccdd24a..d167c7a 100644 (file)
@@ -9,7 +9,7 @@
 #include"xbt/sysdep.h"
 #include "xbt/error.h"
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gos, msg,
-                               "Logging specific to MSG (process)");
+                               "Logging specific to MSG (gos)");
 
 /** \ingroup msg_gos_functions
  * \brief This function is now deprecated and useless. Please stop using it.
index d3e1dbd..15ec2c9 100644 (file)
@@ -49,8 +49,6 @@ m_process_t MSG_process_create(const char *name,
   simdata->PID = PID++;
   simdata->host = host;
   simdata->waiting_task = NULL;
-  simdata->put_host = NULL;
-  simdata->put_channel = -1;
   simdata->argc = -1;
   simdata->argv = NULL;
   simdata->context = xbt_context_new(code, simdata->argc, simdata->argv);
index ad8c31e..6e485d4 100644 (file)
 
 /**************** datatypes **********************************/
 
-typedef enum {
-  HOST_DOWN = 0,
-  HOST_ALIVE = 1
-} m_host_state_t;
-
 typedef struct simdata_host {
   void *host;                  /* SURF modeling */
   xbt_fifo_t *mbox;            /* array of FIFOs used as a mailboxes  */
   m_process_t *sleeping;       /* array of process used to know whether a local process is
                                   waiting for a communication on a channel */
-  m_host_state_t state;
   xbt_fifo_t process_list;
 } s_simdata_host_t;
 
@@ -40,6 +34,8 @@ typedef struct simdata_task {
   double message_size;         /* Data size  */
   double computation_amount;   /* Computation size  */
   xbt_dynar_t sleeping;                /* process to wake-up */
+  m_process_t sender;
+  int using;
 } s_simdata_task_t;
 
 /******************************* Process *************************************/
@@ -50,8 +46,6 @@ typedef struct simdata_process {
   int PID;                     /* used for debugging purposes */
   int PPID;                    /* The parent PID */
   m_task_t waiting_task;        
-  m_host_t put_host;            /* used for debugging purposes */
-  int put_channel;              /* used for debugging purposes */
   int argc;                     /* arguments number if any */
   char **argv;                  /* arguments table if any */
   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
@@ -66,7 +60,7 @@ typedef struct MSG_Global {
   int max_channel;
   m_process_t current_process;
   xbt_dict_t registered_functions;
-} s_MSG_global_t, *MSG_Global_t;
+} s_MSG_Global_t, *MSG_Global_t;
 
 extern MSG_Global_t msg_global;
 
@@ -77,7 +71,9 @@ extern MSG_Global_t msg_global;
 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
 
-#define CHECK_HOST()  xbt_assert0((MSG_host_self()->simdata->state==HOST_ALIVE),"Host failed, you cannot call this function.")
+#define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
+                                 get_state(MSG_host_self()->simdata->host)==SURF_CPU_ON,\
+                                  "Host failed, you cannot call this function.")
 
 m_host_t __MSG_host_create(const char *name, void *workstation,
                           void *data);
index 552c95a..d0f6001 100644 (file)
@@ -48,6 +48,8 @@ m_task_t MSG_task_create(const char *name, long double compute_duration,
   simdata->sleeping = xbt_dynar_new(sizeof(m_process_t),NULL);
   simdata->computation_amount = compute_duration;
   simdata->message_size = message_size;
+  simdata->using = 1;
+  simdata->sender = NULL;
 
   return task;
 }
@@ -81,6 +83,9 @@ MSG_error_t MSG_task_destroy(m_task_t task)
   xbt_assert0((xbt_dynar_length(task->simdata->sleeping)==0), 
              "Task still used. Cannot destroy it now!");
 
+  task->simdata->using--;
+  if(task->simdata->using>0) return MSG_OK;
+
   if(task->name) xbt_free(task->name);
 
   xbt_dynar_free(&(task->simdata->sleeping));