Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
network actions should be suspendable too. In fact it seems to me that it is the...
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 14 Jan 2005 19:54:41 +0000 (19:54 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 14 Jan 2005 19:54:41 +0000 (19:54 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@755 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/surf/surf.h
src/surf/network.c
src/surf/network_private.h
src/surf/workstation.c
src/surf/workstation_KCCFLN05.c

index fc6df9f..6223c5e 100644 (file)
@@ -115,6 +115,9 @@ typedef struct surf_network_resource_extension_private
 *surf_network_resource_extension_private_t;
 typedef struct surf_network_resource_extension_public {
   surf_action_t(*communicate) (void *src, void *dst, double size);
 *surf_network_resource_extension_private_t;
 typedef struct surf_network_resource_extension_public {
   surf_action_t(*communicate) (void *src, void *dst, double size);
+  void (*suspend) (surf_action_t action);
+  void (*resume) (surf_action_t action);
+  int (*is_suspended) (surf_action_t action);
 } s_surf_network_resource_extension_public_t,
     *surf_network_resource_extension_public_t;
 
 } s_surf_network_resource_extension_public_t,
     *surf_network_resource_extension_public_t;
 
index f5712f1..56b4dd8 100644 (file)
@@ -275,7 +275,7 @@ static void update_actions_state(double now, double delta)
        deltap -= action->latency;
        action->latency = 0.0;
       }
        deltap -= action->latency;
        action->latency = 0.0;
       }
-      if (action->latency == 0.0
+      if ((action->latency == 0.0) && !(action->suspended)
        lmm_update_variable_weight(maxmin_system, action->variable, 1.0);
     }
     action->generic_action.remains -=
        lmm_update_variable_weight(maxmin_system, action->variable, 1.0);
     }
     action->generic_action.remains -=
@@ -400,6 +400,25 @@ static surf_action_t communicate(void *src, void *dst, double size)
   return (surf_action_t) action;
 }
 
   return (surf_action_t) action;
 }
 
+static void action_suspend(surf_action_t action)
+{
+  ((surf_action_network_t) action)->suspended = 1;
+  lmm_update_variable_weight(maxmin_system,
+                            ((surf_action_network_t) action)->variable, 0.0);
+}
+
+static void action_resume(surf_action_t action)
+{
+  lmm_update_variable_weight(maxmin_system,
+                            ((surf_action_network_t) action)->variable, 1.0);
+  ((surf_action_network_t) action)->suspended = 0;
+}
+
+static int action_is_suspended(surf_action_t action)
+{
+  return ((surf_action_network_t) action)->suspended;
+}
+
 static void finalize(void)
 {
   int i,j;
 static void finalize(void)
 {
   int i,j;
@@ -475,6 +494,9 @@ static void surf_network_resource_init_internal(void)
   surf_network_resource->common_private->finalize = finalize;
 
   surf_network_resource->extension_public->communicate = communicate;
   surf_network_resource->common_private->finalize = finalize;
 
   surf_network_resource->extension_public->communicate = communicate;
+  surf_network_resource->extension_public->suspend = action_suspend;
+  surf_network_resource->extension_public->resume = action_resume;
+  surf_network_resource->extension_public->is_suspended = action_is_suspended;
 
   network_link_set = xbt_dict_new();
   network_card_set = xbt_dict_new();
 
   network_link_set = xbt_dict_new();
   network_card_set = xbt_dict_new();
index 4556692..898857b 100644 (file)
@@ -42,6 +42,7 @@ typedef struct surf_action_network {
   double latency;
   double lat_current;
   lmm_variable_t variable;
   double latency;
   double lat_current;
   lmm_variable_t variable;
+  int suspended;
   network_card_t src;
   network_card_t dst;
 } s_surf_action_network_t, *surf_action_network_t;
   network_card_t src;
   network_card_t dst;
 } s_surf_action_network_t, *surf_action_network_t;
index 26d4602..4a5cb42 100644 (file)
@@ -127,24 +127,26 @@ static surf_action_t action_sleep(void *workstation, double duration)
 
 static void action_suspend(surf_action_t action)
 {
 
 static void action_suspend(surf_action_t action)
 {
-  xbt_assert0(action->resource_type ==
-             ((surf_resource_t) surf_cpu_resource),
-             "Resource type mismatch");
-  surf_cpu_resource->extension_public->suspend(action);
+  if(action->resource_type==(surf_resource_t)surf_network_resource) 
+    surf_network_resource->extension_public->suspend(action);
+  else if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
+    surf_cpu_resource->extension_public->suspend(action);
+  else DIE_IMPOSSIBLE;
 }
 
 static void action_resume(surf_action_t action)
 {
 }
 
 static void action_resume(surf_action_t action)
 {
-  xbt_assert0(action->resource_type ==
-             ((surf_resource_t) surf_cpu_resource),
-             "Resource type mismatch");
-  surf_cpu_resource->extension_public->resume(action);
+  if(action->resource_type==(surf_resource_t)surf_network_resource)
+    surf_network_resource->extension_public->resume(action);
+  else if(action->resource_type==(surf_resource_t)surf_cpu_resource)
+    surf_cpu_resource->extension_public->resume(action);
+  else DIE_IMPOSSIBLE;
 }
 
 static int action_is_suspended(surf_action_t action)
 {
   if(action->resource_type==(surf_resource_t)surf_network_resource) 
 }
 
 static int action_is_suspended(surf_action_t action)
 {
   if(action->resource_type==(surf_resource_t)surf_network_resource) 
-    return 0;
+    return surf_network_resource->extension_public->is_suspended(action);
   if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
     return surf_cpu_resource->extension_public->is_suspended(action);
   DIE_IMPOSSIBLE;
   if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
     return surf_cpu_resource->extension_public->is_suspended(action);
   DIE_IMPOSSIBLE;
index e88efa8..96a4655 100644 (file)
@@ -602,19 +602,33 @@ static surf_action_t execute_KCCFLN05(void *cpu, double size)
 
 static void cpu_KCCFLN05_action_suspend(surf_action_t action)
 {
 
 static void cpu_KCCFLN05_action_suspend(surf_action_t action)
 {
-  lmm_update_variable_weight(maxmin_system_cpu_KCCFLN05,
-                            ((surf_action_cpu_KCCFLN05_t) action)->variable, 0.0);
+  if(action->resource_type==(surf_resource_t)surf_network_resource) 
+    lmm_update_variable_weight(maxmin_system_network_KCCFLN05,
+                              ((surf_action_network_KCCFLN05_t) action)->variable, 0.0);
+  else if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
+    lmm_update_variable_weight(maxmin_system_cpu_KCCFLN05,
+                              ((surf_action_cpu_KCCFLN05_t) action)->variable, 0.0);
+  else DIE_IMPOSSIBLE;
 }
 
 static void cpu_KCCFLN05_action_resume(surf_action_t action)
 {
 }
 
 static void cpu_KCCFLN05_action_resume(surf_action_t action)
 {
-  lmm_update_variable_weight(maxmin_system_cpu_KCCFLN05,
-                            ((surf_action_cpu_KCCFLN05_t) action)->variable, 1.0);
+  if(action->resource_type==(surf_resource_t)surf_network_resource) 
+    lmm_update_variable_weight(maxmin_system_network_KCCFLN05,
+                              ((surf_action_network_KCCFLN05_t) action)->variable, 1.0);
+  else if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
+    lmm_update_variable_weight(maxmin_system_cpu_KCCFLN05,
+                              ((surf_action_cpu_KCCFLN05_t) action)->variable, 1.0);
+  else DIE_IMPOSSIBLE;
 }
 
 static int cpu_KCCFLN05_action_is_suspended(surf_action_t action)
 {
 }
 
 static int cpu_KCCFLN05_action_is_suspended(surf_action_t action)
 {
-  return (lmm_get_variable_weight(((surf_action_cpu_KCCFLN05_t) action)->variable) == 0.0);
+  if(action->resource_type==(surf_resource_t)surf_network_resource) 
+    return (lmm_get_variable_weight(((surf_action_cpu_KCCFLN05_t) action)->variable) == 0.0);
+  if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
+    return (lmm_get_variable_weight(((surf_action_network_KCCFLN05_t) action)->variable) == 0.0);
+  DIE_IMPOSSIBLE;
 }
 
 /************* workstation ************/
 }
 
 /************* workstation ************/