Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prepare the model_private callbacks of ws
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Mon, 18 Feb 2013 17:52:59 +0000 (18:52 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Mon, 18 Feb 2013 17:57:15 +0000 (18:57 +0100)
src/surf/workstation.c
src/surf/workstation_private.h

index 33a2438..9cf1106 100644 (file)
@@ -37,11 +37,6 @@ static void workstation_new(sg_platf_host_cbarg_t host)
   __init_workstation_CLM03(workstation, host->id, surf_workstation_model);
 }
 
-static int ws_resource_used(void *resource_id)
-{
-  THROW_IMPOSSIBLE;             /* This model does not implement parallel tasks */
-  return -1;
-}
 
 static void ws_parallel_action_cancel(surf_action_t action)
 {
@@ -96,24 +91,48 @@ static void ws_action_state_set(surf_action_t action,
   return;
 }
 
-static double ws_share_resources(surf_model_t workstation_model, double now)
+
+/* -- The callback functions at model_private -- */
+/* These callbacks are also used for the vm workstation model. */
+int ws_resource_used(void *resource_id)
 {
-// invoke share_resources on CPU and network (layer 0)
-  return -1.0;
+  /* This model does not implement parallel tasks */
+  THROW_IMPOSSIBLE;
+  return -1;
 }
 
-static void ws_update_actions_state(surf_model_t workstation_model, double now, double delta)
+double ws_share_resources(surf_model_t workstation_model, double now)
+{
+  /* Invoke the share_resources() callback of the physical cpu model object and
+   * the network model objects. */
+  surf_model_t cpu_model = workstation_model->extension.workstation.cpu_model;
+  surf_model_t net_model = surf_network_model;
+
+  double min_by_cpu = cpu_model->model_private->share_resources(cpu_model, now);
+  double min_by_net = net_model->model_private->share_resources(net_model, now);
+
+  return min(min_by_cpu, min_by_net);
+}
+
+void ws_update_actions_state(surf_model_t workstation_model, double now, double delta)
 {
   return;
 }
 
-static void ws_update_resource_state(void *id,
-                                     tmgr_trace_event_t event_type,
-                                     double value, double date)
+void ws_update_resource_state(void *id, tmgr_trace_event_t event_type, double value, double date)
 {
-  THROW_IMPOSSIBLE;             /* This model does not implement parallel tasks */
+  /* This model does not implement parallel tasks */
+  THROW_IMPOSSIBLE;
 }
 
+void ws_finalize(surf_model_t workstation_model)
+{
+  surf_model_exit(workstation_model);
+  workstation_model = NULL;
+}
+
+
+
 static surf_action_t ws_execute(void *workstation, double size)
 {
   surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
@@ -299,12 +318,6 @@ static int ws_link_shared(const void *link)
   return surf_network_model->extension.network.link_shared(link);
 }
 
-static void ws_finalize(surf_model_t workstation_model)
-{
-  surf_model_exit(workstation_model);
-  workstation_model = NULL;
-}
-
 static xbt_dict_t ws_get_properties(const void *ws)
 {
   return surf_resource_properties(surf_cpu_resource_priv(ws));
index d8a706e..7f157f2 100644 (file)
@@ -14,4 +14,10 @@ typedef struct workstation_CLM03 {
 
 void __init_ws(workstation_CLM03_t ws,  const char *id, int level);
 
+int ws_resource_used(void *resource_id);
+double ws_share_resources(surf_model_t workstation_model, double now);
+void ws_update_actions_state(surf_model_t workstation_model, double now, double delta);
+void ws_update_resource_state(void *id, tmgr_trace_event_t event_type, double value, double date);
+void ws_finalize(surf_model_t workstation_model);
+
 #endif /* WS_PRIVATE_H_ */