Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
revise I/O examples doc
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 17 Apr 2016 16:07:54 +0000 (18:07 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 17 Apr 2016 16:07:54 +0000 (18:07 +0200)
 + merge file and file-unlink, the latter was redundant but for one
function

doc/Doxyfile.in
examples/msg/CMakeLists.txt
examples/msg/io-file-unlink/io-file-unlink.c [deleted file]
examples/msg/io-file-unlink/io-file-unlink.tesh [deleted file]
examples/msg/io-file/io-file.c
examples/msg/io-file/io-file.tesh
examples/msg/io-remote/io-remote.c
examples/msg/io-storage/io-storage.c

index 5013888..cc536f5 100644 (file)
@@ -714,8 +714,9 @@ INPUT +=                 @CMAKE_HOME_DIRECTORY@/examples/msg/app-pingpong/app-pi
                          @CMAKE_HOME_DIRECTORY@/examples/msg/trace-link-user-variables/trace-link-user-variables.c \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/network-ns3/network-ns3.c \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/trace-link-user-variables/trace-link-user-variables.c \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/network-ns3/network-ns3.c \
-                         @CMAKE_HOME_DIRECTORY@/examples/msg/io \
-                         @CMAKE_HOME_DIRECTORY@/examples/msg/gpu \
+                         @CMAKE_HOME_DIRECTORY@/examples/msg/io-storage/io-storage.c \
+                         @CMAKE_HOME_DIRECTORY@/examples/msg/io-file/io-file.c \
+                         @CMAKE_HOME_DIRECTORY@/examples/msg/io-file/io-remote.c \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/actions \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/pmm \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/chord\
                          @CMAKE_HOME_DIRECTORY@/examples/msg/actions \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/pmm \
                          @CMAKE_HOME_DIRECTORY@/examples/msg/chord\
index 2798344..e5077ca 100644 (file)
@@ -1,7 +1,7 @@
 foreach(x actions-comm actions-storage app-masterworker app-pingpong app-pmm app-token-ring async-wait async-waitall 
           async-waitany cloud-capping cloud-masterworker cloud-migration cloud-multicore cloud-simple cloud-two-tasks
           dht-chord dht-pastry exception energy-consumption energy-onoff energy-pstate energy-ptask energy-vm failures 
 foreach(x actions-comm actions-storage app-masterworker app-pingpong app-pmm app-token-ring async-wait async-waitall 
           async-waitany cloud-capping cloud-masterworker cloud-migration cloud-multicore cloud-simple cloud-two-tasks
           dht-chord dht-pastry exception energy-consumption energy-onoff energy-pstate energy-ptask energy-vm failures 
-          io-file io-file-unlink io-remote io-storage task-priority process-kill process-migration process-suspend 
+          io-file io-remote io-storage task-priority process-kill process-migration process-suspend 
           properties set-maestro process-startkilltime synchro trace-categories 
           trace-link-srcdst-user-variables trace-link-user-variables trace-masterworker trace-platform 
           trace-process-migration trace-simple trace-user-variables)
           properties set-maestro process-startkilltime synchro trace-categories 
           trace-link-srcdst-user-variables trace-link-user-variables trace-masterworker trace-platform 
           trace-process-migration trace-simple trace-user-variables)
@@ -83,7 +83,7 @@ set(xml_files    ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actio
 
 foreach(x actions-comm actions-storage app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
           async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple 
 
 foreach(x actions-comm actions-storage app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
           async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple 
-          cloud-two-tasks dht-chord dht-kademlia failures io-file io-file-unlink io-remote io-storage task-priority 
+          cloud-two-tasks dht-chord dht-kademlia failures io-file io-remote io-storage task-priority 
           process-kill process-migration process-suspend properties synchro process-startkilltime)
   ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/${x} ${x}.tesh)
 endforeach()
           process-kill process-migration process-suspend properties synchro process-startkilltime)
   ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/${x} ${x}.tesh)
 endforeach()
diff --git a/examples/msg/io-file-unlink/io-file-unlink.c b/examples/msg/io-file-unlink/io-file-unlink.c
deleted file mode 100644 (file)
index 0426d20..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (c) 2008-2010, 2012-2015. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-/** @addtogroup MSG_examples
- * 
- * - <b>io/file_unlink.c</b> TBA
- */
-
-#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
-
-#include "simgrid/msg.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example");
-
-static int host(int argc, char *argv[])
-{
-  // First open
-  XBT_INFO("\tOpen file '%s'",FILENAME1);
-  msg_file_t file = MSG_file_open(FILENAME1, NULL);
-
-  // Unlink the file
-  XBT_INFO("\tUnlink file '%s'",MSG_file_get_name(file));
-  MSG_file_unlink(file);
-
-  // Re Open the file wich is in fact created
-  XBT_INFO("\tOpen file '%s'",FILENAME1);
-  file = MSG_file_open(FILENAME1, NULL);
-
-  // Write into the new file
-  sg_size_t write = MSG_file_write(file,100000);  // Write for 100Ko
-  XBT_INFO("\tHave written %llu on %s",write,MSG_file_get_name(file));
-
-  // Write into the new file
-  write = MSG_file_write(file,100000);  // Write for 100Ko
-  XBT_INFO("\tHave written %llu on %s",write,MSG_file_get_name(file));
-
-  // Close the file
-  XBT_INFO("\tClose file '%s'",MSG_file_get_name(file));
-  MSG_file_close(file);
-
-  return 0;
-}
-
-int main(int argc, char **argv)
-{
-  MSG_init(&argc, argv);
-  MSG_create_environment(argv[1]);
-  xbt_dynar_t hosts =  MSG_hosts_as_dynar();
-  MSG_function_register("host", host);
-  unsigned long nb_hosts = xbt_dynar_length(hosts);
-  XBT_INFO("Number of host '%lu'",nb_hosts);
-  char* name_host = xbt_strdup("0");
-  MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,0,msg_host_t) );
-  free(name_host);
-
-  xbt_dynar_free(&hosts);
-
-  int res = MSG_main();
-  XBT_INFO("Simulation time %g", MSG_get_clock());
-  return res != MSG_OK;
-}
diff --git a/examples/msg/io-file-unlink/io-file-unlink.tesh b/examples/msg/io-file-unlink/io-file-unlink.tesh
deleted file mode 100644 (file)
index 77549ba..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#! ./tesh
-
-$ ${bindir:=.}/io-file-unlink ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (0:maestro@) Number of host '4'
-> [  0.000000] (1:0@denise)    Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
-> [  0.000000] (1:0@denise)    Unlink file '/home/doc/simgrid/examples/platforms/g5k.xml'
-> [  0.000000] (1:0@denise)    Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
-> [  0.001667] (1:0@denise)    Have written 100000 on /home/doc/simgrid/examples/platforms/g5k.xml
-> [  0.003333] (1:0@denise)    Have written 100000 on /home/doc/simgrid/examples/platforms/g5k.xml
-> [  0.003333] (1:0@denise)    Close file '/home/doc/simgrid/examples/platforms/g5k.xml'
-> [  0.003333] (0:maestro@) Simulation time 0.00333333
index c72e615..0cc2868 100644 (file)
@@ -6,13 +6,8 @@
 
 /** @addtogroup MSG_examples
  * 
 
 /** @addtogroup MSG_examples
  * 
- * @subsection MSG_ex_resources Other resource kinds
- * 
- * This section contains some sparse examples of how to use the other
- * kind of resources, such as disk or GPU. These resources are quite
- * experimental for now, but here we go anyway.
- * 
- * - <b>io/file.c</b> Example with the disk resource
+ * - <b>File management: io-file/io-file.c</b>. This example illustrates the use of operations on file
+ *   (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write, or @ref MSG_file_close).
  */
 
 #define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
  */
 
 #define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
@@ -85,9 +80,13 @@ static int host(int argc, char *argv[])
   XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
             filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
 
   XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
             filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
 
-  XBT_INFO("\tClose file '%s'",filename);
-  MSG_file_close(file);
-
+  if(!strcmp(MSG_process_get_name(MSG_process_self()),"0")){
+    XBT_INFO("\tUnlink file '%s'",MSG_file_get_name(file));
+    MSG_file_unlink(file);
+  } else {
+    XBT_INFO("\tClose file '%s'",filename);
+    MSG_file_close(file);
+  }
   return 0;
 }
 
   return 0;
 }
 
index 5bde55c..9c88ea9 100644 (file)
@@ -40,7 +40,7 @@ $ ${bindir:=.}/io-file ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]
 > [  0.003560] (3:2@carl)      Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
 > [  0.004135] (1:0@denise)    Have written 110000 in '/home/doc/simgrid/examples/platforms/g5k.xml'. Size now is: 110000
 > [  0.004135] (1:0@denise)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13314966 / 536870912000
 > [  0.003560] (3:2@carl)      Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
 > [  0.004135] (1:0@denise)    Have written 110000 in '/home/doc/simgrid/examples/platforms/g5k.xml'. Size now is: 110000
 > [  0.004135] (1:0@denise)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13314966 / 536870912000
-> [  0.004135] (1:0@denise)    Close file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.004135] (1:0@denise)    Unlink file '/home/doc/simgrid/examples/platforms/g5k.xml'
 > [  0.004414] (4:3@bob)       Have read 104028 from '/home/doc/simgrid/examples/platforms/nancy.xml' (of size 104028)
 > [  0.004414] (4:3@bob)       Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.004558] (2:1@alice)     Have written 110000 in 'c:\Windows\setupact.log'. Size now is: 110000
 > [  0.004414] (4:3@bob)       Have read 104028 from '/home/doc/simgrid/examples/platforms/nancy.xml' (of size 104028)
 > [  0.004414] (4:3@bob)       Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.004558] (2:1@alice)     Have written 110000 in 'c:\Windows\setupact.log'. Size now is: 110000
index bbb3ca0..86fd255 100644 (file)
@@ -6,7 +6,7 @@
 
 /** @addtogroup MSG_examples
  * 
 
 /** @addtogroup MSG_examples
  * 
- * - <b>io/remote.c</b> Example of delegated I/O operations
+ * - <b>Remote I/O: io-remote/io-remote.c</b> I/O operation can also be done in a remote, which is illustrated here.
  */
 
 #include "simgrid/msg.h"
  */
 
 #include "simgrid/msg.h"
index ce10c42..f647c5a 100644 (file)
@@ -6,22 +6,12 @@
 
 /** @addtogroup MSG_examples
  * 
 
 /** @addtogroup MSG_examples
  * 
- * - <b>io/storage.c</b> demo of all main storage and file functions
- */
-
-/********************* Files and Storage handling ****************************
- * This example implements all main storage and file functions of the MSG API
+ * @section MSG_ex_resources Simulation disks and files
  *
  *
- * Scenario :
- * - display information on the disks mounted by the current host
- * - create a 200,000 bytes file
- * - completely read the created file
- * - write 100,000 bytes in the file
- * - rename the created file
- * - attach some user data to a disk
- * - dump disk's contents
+ * This section lists some examples of storage simulation. This part of SimGrid is still preliminary.
  *
  *
-******************************************************************************/
+ * - <b>Basic example: io-storage/io-storage.c</b>. This example implements all main storage and file functions.
+ */
 
 #include "simgrid/msg.h"
 
 
 #include "simgrid/msg.h"
 
@@ -30,7 +20,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 static int host(int argc, char *argv[]){
   const char* host_name = MSG_host_get_name(MSG_host_self());
 
 static int host(int argc, char *argv[]){
   const char* host_name = MSG_host_get_name(MSG_host_self());
 
-  // display information on the disks mounted by the current host
+  /** - Display information on the disks mounted by the current host */
   XBT_INFO("*** Storage info on %s ***", host_name);
 
   xbt_dict_cursor_t cursor = NULL;
   XBT_INFO("*** Storage info on %s ***", host_name);
 
   xbt_dict_cursor_t cursor = NULL;
@@ -38,15 +28,15 @@ static int host(int argc, char *argv[]){
   char* storage_name;
   msg_storage_t storage = NULL;
 
   char* storage_name;
   msg_storage_t storage = NULL;
 
-  // Retrieve all mount points of current host
+  /** - Retrieve all mount points of current host */
   xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
 
   xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)  {
   xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
 
   xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)  {
-    // For each disk mounted on host
+    /** - For each disk mounted on host:
+           - Retrieve disk's information */
     XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name);
     storage = MSG_storage_get_by_name(storage_name);
 
     XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name);
     storage = MSG_storage_get_by_name(storage_name);
 
-    // Retrieve disk's information
     sg_size_t free_size = MSG_storage_get_free_size(storage);
     sg_size_t used_size = MSG_storage_get_used_size(storage);
     sg_size_t size = MSG_storage_get_size(storage);
     sg_size_t free_size = MSG_storage_get_free_size(storage);
     sg_size_t used_size = MSG_storage_get_used_size(storage);
     sg_size_t size = MSG_storage_get_size(storage);
@@ -57,28 +47,28 @@ static int host(int argc, char *argv[]){
   }
   xbt_dict_free(&storage_list);
 
   }
   xbt_dict_free(&storage_list);
 
-  // Create a 200,000 bytes file named './tmp/data.txt' on /sd1
+  /** - Create a 200,000 bytes file named './tmp/data.txt' on /sd1 */
   char* file_name = xbt_strdup("/home/tmp/data.txt");
   msg_file_t file = NULL;
   sg_size_t write, read, file_size;
 
   char* file_name = xbt_strdup("/home/tmp/data.txt");
   msg_file_t file = NULL;
   sg_size_t write, read, file_size;
 
-  // Open an non-existing file amounts to create it!
+  /** - Open an non-existing file which amounts to create it. */
   file = MSG_file_open(file_name, NULL);
   write = MSG_file_write(file, 200000);  // Write 200,000 bytes
   XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name);
   MSG_file_dump(file);
 
   file = MSG_file_open(file_name, NULL);
   write = MSG_file_write(file, 200000);  // Write 200,000 bytes
   XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name);
   MSG_file_dump(file);
 
-  // check that sizes have changed
+  /** - Check that sizes have changed */
   XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage));
   XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage));
 
   XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage));
   XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage));
 
-  // Now retrieve the size of created file and read it completely
+  /**  - Retrieve the size of created file and read it completely */
   file_size = MSG_file_get_size(file);
   MSG_file_seek(file, 0, SEEK_SET);
   read = MSG_file_read(file, file_size);
   XBT_INFO("Read %llu bytes on %s", read, file_name);
 
   file_size = MSG_file_get_size(file);
   MSG_file_seek(file, 0, SEEK_SET);
   read = MSG_file_read(file, file_size);
   XBT_INFO("Read %llu bytes on %s", read, file_name);
 
-  // Now write 100,000 bytes in tmp/data.txt
+  /** - Then write 100,000 bytes in tmp/data.txt */
   write = MSG_file_write(file, 100000);  // Write 100,000 bytes
   XBT_INFO("Write %llu bytes on %s", write, file_name);
   MSG_file_dump(file);
   write = MSG_file_write(file, 100000);  // Write 100,000 bytes
   XBT_INFO("Write %llu bytes on %s", write, file_name);
   MSG_file_dump(file);
@@ -86,20 +76,20 @@ static int host(int argc, char *argv[]){
   storage_name = xbt_strdup("Disk4");
   storage = MSG_storage_get_by_name(storage_name);
 
   storage_name = xbt_strdup("Disk4");
   storage = MSG_storage_get_by_name(storage_name);
 
-  // Now rename file from ./tmp/data.txt to ./tmp/simgrid.readme
+  /**  - Move file from ./tmp/data.txt to ./tmp/simgrid.readme */
   XBT_INFO("*** Move '/tmp/data.txt' into '/tmp/simgrid.readme'");
   MSG_file_move(file, "/home/tmp/simgrid.readme");
 
   XBT_INFO("*** Move '/tmp/data.txt' into '/tmp/simgrid.readme'");
   MSG_file_move(file, "/home/tmp/simgrid.readme");
 
-  // Attach some user data to the file
+  /** - Attach some user data to the file */
   MSG_file_set_data(file, xbt_strdup("777"));
   MSG_file_set_data(file, xbt_strdup("777"));
-  // Retrieve these data
+  /** - Then retrieve this data */
   char *data = MSG_file_get_data(file);
   XBT_INFO("User data attached to the file: %s", data);
 
   MSG_file_close(file);
   free(file_name);
 
   char *data = MSG_file_get_data(file);
   XBT_INFO("User data attached to the file: %s", data);
 
   MSG_file_close(file);
   free(file_name);
 
-  // Now attach some user data to disk1
+  /** - Attach some user data to disk1 */
   XBT_INFO("*** Get/set data for storage element: %s ***",storage_name);
 
   data = MSG_storage_get_data(storage);
   XBT_INFO("*** Get/set data for storage element: %s ***",storage_name);
 
   data = MSG_storage_get_data(storage);
@@ -112,7 +102,7 @@ static int host(int argc, char *argv[]){
   xbt_free(data);
   xbt_free(storage_name);
 
   xbt_free(data);
   xbt_free(storage_name);
 
-  // Dump disks contents
+  /** - Finally dump disks contents */
   XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self()));
   xbt_dict_t contents = NULL;
   contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts
   XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self()));
   xbt_dict_t contents = NULL;
   contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts