Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First step to take care of constraint into storage model
authornavarro <navarro@caraja.(none)>
Thu, 22 Mar 2012 14:35:04 +0000 (15:35 +0100)
committernavarro <navarro@caraja.(none)>
Thu, 22 Mar 2012 15:20:16 +0000 (16:20 +0100)
examples/msg/io/file.c
examples/platforms/storage.xml
src/include/surf/surf.h
src/surf/storage.c
src/surf/storage_private.h
src/surf/surf_routing.c

index 91c8ee8..87c9618 100644 (file)
@@ -15,6 +15,8 @@
  * - <b>io/file.c</b> Example with the disk resource
  */
 
  * - <b>io/file.c</b> Example with the disk resource
  */
 
+#define FILENAME "/home/user/Install/simgrid/doc/simgrid/examples/cxx/basic/basic_platform.xml"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "msg/msg.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include "msg/msg.h"
@@ -30,7 +32,7 @@ int host(int argc, char *argv[])
   m_file_t file;
   char* mount = bprintf("C:");
 
   m_file_t file;
   char* mount = bprintf("C:");
 
-  file = MSG_file_open(mount,"test.txt","rw");
+  file = MSG_file_open(mount,FILENAME,"rw");
   XBT_INFO("Host '%s' open %p",MSG_host_get_name(MSG_host_self()), file);
 
   size_t read = MSG_file_read(mount,NULL,0,0,file);
   XBT_INFO("Host '%s' open %p",MSG_host_get_name(MSG_host_self()), file);
 
   size_t read = MSG_file_read(mount,NULL,0,0,file);
index 41c2bb6..d808970 100644 (file)
 
                <storage_type id="samsung" model="RAID5" content="storage_content.txt">
                        <prop id="Bwrite" value="30" />
 
                <storage_type id="samsung" model="RAID5" content="storage_content.txt">
                        <prop id="Bwrite" value="30" />
-                       <prop id="Bread" value="80" />
+                       <prop id="Bread" value="100000000" />
                </storage_type>
 
                </storage_type>
 
-               <storage_type id="crucial" model="SSD" content="">
-                       <prop id="Bwrite" value="30" />
-                       <prop id="Bread" value="80" />
+               <storage_type id="crucial" model="SSD" content="storage_content.txt">
+                       <prop id="Bwrite" value="80" />
+                       <prop id="Bread" value="100000000" />
                </storage_type>
 
                </storage_type>
 
-               <storage_type id="wdigital" model="RAID0" content="">
-                       <prop id="Bwrite" value="30" />
-                       <prop id="Bread" value="80" />
+               <storage_type id="wdigital" model="RAID0" content="storage_content.txt">
+                       <prop id="Bwrite" value="60" />
+                       <prop id="Bread" value="100000000" />
                </storage_type>
 
                <storage id="Disk1" typeId="crucial"/>
                <storage id="Disk2" typeId="samsung"/>
                <storage id="Disk3" typeId="wdigital"/>
                </storage_type>
 
                <storage id="Disk1" typeId="crucial"/>
                <storage id="Disk2" typeId="samsung"/>
                <storage id="Disk3" typeId="wdigital"/>
+               <storage id="Disk4" typeId="wdigital"/>
 
                <host id="bob" power="1000000000">
 
                <host id="bob" power="1000000000">
-                       <mount id="Disk1" name="C:"/>
-                       <mount id="Disk2" name="D:"/>
-                       <mount id="Disk3" name="E:"/>
-                       <mount id="Disk1" name="F:"/>                   
+                       <mount id="Disk1" name="C:"/>                   
                </host>         
                
                <host id="alice" power="1000000000">
                </host>         
                
                <host id="alice" power="1000000000">
-                       <mount id="Disk1" name="C:"/>
+                       <mount id="Disk2" name="C:"/>
                </host>
 
                </host>
 
-               <storage id="Disk4" typeId="wdigital"/>
                <host id="carl" power="1000000000">             
                <host id="carl" power="1000000000">             
-                       <mount id="Disk4" name="C:"/>
-                       <mount id="Disk1" name="D:"/>                   
+                       <mount id="Disk3" name="C:"/>           
                </host>
                
                <host id="denise" power="1000000000">
                </host>
                
                <host id="denise" power="1000000000">
index 8cc569e..9ce016d 100644 (file)
@@ -224,8 +224,7 @@ typedef struct surf_storage_model_extension_public {
   surf_action_t(*read) (void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
   surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
   surf_action_t(*stat) (void *storage, int fd, void* buf);
   surf_action_t(*read) (void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
   surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
   surf_action_t(*stat) (void *storage, int fd, void* buf);
-  void* (*create_resource) (const char* id, const char* model,const char* type_id,
-      xbt_dict_t content, xbt_dict_t storage_properties);
+  void* (*create_resource) (const char* id, const char* model,const char* type_id);
 } s_surf_model_extension_storage_t;
 
      /** \brief Workstation model extension public
 } s_surf_model_extension_storage_t;
 
      /** \brief Workstation model extension public
@@ -365,6 +364,15 @@ typedef struct s_mount {
   char *name;
 } s_mount_t, *mount_t;
 
   char *name;
 } s_mount_t, *mount_t;
 
+typedef struct s_content {
+  char *user_rights;
+  char *user;
+  char *group;
+  char *date;
+  char *time;
+  int size;
+} s_content_t, *content_t;
+
 /**
  * Resource which have a metric handled by a maxmin system
  */
 /**
  * Resource which have a metric handled by a maxmin system
  */
index 28e3cfc..9c89f16 100644 (file)
@@ -31,10 +31,24 @@ typedef struct surf_storage {
 
 static void storage_action_state_set(surf_action_t action, e_surf_action_state_t state);
 static surf_action_t storage_action_sleep (void *storage, double duration);
 
 static void storage_action_state_set(surf_action_t action, e_surf_action_state_t state);
 static surf_action_t storage_action_sleep (void *storage, double duration);
+static surf_action_t storage_action_execute (void *storage, double size);
 
 static surf_action_t storage_action_open(void *storage, const char* path, const char* mode)
 {
 
 static surf_action_t storage_action_open(void *storage, const char* path, const char* mode)
 {
-  return storage_action_sleep(storage,1.0);
+  char *storage_type_id = xbt_lib_get_or_null(
+      storage_lib,
+      ((storage_t)storage)->generic_resource.name,
+      ROUTING_STORAGE_LEVEL);
+  storage_type_t storage_type = xbt_lib_get_or_null(storage_type_lib, storage_type_id,ROUTING_STORAGE_TYPE_LEVEL);
+  xbt_dict_t content_dict = storage_type->content;
+  content_t content = xbt_dict_get(content_dict,path);
+
+  double size = content->size;
+  XBT_DEBUG("Disk '%s' with type_d '%s'",((storage_t)storage)->generic_resource.name,storage_type_id);
+  XBT_INFO("\tFile '%s' size '%f'",path,size);
+
+  surf_action_t action = storage_action_execute(storage,size);
+  return action;
 }
 
 static surf_action_t storage_action_close(void *storage, surf_file_t fp)
 }
 
 static surf_action_t storage_action_close(void *storage, surf_file_t fp)
@@ -71,6 +85,9 @@ static surf_action_t storage_action_execute (void *storage, double size)
                                                    calloc but it seems to help valgrind... */
   GENERIC_LMM_ACTION(action).variable =
       lmm_variable_new(storage_maxmin_system, action, 1.0, -1.0 , 1);
                                                    calloc but it seems to help valgrind... */
   GENERIC_LMM_ACTION(action).variable =
       lmm_variable_new(storage_maxmin_system, action, 1.0, -1.0 , 1);
+
+  lmm_expand(storage_maxmin_system, STORAGE->constraint,
+             GENERIC_LMM_ACTION(action).variable, 1.0);
   XBT_OUT();
   return (surf_action_t) action;
 }
   XBT_OUT();
   return (surf_action_t) action;
 }
@@ -98,8 +115,7 @@ static surf_action_t storage_action_sleep (void *storage, double duration)
   return (surf_action_t) action;
 }
 
   return (surf_action_t) action;
 }
 
-static void* storage_create_resource(const char* id, const char* model,const char* type_id,
-                                    xbt_dict_t content, xbt_dict_t storage_properties)
+static void* storage_create_resource(const char* id, const char* model,const char* type_id)
 {
   storage_t storage = NULL;
 
 {
   storage_t storage = NULL;
 
@@ -107,18 +123,25 @@ static void* storage_create_resource(const char* id, const char* model,const cha
               "Storage '%s' declared several times in the platform file",
               id);
   storage = (storage_t) surf_resource_new(sizeof(s_storage_t),
               "Storage '%s' declared several times in the platform file",
               id);
   storage = (storage_t) surf_resource_new(sizeof(s_storage_t),
-          surf_storage_model, id,storage_properties);
+          surf_storage_model, id,NULL);
 
   storage->state_current = SURF_RESOURCE_ON;
 
 
   storage->state_current = SURF_RESOURCE_ON;
 
+  storage_type_t storage_type = xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
+  int Bread = atoi(xbt_dict_get(storage_type->properties,"Bread"));
+
+  storage->constraint =
+      lmm_constraint_new(storage_maxmin_system, storage,
+          Bread);
+
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
-  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' \n\t\tmodel '%s' \n\t\tcontent '%p'\n\t\tproperties '%p'\n",
+  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' \n\t\tmodel '%s' \n\t\tproperties '%p'\n\t\tBread '%d'\n",
       id,
       model,
       type_id,
       id,
       model,
       type_id,
-      content,
-      storage_properties);
+      storage_type->properties,
+      Bread);
 
   return storage;
 }
 
   return storage;
 }
@@ -258,9 +281,7 @@ static void parse_storage_init(sg_platf_storage_cbarg_t storage)
 
  storage_create_resource(storage->id,
      ((storage_type_t) stype)->model,
 
  storage_create_resource(storage->id,
      ((storage_type_t) stype)->model,
-     ((storage_type_t) stype)->type_id,
-     ((storage_type_t) stype)->content,
-     NULL);
+     ((storage_type_t) stype)->type_id);
 }
 
 static void parse_mstorage_init(sg_platf_mstorage_cbarg_t mstorage)
 }
 
 static void parse_mstorage_init(sg_platf_mstorage_cbarg_t mstorage)
index 1162787..39b1df0 100644 (file)
@@ -11,6 +11,7 @@
 typedef struct storage {
   s_surf_resource_t generic_resource;   /*< Structure with generic data. Needed at begin to interate with SURF */
   e_surf_resource_state_t state_current;        /*< STORAGE current state (ON or OFF) */
 typedef struct storage {
   s_surf_resource_t generic_resource;   /*< Structure with generic data. Needed at begin to interate with SURF */
   e_surf_resource_state_t state_current;        /*< STORAGE current state (ON or OFF) */
+  lmm_constraint_t constraint;
 } s_storage_t, *storage_t;
 
 typedef struct surf_action_storage {
 } s_storage_t, *storage_t;
 
 typedef struct surf_action_storage {
index 162041e..29947c5 100644 (file)
@@ -760,15 +760,6 @@ static void routing_parse_storage(sg_platf_storage_cbarg_t storage)
       (void *) xbt_strdup(storage->type_id));
 }
 
       (void *) xbt_strdup(storage->type_id));
 }
 
-typedef struct s_content {
-  char *user_rights;
-  char *user;
-  char *group;
-  char *date;
-  char *time;
-  int size;
-} s_content_t, *content_t;
-
 static void free_storage_content(void *p)
 {
   content_t content = p;
 static void free_storage_content(void *p)
 {
   content_t content = p;
@@ -839,7 +830,7 @@ static void routing_parse_storage_type(sg_platf_storage_type_cbarg_t storage_typ
   stype->content = parse_storage_content(storage_type->content);
   stype->type_id = xbt_strdup(storage_type->id);
 
   stype->content = parse_storage_content(storage_type->content);
   stype->type_id = xbt_strdup(storage_type->id);
 
-  XBT_INFO("ROUTING Create a storage type id '%s' with model '%s' content '%s' and properties '%p'",
+  XBT_DEBUG("ROUTING Create a storage type id '%s' with model '%s' content '%s' and properties '%p'",
       stype->type_id,
       stype->model,
       storage_type->content,
       stype->type_id,
       stype->model,
       storage_type->content,