Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7ee98f9f4dd3b98d3d94f8b0fddaf554dae4dc05
[simgrid.git] / teshsuite / msg / storage / concurrent_rw.c
1 /* Copyright (c) 2008-2010, 2012-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "simgrid/msg.h"
8 #include <unistd.h>
9
10 #define FILENAME1 "/sd1/doc/simgrid/examples/cxx/autoDestination/Main.cxx"
11
12 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
13
14 static int host(int argc, char *argv[])
15 {
16   char name[2048];
17   sprintf(name,"%s%i", FILENAME1,MSG_process_self_PID());
18   msg_file_t file = MSG_file_open(name, NULL);
19   //MSG_file_read(file, MSG_file_get_size(file));
20   MSG_file_write(file, 500000);
21
22   XBT_INFO("Size of %s: %llu", MSG_file_get_name(file), MSG_file_get_size(file));
23   MSG_file_close(file);
24
25   return 1;
26 }
27
28 int main(int argc, char **argv)
29 {
30   MSG_init(&argc, argv);
31   MSG_create_environment(argv[1]);
32
33   MSG_function_register("host", host);
34   for(int i = 0 ; i<10; i++){
35     MSG_process_create(xbt_strdup("host"), host, NULL, MSG_host_by_name(xbt_strdup("host")));
36   }
37
38   int res = MSG_main();
39   XBT_INFO("Simulation time %g", MSG_get_clock());
40
41   return res != MSG_OK;
42 }