1 /* Copyright (c) 2008-2010, 2012-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "simgrid/msg.h"
10 #define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
12 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
14 static int host(int argc, char *argv[])
17 int id = MSG_process_self_PID();
18 sprintf(name,"%s%i", FILENAME1, id);
19 msg_file_t file = MSG_file_open(name, NULL);
20 XBT_INFO("process %d is writing!", id);
21 MSG_file_write(file, 3000000);
22 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
23 MSG_process_sleep(id);
24 XBT_INFO("process %d is writing again!", id);
25 MSG_file_write(file, 3000000);
26 XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id);
27 MSG_process_sleep(6-id);
28 XBT_INFO("process %d is reading!", id);
29 MSG_file_seek(file, 0, SEEK_SET);
30 MSG_file_read(file, 3000000);
31 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
32 MSG_process_sleep(id);
33 XBT_INFO("process %d is reading again!", id);
34 MSG_file_seek(file, 0, SEEK_SET);
35 MSG_file_read(file, 3000000);
37 XBT_INFO("process %d => Size of %s: %llu", id, MSG_file_get_name(file), MSG_file_get_size(file));
43 int main(int argc, char **argv)
45 MSG_init(&argc, argv);
46 MSG_create_environment(argv[1]);
48 MSG_function_register("host", host);
49 for(int i = 0 ; i < 5; i++){
50 MSG_process_create("bob", host, NULL, MSG_host_by_name(xbt_strdup("bob")));
54 XBT_INFO("Simulation time %g", MSG_get_clock());