Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
These defines are useless.
[simgrid.git] / src / surf / workstation.cpp
index e1d23b9..7274418 100644 (file)
@@ -10,8 +10,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_workstation, surf,
 
 WorkstationModelPtr surf_workstation_model = NULL;
 
-//FIXME:Faire hériter ou composer de cup et network
-
 /*************
  * CallBacks *
  *************/
@@ -129,18 +127,23 @@ double WorkstationModel::shareResources(double now){
 
   double min_by_cpu = p_cpuModel->shareResources(now);
   double min_by_net = surf_network_model->shareResources(now);
+  double min_by_sto = -1;
+  if (p_cpuModel == surf_cpu_model_pm)
+       min_by_sto = surf_storage_model->shareResources(now);
 
-  XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f",
-      this, surf_cpu_model_pm->m_name.c_str(), min_by_cpu, surf_network_model->m_name.c_str(), min_by_net);
+  XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
+      this, surf_cpu_model_pm->m_name.c_str(), min_by_cpu,
+            surf_network_model->m_name.c_str(), min_by_net,
+            surf_storage_model->m_name.c_str(), min_by_sto);
 
-  if (min_by_cpu >= 0.0 && min_by_net >= 0.0)
-    return min(min_by_cpu, min_by_net);
-  else if (min_by_cpu >= 0.0)
-    return min_by_cpu;
-  else if (min_by_net >= 0.0)
-    return min_by_net;
-  else
-    return min_by_cpu;  /* probably min_by_cpu == min_by_net == -1 */
+  double res = max(max(min_by_cpu, min_by_net), min_by_sto);
+  if (min_by_cpu >= 0.0 && min_by_cpu < res)
+       res = min_by_cpu;
+  if (min_by_net >= 0.0 && min_by_net < res)
+       res = min_by_net;
+  if (min_by_sto >= 0.0 && min_by_sto < res)
+       res = min_by_sto;
+  return res;
 }
 
 void WorkstationModel::updateActionsState(double /*now*/, double /*delta*/){
@@ -373,6 +376,29 @@ xbt_dynar_t WorkstationCLM03::getInfo( surf_file_t fd)
   return info;
 }
 
+sg_size_t WorkstationCLM03::fileTell(surf_file_t fd){
+  return fd->current_position;
+}
+
+int WorkstationCLM03::fileSeek(surf_file_t fd, sg_size_t offset, int origin){
+
+  switch (origin) {
+  case SEEK_SET:
+    fd->current_position = 0;
+       return MSG_OK;
+  case SEEK_CUR:
+       if(offset > fd->size)
+         offset = fd->size;
+       fd->current_position = offset;
+       return MSG_OK;
+  case SEEK_END:
+       fd->current_position = fd->size;
+       return MSG_OK;
+  default:
+       return MSG_TASK_CANCELED;
+  }
+}
+
 sg_size_t WorkstationCLM03::getFreeSize(const char* name)
 {
   StoragePtr st = findStorageOnMountList(name);