Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
delete the use of surf_workstation_model more
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Tue, 26 Feb 2013 15:18:43 +0000 (16:18 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Tue, 26 Feb 2013 15:22:40 +0000 (16:22 +0100)
src/simix/smx_host.c
src/simix/smx_process.c
src/simix/smx_synchro.c

index 60da45a..ef663b7 100644 (file)
@@ -546,13 +546,15 @@ void SIMIX_execution_finish(smx_action_t action)
 
 void SIMIX_post_host_execute(smx_action_t action)
 {
+  surf_model_t ws_model = get_ws_model_from_action(action);
+
   if (action->type == SIMIX_ACTION_EXECUTE && /* FIMXE: handle resource failure
                                                * for parallel tasks too */
-      surf_workstation_model->extension.workstation.get_state(action->execution.host) == SURF_RESOURCE_OFF) {
+      ws_model->extension.workstation.get_state(action->execution.host) == SURF_RESOURCE_OFF) {
     /* If the host running the action failed, notice it so that the asking
      * process can be killed if it runs on that host itself */
     action->state = SIMIX_FAILED;
-  } else if (surf_workstation_model->action_state_get(action->execution.surf_exec) == SURF_ACTION_FAILED) {
+  } else if (ws_model->action_state_get(action->execution.surf_exec) == SURF_ACTION_FAILED) {
     /* If the host running the action didn't fail, then the action was
      * canceled */
     action->state = SIMIX_CANCELED;
@@ -561,7 +563,7 @@ void SIMIX_post_host_execute(smx_action_t action)
   }
 
   if (action->execution.surf_exec) {
-    surf_workstation_model->action_unref(action->execution.surf_exec);
+    ws_model->action_unref(action->execution.surf_exec);
     action->execution.surf_exec = NULL;
   }
 
index 2e2e5de..5b02190 100644 (file)
@@ -685,9 +685,10 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
 {
   smx_action_t action;
   smx_host_t host = process->smx_host;
+  surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
 
   /* check if the host is active */
-  if (surf_workstation_model->extension.
+  if (ws_model->extension.
       workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
            sg_host_name(host));
@@ -702,9 +703,9 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
 
   action->sleep.host = host;
   action->sleep.surf_sleep =
-      surf_workstation_model->extension.workstation.sleep(host, duration);
+      ws_model->extension.workstation.sleep(host, duration);
 
-  surf_workstation_model->action_data_set(action->sleep.surf_sleep, action);
+  ws_model->action_data_set(action->sleep.surf_sleep, action);
   XBT_DEBUG("Create sleep action %p", action);
 
   return action;
@@ -715,9 +716,13 @@ void SIMIX_post_process_sleep(smx_action_t action)
   smx_simcall_t simcall;
   e_smx_state_t state;
 
+  xbt_assert(action->type == SIMIX_ACTION_SLEEP);
+  smx_host_t host = action->sleep.host;
+  surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
+
   while ((simcall = xbt_fifo_shift(action->simcalls))) {
 
-    switch(surf_workstation_model->action_state_get(action->sleep.surf_sleep)){
+    switch(ws_model->action_state_get(action->sleep.surf_sleep)){
       case SURF_ACTION_FAILED:
         simcall->issuer->context->iwannadie = 1;
         //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
@@ -732,7 +737,7 @@ void SIMIX_post_process_sleep(smx_action_t action)
         THROW_IMPOSSIBLE;
         break;
     }
-    if (surf_workstation_model->extension.
+    if (ws_model->extension.
         workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
@@ -747,6 +752,10 @@ void SIMIX_post_process_sleep(smx_action_t action)
 void SIMIX_process_sleep_destroy(smx_action_t action)
 {
   XBT_DEBUG("Destroy action %p", action);
+  xbt_assert(action->type == SIMIX_ACTION_SLEEP);
+  smx_host_t host = action->sleep.host;
+  surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
+
   if (action->sleep.surf_sleep)
     action->sleep.surf_sleep->model_obj->action_unref(action->sleep.surf_sleep);
   xbt_mallocator_release(simix_global->action_mallocator, action);
@@ -754,12 +763,21 @@ void SIMIX_process_sleep_destroy(smx_action_t action)
 
 void SIMIX_process_sleep_suspend(smx_action_t action)
 {
-  surf_workstation_model->suspend(action->sleep.surf_sleep);
+  xbt_assert(action->type == SIMIX_ACTION_SLEEP);
+  smx_host_t host = action->sleep.host;
+  surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
+
+  ws_model->suspend(action->sleep.surf_sleep);
 }
 
 void SIMIX_process_sleep_resume(smx_action_t action)
 {
-  surf_workstation_model->resume(action->sleep.surf_sleep);
+  xbt_assert(action->type == SIMIX_ACTION_SLEEP);
+  smx_host_t host = action->sleep.host;
+  surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
+  XBT_DEBUG("%p ws_model", ws_model);
+
+  ws_model->resume(action->sleep.surf_sleep);
 }
 
 /** 
index 4a3d094..58e0b85 100644 (file)
@@ -23,14 +23,16 @@ static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
 static smx_action_t SIMIX_synchro_wait(smx_host_t smx_host, double timeout)
 {
   XBT_IN("(%p, %f)",smx_host,timeout);
+  surf_model_t ws_model = surf_resource_model(smx_host, SURF_WKS_LEVEL);
+
   smx_action_t action;
   action = xbt_mallocator_get(simix_global->action_mallocator);
   action->type = SIMIX_ACTION_SYNCHRO;
   action->name = xbt_strdup("synchro");
   action->synchro.sleep = 
-    surf_workstation_model->extension.workstation.sleep(smx_host, timeout);
+    ws_model->extension.workstation.sleep(smx_host, timeout);
 
-  surf_workstation_model->action_data_set(action->synchro.sleep, action);
+  ws_model->action_data_set(action->synchro.sleep, action);
   XBT_OUT();
   return action;
 }
@@ -70,6 +72,8 @@ void SIMIX_synchro_destroy(smx_action_t action)
 {
   XBT_IN("(%p)",action);
   XBT_DEBUG("Destroying synchro %p", action);
+  xbt_assert(action->type == SIMIX_ACTION_SYNCHRO);
+
   action->synchro.sleep->model_obj->action_unref(action->synchro.sleep);
   xbt_free(action->name);
   xbt_mallocator_release(simix_global->action_mallocator, action);
@@ -79,9 +83,12 @@ void SIMIX_synchro_destroy(smx_action_t action)
 void SIMIX_post_synchro(smx_action_t action)
 {
   XBT_IN("(%p)",action);
-  if (surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_FAILED)
+  xbt_assert(action->type == SIMIX_ACTION_SYNCHRO);
+  surf_model_t ws_model = action->synchro.sleep->model_obj;
+
+  if (ws_model->action_state_get(action->synchro.sleep) == SURF_ACTION_FAILED)
     action->state = SIMIX_FAILED;
-  else if(surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_DONE)
+  else if(ws_model->action_state_get(action->synchro.sleep) == SURF_ACTION_DONE)
     action->state = SIMIX_SRC_TIMEOUT;
 
   SIMIX_synchro_finish(action);