include examples/c/actor-create/actor-create.c
include examples/c/actor-create/actor-create.tesh
include examples/c/actor-create/actor-create_d.xml
+include examples/c/actor-daemon/actor-daemon.c
+include examples/c/actor-daemon/actor-daemon.tesh
+include examples/c/actor-join/actor-join.c
+include examples/c/actor-join/actor-join.tesh
include examples/c/app-pingpong/app-pingpong.c
include examples/c/app-pingpong/app-pingpong.tesh
include examples/c/app-pingpong/app-pingpong_d.xml
+include examples/c/app-token-ring/app-token-ring.c
+include examples/c/app-token-ring/app-token-ring.tesh
include examples/c/async-waitany/async-waitany.c
include examples/c/async-waitany/async-waitany.tesh
include examples/c/async-waitany/async-waitany_d.xml
include teshsuite/msg/app-chainsend/messages.h
include teshsuite/msg/app-chainsend/peer.c
include teshsuite/msg/app-chainsend/peer.h
-include teshsuite/msg/app-token-ring/app-token-ring.c
-include teshsuite/msg/app-token-ring/app-token-ring.tesh
include teshsuite/msg/async-wait/async-wait.c
include teshsuite/msg/async-wait/async-wait.tesh
include teshsuite/msg/async-wait/async-wait2_d.xml
include teshsuite/msg/platform-properties/platform-properties_d.xml
include teshsuite/msg/plugin-hostload/plugin-hostload.c
include teshsuite/msg/plugin-hostload/plugin-hostload.tesh
-include teshsuite/msg/process-daemon/process-daemon.c
-include teshsuite/msg/process-daemon/process-daemon.tesh
-include teshsuite/msg/process-join/process-join.c
-include teshsuite/msg/process-join/process-join.tesh
include teshsuite/msg/process-kill/process-kill.c
include teshsuite/msg/process-kill/process-kill.tesh
include teshsuite/msg/process-lifetime/baseline_d.xml
-foreach(x actor-create app-pingpong async-waitany io-disk-raw)
+foreach(x actor-create actor-daemon actor-join app-pingpong app-token-ring async-waitany io-disk-raw)
add_executable (${x}-c EXCLUDE_FROM_ALL ${x}/${x}.c)
target_link_libraries(${x}-c simgrid)
set_target_properties(${x}-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml
PARENT_SCOPE)
-foreach(x actor-create app-pingpong async-waitany io-disk-raw)
+foreach(x actor-create actor-daemon actor-join app-pingpong app-token-ring async-waitany io-disk-raw)
ADD_TESH(c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
--setenv bindir=${CMAKE_BINARY_DIR}/examples/c/${x}
--cd ${CMAKE_HOME_DIRECTORY}/examples/c/${x}
--- /dev/null
+/* Copyright (c) 2017-2020. 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. */
+
+#include "simgrid/actor.h"
+#include "simgrid/engine.h"
+#include "simgrid/host.h"
+#include "xbt/log.h"
+#include "xbt/sysdep.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(actor_daemon, "Messages specific for this example");
+
+/* The worker process, working for a while before leaving */
+static void worker(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ XBT_INFO("Let's do some work (for 10 sec on Boivin).");
+ sg_actor_self_execute(980.95e6);
+ XBT_INFO("I'm done now. I leave even if it makes the daemon die.");
+}
+
+/* The daemon, displaying a message every 3 seconds until all other processes stop */
+static void my_daemon(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ sg_actor_daemonize(sg_actor_self());
+
+ while (1) {
+ XBT_INFO("Hello from the infinite loop");
+ sg_actor_sleep_for(3.0);
+ }
+
+ XBT_INFO("I will never reach that point: daemons are killed when regular processes are done");
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid_init(&argc, argv);
+ xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
+ simgrid_load_platform(argv[1]);
+
+ sg_actor_t w = sg_actor_init("worker", sg_host_by_name("Boivin"));
+ sg_actor_start(w, worker, 0, NULL);
+ sg_actor_t d = sg_actor_init("daemon", sg_host_by_name("Tremblay"));
+ sg_actor_start(d, my_daemon, 0, NULL);
+
+ simgrid_run();
+}
#!/usr/bin/env tesh
-p Testing the process daemonization feature of MSG
+p Testing the actor daemonization feature
-$ ${bindir:=.}/process-daemon ${platfdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/actor-daemon-c ${platfdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:worker@Boivin) Let's do some work (for 10 sec on Boivin).
> [ 0.000000] (2:daemon@Tremblay) Hello from the infinite loop
> [ 3.000000] (2:daemon@Tremblay) Hello from the infinite loop
--- /dev/null
+/* Copyright (c) 2010-2020. 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. */
+
+#include "simgrid/actor.h"
+#include "simgrid/engine.h"
+#include "simgrid/host.h"
+
+#include "xbt/log.h"
+#include "xbt/sysdep.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(actor_join, "Messages specific for this example");
+
+static void sleeper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ XBT_INFO("Sleeper started");
+ sg_actor_sleep_for(3);
+ XBT_INFO("I'm done. See you!");
+}
+
+static void master(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ sg_actor_t actor;
+
+ XBT_INFO("Start sleeper");
+ actor = sg_actor_init("sleeper from master", sg_host_self());
+ sg_actor_start(actor, sleeper, 0, NULL);
+ XBT_INFO("Join the sleeper (timeout 2)");
+ sg_actor_join(actor, 2);
+
+ XBT_INFO("Start sleeper");
+ actor = sg_actor_init("sleeper from master", sg_host_self());
+ sg_actor_start(actor, sleeper, 0, NULL);
+ XBT_INFO("Join the sleeper (timeout 4)");
+ sg_actor_join(actor, 4);
+
+ XBT_INFO("Start sleeper");
+ actor = sg_actor_init("sleeper from master", sg_host_self());
+ sg_actor_start(actor, sleeper, 0, NULL);
+ XBT_INFO("Join the sleeper (timeout 2)");
+ sg_actor_join(actor, 2);
+
+ XBT_INFO("Start sleeper");
+ actor = sg_actor_init("sleeper from master", sg_host_self());
+ sg_actor_start(actor, sleeper, 0, NULL);
+ sg_actor_ref(actor); // We have to take that ref because the actor will stop before we join it
+ XBT_INFO("Waiting 4");
+ sg_actor_sleep_for(4);
+ XBT_INFO("Join the sleeper after its end (timeout 1)");
+ sg_actor_join(actor, 1);
+ sg_actor_unref(actor); // Avoid to leak memory
+
+ XBT_INFO("Goodbye now!");
+
+ sg_actor_sleep_for(1);
+
+ XBT_INFO("Goodbye now!");
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid_init(&argc, argv);
+ xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+
+ simgrid_load_platform(argv[1]);
+
+ sg_actor_t actor = sg_actor_init("master", sg_host_by_name("Tremblay"));
+ sg_actor_start(actor, master, 0, NULL);
+
+ simgrid_run();
+
+ XBT_INFO("Simulation time %g", simgrid_get_clock());
+
+ return 0;
+}
--- /dev/null
+$ ${bindir:=.}/actor-join-c ${platfdir}/small_platform.xml
+> [Tremblay:master:(1) 0.000000] [actor_join/INFO] Start sleeper
+> [Tremblay:sleeper from master:(2) 0.000000] [actor_join/INFO] Sleeper started
+> [Tremblay:master:(1) 0.000000] [actor_join/INFO] Join the sleeper (timeout 2)
+> [Tremblay:master:(1) 2.000000] [actor_join/INFO] Start sleeper
+> [Tremblay:sleeper from master:(3) 2.000000] [actor_join/INFO] Sleeper started
+> [Tremblay:master:(1) 2.000000] [actor_join/INFO] Join the sleeper (timeout 4)
+> [Tremblay:sleeper from master:(2) 3.000000] [actor_join/INFO] I'm done. See you!
+> [Tremblay:sleeper from master:(3) 5.000000] [actor_join/INFO] I'm done. See you!
+> [Tremblay:master:(1) 5.000000] [actor_join/INFO] Start sleeper
+> [Tremblay:sleeper from master:(4) 5.000000] [actor_join/INFO] Sleeper started
+> [Tremblay:master:(1) 5.000000] [actor_join/INFO] Join the sleeper (timeout 2)
+> [Tremblay:master:(1) 7.000000] [actor_join/INFO] Start sleeper
+> [Tremblay:sleeper from master:(5) 7.000000] [actor_join/INFO] Sleeper started
+> [Tremblay:master:(1) 7.000000] [actor_join/INFO] Waiting 4
+> [Tremblay:sleeper from master:(4) 8.000000] [actor_join/INFO] I'm done. See you!
+> [Tremblay:sleeper from master:(5) 10.000000] [actor_join/INFO] I'm done. See you!
+> [Tremblay:master:(1) 11.000000] [actor_join/INFO] Join the sleeper after its end (timeout 1)
+> [Tremblay:master:(1) 11.000000] [actor_join/INFO] Goodbye now!
+> [Tremblay:master:(1) 12.000000] [actor_join/INFO] Goodbye now!
+> [12.000000] [actor_join/INFO] Simulation time 12
--- /dev/null
+/* Copyright (c) 2008-2020. 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. */
+
+#include "simgrid/actor.h"
+#include "simgrid/engine.h"
+#include "simgrid/host.h"
+#include "simgrid/mailbox.h"
+
+#include "xbt/log.h"
+#include "xbt/str.h"
+#include "xbt/sysdep.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(app_token_ring, "Messages specific for this msg example");
+
+/* Main function of all actors used in this example */
+static void relay_runner(int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ xbt_assert(argc == 0, "The relay_runner function does not accept any parameter from the XML deployment file");
+
+ const char* name = sg_actor_self_get_name();
+ int rank = xbt_str_parse_int(name, "Any actor of this example must have a numerical name, not %s");
+
+ sg_mailbox_t my_mailbox = sg_mailbox_by_name(name);
+
+ /* The last actor sends the token back to rank 0, the others send to their right neighbor (rank+1) */
+ char neighbor_mailbox_name[256];
+ snprintf(neighbor_mailbox_name, 255, "%d", rank + 1 == sg_host_count() ? 0 : rank + 1);
+
+ sg_mailbox_t neighbor_mailbox = sg_mailbox_by_name(neighbor_mailbox_name);
+
+ char* res;
+ if (rank == 0) {
+ /* The root actor (rank 0) first sends the token then waits to receive it back */
+ XBT_INFO("Host \"%d\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox_name);
+ sg_mailbox_put(neighbor_mailbox, xbt_strdup("Token"), 1000000);
+
+ res = (char*)sg_mailbox_get(my_mailbox);
+ XBT_INFO("Host \"%d\" received \"%s\"", rank, res);
+ } else {
+ /* The others actors receive from their left neighbor (rank-1) and send to their right neighbor (rank+1) */
+ res = (char*)sg_mailbox_get(my_mailbox);
+ XBT_INFO("Host \"%d\" received \"%s\"", rank, res);
+ XBT_INFO("Host \"%d\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox_name);
+ sg_mailbox_put(neighbor_mailbox, xbt_strdup("Token"), 1000000);
+ }
+ free(res);
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid_init(&argc, argv);
+ xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
+ simgrid_load_platform(argv[1]); /* - Load the platform description */
+
+ size_t host_count;
+ sg_host_t* hosts;
+ simgrid_get_all_hosts(&host_count, &hosts);
+
+ XBT_INFO("Number of hosts '%zu'", host_count);
+ for (size_t i = 0; i < host_count; i++) {
+ /* - Give a unique rank to each host and create a @ref relay_runner process on each */
+ char* name_host = bprintf("%zu", i);
+ sg_actor_t actor = sg_actor_init(name_host, hosts[i]);
+ sg_actor_start(actor, relay_runner, 0, NULL);
+ free(name_host);
+ }
+ free(hosts);
+
+ simgrid_run();
+
+ XBT_INFO("Simulation time %g", simgrid_get_clock());
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/app-token-ring-c ${platfdir}/routing_cluster.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n"
+> [ 0.000000] (maestro@) Number of hosts '6'
+> [ 0.000000] (0@host1) Host "0" send 'Token' to Host "1"
+> [ 0.017354] (1@host2) Host "1" received "Token"
+> [ 0.017354] (1@host2) Host "1" send 'Token' to Host "2"
+> [ 0.035121] (2@host3) Host "2" received "Token"
+> [ 0.035121] (2@host3) Host "2" send 'Token' to Host "3"
+> [ 0.065898] (3@host4) Host "3" received "Token"
+> [ 0.065898] (3@host4) Host "3" send 'Token' to Host "4"
+> [ 0.083252] (4@host5) Host "4" received "Token"
+> [ 0.083252] (4@host5) Host "4" send 'Token' to Host "5"
+> [ 0.101019] (5@host6) Host "5" received "Token"
+> [ 0.101019] (5@host6) Host "5" send 'Token' to Host "0"
+> [ 0.131796] (0@host1) Host "0" received "Token"
+> [ 0.131796] (maestro@) Simulation time 0.131796
+
+$ ${bindir:=.}/app-token-ring-c ${platfdir}/two_peers.xml "--log=root.fmt:[%12.6r]%e(%P@%h)%e%m%n"
+> [ 0.000000] (maestro@) Number of hosts '2'
+> [ 0.000000] (0@100030591) Host "0" send 'Token' to Host "1"
+> [ 0.624423] (1@100036570) Host "1" received "Token"
+> [ 0.624423] (1@100036570) Host "1" send 'Token' to Host "0"
+> [ 1.248846] (0@100030591) Host "0" received "Token"
+> [ 1.248846] (maestro@) Simulation time 1.24885
+
+$ ${bindir:=.}/app-token-ring-c ${platfdir}/meta_cluster.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n"
+> [ 0.000000] (maestro@) Number of hosts '60'
+> [ 0.000000] (0@host-1.cluster1) Host "0" send 'Token' to Host "1"
+> [ 0.030364] (1@host-1.cluster2) Host "1" received "Token"
+> [ 0.030364] (1@host-1.cluster2) Host "1" send 'Token' to Host "2"
+> [ 0.060729] (2@host-10.cluster1) Host "2" received "Token"
+> [ 0.060729] (2@host-10.cluster1) Host "2" send 'Token' to Host "3"
+> [ 0.091093] (3@host-10.cluster2) Host "3" received "Token"
+> [ 0.091093] (3@host-10.cluster2) Host "3" send 'Token' to Host "4"
+> [ 0.121458] (4@host-11.cluster1) Host "4" received "Token"
+> [ 0.121458] (4@host-11.cluster1) Host "4" send 'Token' to Host "5"
+> [ 0.151822] (5@host-11.cluster2) Host "5" received "Token"
+> [ 0.151822] (5@host-11.cluster2) Host "5" send 'Token' to Host "6"
+> [ 0.182187] (6@host-12.cluster1) Host "6" received "Token"
+> [ 0.182187] (6@host-12.cluster1) Host "6" send 'Token' to Host "7"
+> [ 0.212551] (7@host-12.cluster2) Host "7" received "Token"
+> [ 0.212551] (7@host-12.cluster2) Host "7" send 'Token' to Host "8"
+> [ 0.242915] (8@host-13.cluster1) Host "8" received "Token"
+> [ 0.242915] (8@host-13.cluster1) Host "8" send 'Token' to Host "9"
+> [ 0.273280] (9@host-13.cluster2) Host "9" received "Token"
+> [ 0.273280] (9@host-13.cluster2) Host "9" send 'Token' to Host "10"
+> [ 0.303644] (10@host-14.cluster1) Host "10" received "Token"
+> [ 0.303644] (10@host-14.cluster1) Host "10" send 'Token' to Host "11"
+> [ 0.334009] (11@host-14.cluster2) Host "11" received "Token"
+> [ 0.334009] (11@host-14.cluster2) Host "11" send 'Token' to Host "12"
+> [ 0.364373] (12@host-15.cluster1) Host "12" received "Token"
+> [ 0.364373] (12@host-15.cluster1) Host "12" send 'Token' to Host "13"
+> [ 0.394737] (13@host-15.cluster2) Host "13" received "Token"
+> [ 0.394737] (13@host-15.cluster2) Host "13" send 'Token' to Host "14"
+> [ 0.425102] (14@host-16.cluster1) Host "14" received "Token"
+> [ 0.425102] (14@host-16.cluster1) Host "14" send 'Token' to Host "15"
+> [ 0.455466] (15@host-16.cluster2) Host "15" received "Token"
+> [ 0.455466] (15@host-16.cluster2) Host "15" send 'Token' to Host "16"
+> [ 0.485831] (16@host-17.cluster1) Host "16" received "Token"
+> [ 0.485831] (16@host-17.cluster1) Host "16" send 'Token' to Host "17"
+> [ 0.516195] (17@host-17.cluster2) Host "17" received "Token"
+> [ 0.516195] (17@host-17.cluster2) Host "17" send 'Token' to Host "18"
+> [ 0.546560] (18@host-18.cluster1) Host "18" received "Token"
+> [ 0.546560] (18@host-18.cluster1) Host "18" send 'Token' to Host "19"
+> [ 0.576924] (19@host-18.cluster2) Host "19" received "Token"
+> [ 0.576924] (19@host-18.cluster2) Host "19" send 'Token' to Host "20"
+> [ 0.607288] (20@host-19.cluster1) Host "20" received "Token"
+> [ 0.607288] (20@host-19.cluster1) Host "20" send 'Token' to Host "21"
+> [ 0.637653] (21@host-19.cluster2) Host "21" received "Token"
+> [ 0.637653] (21@host-19.cluster2) Host "21" send 'Token' to Host "22"
+> [ 0.668017] (22@host-2.cluster1) Host "22" received "Token"
+> [ 0.668017] (22@host-2.cluster1) Host "22" send 'Token' to Host "23"
+> [ 0.698382] (23@host-2.cluster2) Host "23" received "Token"
+> [ 0.698382] (23@host-2.cluster2) Host "23" send 'Token' to Host "24"
+> [ 0.728746] (24@host-20.cluster1) Host "24" received "Token"
+> [ 0.728746] (24@host-20.cluster1) Host "24" send 'Token' to Host "25"
+> [ 0.759111] (25@host-20.cluster2) Host "25" received "Token"
+> [ 0.759111] (25@host-20.cluster2) Host "25" send 'Token' to Host "26"
+> [ 0.789475] (26@host-21.cluster1) Host "26" received "Token"
+> [ 0.789475] (26@host-21.cluster1) Host "26" send 'Token' to Host "27"
+> [ 0.819839] (27@host-21.cluster2) Host "27" received "Token"
+> [ 0.819839] (27@host-21.cluster2) Host "27" send 'Token' to Host "28"
+> [ 0.850204] (28@host-22.cluster1) Host "28" received "Token"
+> [ 0.850204] (28@host-22.cluster1) Host "28" send 'Token' to Host "29"
+> [ 0.880568] (29@host-22.cluster2) Host "29" received "Token"
+> [ 0.880568] (29@host-22.cluster2) Host "29" send 'Token' to Host "30"
+> [ 0.910933] (30@host-23.cluster1) Host "30" received "Token"
+> [ 0.910933] (30@host-23.cluster1) Host "30" send 'Token' to Host "31"
+> [ 0.941297] (31@host-23.cluster2) Host "31" received "Token"
+> [ 0.941297] (31@host-23.cluster2) Host "31" send 'Token' to Host "32"
+> [ 0.971662] (32@host-24.cluster1) Host "32" received "Token"
+> [ 0.971662] (32@host-24.cluster1) Host "32" send 'Token' to Host "33"
+> [ 1.002026] (33@host-24.cluster2) Host "33" received "Token"
+> [ 1.002026] (33@host-24.cluster2) Host "33" send 'Token' to Host "34"
+> [ 1.032390] (34@host-25.cluster1) Host "34" received "Token"
+> [ 1.032390] (34@host-25.cluster1) Host "34" send 'Token' to Host "35"
+> [ 1.062755] (35@host-25.cluster2) Host "35" received "Token"
+> [ 1.062755] (35@host-25.cluster2) Host "35" send 'Token' to Host "36"
+> [ 1.093119] (36@host-26.cluster1) Host "36" received "Token"
+> [ 1.093119] (36@host-26.cluster1) Host "36" send 'Token' to Host "37"
+> [ 1.123484] (37@host-26.cluster2) Host "37" received "Token"
+> [ 1.123484] (37@host-26.cluster2) Host "37" send 'Token' to Host "38"
+> [ 1.153848] (38@host-27.cluster1) Host "38" received "Token"
+> [ 1.153848] (38@host-27.cluster1) Host "38" send 'Token' to Host "39"
+> [ 1.184212] (39@host-27.cluster2) Host "39" received "Token"
+> [ 1.184212] (39@host-27.cluster2) Host "39" send 'Token' to Host "40"
+> [ 1.214577] (40@host-28.cluster1) Host "40" received "Token"
+> [ 1.214577] (40@host-28.cluster1) Host "40" send 'Token' to Host "41"
+> [ 1.244941] (41@host-28.cluster2) Host "41" received "Token"
+> [ 1.244941] (41@host-28.cluster2) Host "41" send 'Token' to Host "42"
+> [ 1.275306] (42@host-29.cluster1) Host "42" received "Token"
+> [ 1.275306] (42@host-29.cluster1) Host "42" send 'Token' to Host "43"
+> [ 1.305670] (43@host-29.cluster2) Host "43" received "Token"
+> [ 1.305670] (43@host-29.cluster2) Host "43" send 'Token' to Host "44"
+> [ 1.336035] (44@host-3.cluster1) Host "44" received "Token"
+> [ 1.336035] (44@host-3.cluster1) Host "44" send 'Token' to Host "45"
+> [ 1.366399] (45@host-3.cluster2) Host "45" received "Token"
+> [ 1.366399] (45@host-3.cluster2) Host "45" send 'Token' to Host "46"
+> [ 1.396763] (46@host-30.cluster1) Host "46" received "Token"
+> [ 1.396763] (46@host-30.cluster1) Host "46" send 'Token' to Host "47"
+> [ 1.427128] (47@host-30.cluster2) Host "47" received "Token"
+> [ 1.427128] (47@host-30.cluster2) Host "47" send 'Token' to Host "48"
+> [ 1.457492] (48@host-4.cluster1) Host "48" received "Token"
+> [ 1.457492] (48@host-4.cluster1) Host "48" send 'Token' to Host "49"
+> [ 1.487857] (49@host-4.cluster2) Host "49" received "Token"
+> [ 1.487857] (49@host-4.cluster2) Host "49" send 'Token' to Host "50"
+> [ 1.518221] (50@host-5.cluster1) Host "50" received "Token"
+> [ 1.518221] (50@host-5.cluster1) Host "50" send 'Token' to Host "51"
+> [ 1.548586] (51@host-5.cluster2) Host "51" received "Token"
+> [ 1.548586] (51@host-5.cluster2) Host "51" send 'Token' to Host "52"
+> [ 1.578950] (52@host-6.cluster1) Host "52" received "Token"
+> [ 1.578950] (52@host-6.cluster1) Host "52" send 'Token' to Host "53"
+> [ 1.609314] (53@host-6.cluster2) Host "53" received "Token"
+> [ 1.609314] (53@host-6.cluster2) Host "53" send 'Token' to Host "54"
+> [ 1.639679] (54@host-7.cluster1) Host "54" received "Token"
+> [ 1.639679] (54@host-7.cluster1) Host "54" send 'Token' to Host "55"
+> [ 1.670043] (55@host-7.cluster2) Host "55" received "Token"
+> [ 1.670043] (55@host-7.cluster2) Host "55" send 'Token' to Host "56"
+> [ 1.700408] (56@host-8.cluster1) Host "56" received "Token"
+> [ 1.700408] (56@host-8.cluster1) Host "56" send 'Token' to Host "57"
+> [ 1.730772] (57@host-8.cluster2) Host "57" received "Token"
+> [ 1.730772] (57@host-8.cluster2) Host "57" send 'Token' to Host "58"
+> [ 1.761137] (58@host-9.cluster1) Host "58" received "Token"
+> [ 1.761137] (58@host-9.cluster1) Host "58" send 'Token' to Host "59"
+> [ 1.791501] (59@host-9.cluster2) Host "59" received "Token"
+> [ 1.791501] (59@host-9.cluster2) Host "59" send 'Token' to Host "0"
+> [ 1.821865] (0@host-1.cluster1) Host "0" received "Token"
+> [ 1.821865] (maestro@) Simulation time 1.82187
try {
rank = std::stoi(simgrid::s4u::this_actor::get_name());
} catch (const std::invalid_argument& ia) {
- throw std::invalid_argument(std::string("Processes of this example must have a numerical name, not ") +
- ia.what());
+ throw std::invalid_argument(std::string("Actors of this example must have a numerical name, not ") + ia.what());
}
my_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(rank));
if (rank + 1 == simgrid::s4u::Engine::get_instance()->get_host_count())
- /* The last process, which sends the token back to rank 0 */
+ /* The last actor sends the token back to rank 0 */
neighbor_mailbox = simgrid::s4u::Mailbox::by_name("0");
else
- /* The others processes send to their right neighbor (rank+1) */
+ /* The others actors send to their right neighbor (rank+1) */
neighbor_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(rank + 1));
if (rank == 0) {
- /* The root process (rank 0) first sends the token then waits to receive it back */
+ /* The root actor (rank 0) first sends the token then waits to receive it back */
XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname());
std::string msg = "Token";
neighbor_mailbox->put(&msg, task_comm_size);
int id = 0;
std::vector<simgrid::s4u::Host*> list = e.get_all_hosts();
for (auto const& host : list) {
- /* - Give a unique rank to each host and create a @ref relay_runner process on each */
+ /* - Give a unique rank to each host and create a @ref relay_runner actor on each */
simgrid::s4u::Actor::create((std::to_string(id)).c_str(), host, RelayRunner());
id++;
}
# C examples
-foreach(x app-token-ring
- async-wait async-waitall async-waitany
+foreach(x async-wait async-waitall async-waitany
cloud-capping cloud-migration cloud-two-tasks cloud-simple
get_sender host_on_off host_on_off_recv
- process-daemon process-kill process-join process-lifetime process-migration process-suspend process-yield
+ process-kill process-lifetime process-migration process-suspend process-yield
energy-consumption energy-ptask energy-pstate platform-properties
io-file io-file-remote
task-priority
if(enable_msg)
foreach(x
async-wait async-waitall
- app-bittorrent app-chainsend app-token-ring
+ app-bittorrent app-chainsend
cloud-capping cloud-migration cloud-two-tasks cloud-simple
energy-pstate
host_on_off host_on_off_processes host_on_off_recv
get_sender
task_destroy_cancel task_listen_from task_progress
- process-daemon process-kill process-join process-lifetime process-migration process-suspend process-yield
+ process-kill process-lifetime process-migration process-suspend process-yield
energy-consumption energy-ptask
io-file io-file-remote
platform-properties
+++ /dev/null
-/* Copyright (c) 2008-2020. 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. */
-
-#include "simgrid/msg.h"
-
-#include <stdio.h> /* snprintf */
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_app_token_ring, "Messages specific for this msg example");
-
-/* Main function of all processes used in this example */
-static int relay_runner(int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- xbt_assert(argc == 0, "The relay_runner function does not accept any parameter from the XML deployment file");
- int rank = xbt_str_parse_int(MSG_process_get_name(MSG_process_self()),
- "Any process of this example must have a numerical name, not %s");
- char mailbox[256];
-
- if (rank == 0) {
- /* The root process (rank 0) first sends the token then waits to receive it back */
- snprintf(mailbox, 255, "%d", rank + 1);
- unsigned int task_comm_size = 1000000; /* The token is 1MB long*/
- msg_task_t task = MSG_task_create("Token", 0, task_comm_size, NULL);
- XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, MSG_task_get_name(task), mailbox);
- MSG_task_send(task, mailbox);
- task = NULL;
- int res = MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
- xbt_assert(res == MSG_OK, "MSG_task_get failed");
- XBT_INFO("Host \"%d\" received \"%s\"", rank, MSG_task_get_name(task));
- MSG_task_destroy(task);
-
- } else {
- /* The others processes receive from their left neighbor (rank-1) and send to their right neighbor (rank+1) */
- msg_task_t task = NULL;
- int res = MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
- xbt_assert(res == MSG_OK, "MSG_task_get failed");
- XBT_INFO("Host \"%d\" received \"%s\"", rank, MSG_task_get_name(task));
-
- if (rank + 1 == MSG_get_host_number())
- /* But the last process, which sends the token back to rank 0 */
- snprintf(mailbox, 255, "0");
- else
- snprintf(mailbox, 255, "%d", rank + 1);
- XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, MSG_task_get_name(task), mailbox);
- MSG_task_send(task, mailbox);
- }
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- MSG_init(&argc, argv);
- xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
- MSG_create_environment(argv[1]); /* - Load the platform description */
- xbt_dynar_t hosts = MSG_hosts_as_dynar();
-
- XBT_INFO("Number of hosts '%zu'", MSG_get_host_number());
- unsigned int i;
- msg_host_t h;
- xbt_dynar_foreach (hosts, i,
- h) { /* - Give a unique rank to each host and create a @ref relay_runner process on each */
- char* name_host = bprintf("%u", i);
- MSG_process_create(name_host, relay_runner, NULL, h);
- free(name_host);
- }
- xbt_dynar_free(&hosts);
-
- int res = MSG_main(); /* - Run the simulation */
- XBT_INFO("Simulation time %g", MSG_get_clock());
- return res != MSG_OK;
-}
+++ /dev/null
-#!/usr/bin/env tesh
-
-$ ${bindir:=.}/app-token-ring ${platfdir}/routing_cluster.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (0:maestro@) Number of hosts '6'
-> [ 0.000000] (1:0@host1) Host "0" send 'Token' to Host "1"
-> [ 0.017354] (2:1@host2) Host "1" received "Token"
-> [ 0.017354] (2:1@host2) Host "1" send 'Token' to Host "2"
-> [ 0.035121] (3:2@host3) Host "2" received "Token"
-> [ 0.035121] (3:2@host3) Host "2" send 'Token' to Host "3"
-> [ 0.065898] (4:3@host4) Host "3" received "Token"
-> [ 0.065898] (4:3@host4) Host "3" send 'Token' to Host "4"
-> [ 0.083252] (5:4@host5) Host "4" received "Token"
-> [ 0.083252] (5:4@host5) Host "4" send 'Token' to Host "5"
-> [ 0.101019] (6:5@host6) Host "5" received "Token"
-> [ 0.101019] (6:5@host6) Host "5" send 'Token' to Host "0"
-> [ 0.131796] (1:0@host1) Host "0" received "Token"
-> [ 0.131796] (0:maestro@) Simulation time 0.131796
-
-$ ${bindir:=.}/app-token-ring ${platfdir}/two_peers.xml "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (0:maestro@) Number of hosts '2'
-> [ 0.000000] (1:0@100030591) Host "0" send 'Token' to Host "1"
-> [ 0.624423] (2:1@100036570) Host "1" received "Token"
-> [ 0.624423] (2:1@100036570) Host "1" send 'Token' to Host "0"
-> [ 1.248846] (1:0@100030591) Host "0" received "Token"
-> [ 1.248846] (0:maestro@) Simulation time 1.24885
-
-$ ${bindir:=.}/app-token-ring ${platfdir}/meta_cluster.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (0:maestro@) Number of hosts '60'
-> [ 0.000000] (1:0@host-1.cluster1) Host "0" send 'Token' to Host "1"
-> [ 0.030364] (2:1@host-1.cluster2) Host "1" received "Token"
-> [ 0.030364] (2:1@host-1.cluster2) Host "1" send 'Token' to Host "2"
-> [ 0.060729] (3:2@host-10.cluster1) Host "2" received "Token"
-> [ 0.060729] (3:2@host-10.cluster1) Host "2" send 'Token' to Host "3"
-> [ 0.091093] (4:3@host-10.cluster2) Host "3" received "Token"
-> [ 0.091093] (4:3@host-10.cluster2) Host "3" send 'Token' to Host "4"
-> [ 0.121458] (5:4@host-11.cluster1) Host "4" received "Token"
-> [ 0.121458] (5:4@host-11.cluster1) Host "4" send 'Token' to Host "5"
-> [ 0.151822] (6:5@host-11.cluster2) Host "5" received "Token"
-> [ 0.151822] (6:5@host-11.cluster2) Host "5" send 'Token' to Host "6"
-> [ 0.182187] (7:6@host-12.cluster1) Host "6" received "Token"
-> [ 0.182187] (7:6@host-12.cluster1) Host "6" send 'Token' to Host "7"
-> [ 0.212551] (8:7@host-12.cluster2) Host "7" received "Token"
-> [ 0.212551] (8:7@host-12.cluster2) Host "7" send 'Token' to Host "8"
-> [ 0.242915] (9:8@host-13.cluster1) Host "8" received "Token"
-> [ 0.242915] (9:8@host-13.cluster1) Host "8" send 'Token' to Host "9"
-> [ 0.273280] (10:9@host-13.cluster2) Host "9" received "Token"
-> [ 0.273280] (10:9@host-13.cluster2) Host "9" send 'Token' to Host "10"
-> [ 0.303644] (11:10@host-14.cluster1) Host "10" received "Token"
-> [ 0.303644] (11:10@host-14.cluster1) Host "10" send 'Token' to Host "11"
-> [ 0.334009] (12:11@host-14.cluster2) Host "11" received "Token"
-> [ 0.334009] (12:11@host-14.cluster2) Host "11" send 'Token' to Host "12"
-> [ 0.364373] (13:12@host-15.cluster1) Host "12" received "Token"
-> [ 0.364373] (13:12@host-15.cluster1) Host "12" send 'Token' to Host "13"
-> [ 0.394737] (14:13@host-15.cluster2) Host "13" received "Token"
-> [ 0.394737] (14:13@host-15.cluster2) Host "13" send 'Token' to Host "14"
-> [ 0.425102] (15:14@host-16.cluster1) Host "14" received "Token"
-> [ 0.425102] (15:14@host-16.cluster1) Host "14" send 'Token' to Host "15"
-> [ 0.455466] (16:15@host-16.cluster2) Host "15" received "Token"
-> [ 0.455466] (16:15@host-16.cluster2) Host "15" send 'Token' to Host "16"
-> [ 0.485831] (17:16@host-17.cluster1) Host "16" received "Token"
-> [ 0.485831] (17:16@host-17.cluster1) Host "16" send 'Token' to Host "17"
-> [ 0.516195] (18:17@host-17.cluster2) Host "17" received "Token"
-> [ 0.516195] (18:17@host-17.cluster2) Host "17" send 'Token' to Host "18"
-> [ 0.546560] (19:18@host-18.cluster1) Host "18" received "Token"
-> [ 0.546560] (19:18@host-18.cluster1) Host "18" send 'Token' to Host "19"
-> [ 0.576924] (20:19@host-18.cluster2) Host "19" received "Token"
-> [ 0.576924] (20:19@host-18.cluster2) Host "19" send 'Token' to Host "20"
-> [ 0.607288] (21:20@host-19.cluster1) Host "20" received "Token"
-> [ 0.607288] (21:20@host-19.cluster1) Host "20" send 'Token' to Host "21"
-> [ 0.637653] (22:21@host-19.cluster2) Host "21" received "Token"
-> [ 0.637653] (22:21@host-19.cluster2) Host "21" send 'Token' to Host "22"
-> [ 0.668017] (23:22@host-2.cluster1) Host "22" received "Token"
-> [ 0.668017] (23:22@host-2.cluster1) Host "22" send 'Token' to Host "23"
-> [ 0.698382] (24:23@host-2.cluster2) Host "23" received "Token"
-> [ 0.698382] (24:23@host-2.cluster2) Host "23" send 'Token' to Host "24"
-> [ 0.728746] (25:24@host-20.cluster1) Host "24" received "Token"
-> [ 0.728746] (25:24@host-20.cluster1) Host "24" send 'Token' to Host "25"
-> [ 0.759111] (26:25@host-20.cluster2) Host "25" received "Token"
-> [ 0.759111] (26:25@host-20.cluster2) Host "25" send 'Token' to Host "26"
-> [ 0.789475] (27:26@host-21.cluster1) Host "26" received "Token"
-> [ 0.789475] (27:26@host-21.cluster1) Host "26" send 'Token' to Host "27"
-> [ 0.819839] (28:27@host-21.cluster2) Host "27" received "Token"
-> [ 0.819839] (28:27@host-21.cluster2) Host "27" send 'Token' to Host "28"
-> [ 0.850204] (29:28@host-22.cluster1) Host "28" received "Token"
-> [ 0.850204] (29:28@host-22.cluster1) Host "28" send 'Token' to Host "29"
-> [ 0.880568] (30:29@host-22.cluster2) Host "29" received "Token"
-> [ 0.880568] (30:29@host-22.cluster2) Host "29" send 'Token' to Host "30"
-> [ 0.910933] (31:30@host-23.cluster1) Host "30" received "Token"
-> [ 0.910933] (31:30@host-23.cluster1) Host "30" send 'Token' to Host "31"
-> [ 0.941297] (32:31@host-23.cluster2) Host "31" received "Token"
-> [ 0.941297] (32:31@host-23.cluster2) Host "31" send 'Token' to Host "32"
-> [ 0.971662] (33:32@host-24.cluster1) Host "32" received "Token"
-> [ 0.971662] (33:32@host-24.cluster1) Host "32" send 'Token' to Host "33"
-> [ 1.002026] (34:33@host-24.cluster2) Host "33" received "Token"
-> [ 1.002026] (34:33@host-24.cluster2) Host "33" send 'Token' to Host "34"
-> [ 1.032390] (35:34@host-25.cluster1) Host "34" received "Token"
-> [ 1.032390] (35:34@host-25.cluster1) Host "34" send 'Token' to Host "35"
-> [ 1.062755] (36:35@host-25.cluster2) Host "35" received "Token"
-> [ 1.062755] (36:35@host-25.cluster2) Host "35" send 'Token' to Host "36"
-> [ 1.093119] (37:36@host-26.cluster1) Host "36" received "Token"
-> [ 1.093119] (37:36@host-26.cluster1) Host "36" send 'Token' to Host "37"
-> [ 1.123484] (38:37@host-26.cluster2) Host "37" received "Token"
-> [ 1.123484] (38:37@host-26.cluster2) Host "37" send 'Token' to Host "38"
-> [ 1.153848] (39:38@host-27.cluster1) Host "38" received "Token"
-> [ 1.153848] (39:38@host-27.cluster1) Host "38" send 'Token' to Host "39"
-> [ 1.184212] (40:39@host-27.cluster2) Host "39" received "Token"
-> [ 1.184212] (40:39@host-27.cluster2) Host "39" send 'Token' to Host "40"
-> [ 1.214577] (41:40@host-28.cluster1) Host "40" received "Token"
-> [ 1.214577] (41:40@host-28.cluster1) Host "40" send 'Token' to Host "41"
-> [ 1.244941] (42:41@host-28.cluster2) Host "41" received "Token"
-> [ 1.244941] (42:41@host-28.cluster2) Host "41" send 'Token' to Host "42"
-> [ 1.275306] (43:42@host-29.cluster1) Host "42" received "Token"
-> [ 1.275306] (43:42@host-29.cluster1) Host "42" send 'Token' to Host "43"
-> [ 1.305670] (44:43@host-29.cluster2) Host "43" received "Token"
-> [ 1.305670] (44:43@host-29.cluster2) Host "43" send 'Token' to Host "44"
-> [ 1.336035] (45:44@host-3.cluster1) Host "44" received "Token"
-> [ 1.336035] (45:44@host-3.cluster1) Host "44" send 'Token' to Host "45"
-> [ 1.366399] (46:45@host-3.cluster2) Host "45" received "Token"
-> [ 1.366399] (46:45@host-3.cluster2) Host "45" send 'Token' to Host "46"
-> [ 1.396763] (47:46@host-30.cluster1) Host "46" received "Token"
-> [ 1.396763] (47:46@host-30.cluster1) Host "46" send 'Token' to Host "47"
-> [ 1.427128] (48:47@host-30.cluster2) Host "47" received "Token"
-> [ 1.427128] (48:47@host-30.cluster2) Host "47" send 'Token' to Host "48"
-> [ 1.457492] (49:48@host-4.cluster1) Host "48" received "Token"
-> [ 1.457492] (49:48@host-4.cluster1) Host "48" send 'Token' to Host "49"
-> [ 1.487857] (50:49@host-4.cluster2) Host "49" received "Token"
-> [ 1.487857] (50:49@host-4.cluster2) Host "49" send 'Token' to Host "50"
-> [ 1.518221] (51:50@host-5.cluster1) Host "50" received "Token"
-> [ 1.518221] (51:50@host-5.cluster1) Host "50" send 'Token' to Host "51"
-> [ 1.548586] (52:51@host-5.cluster2) Host "51" received "Token"
-> [ 1.548586] (52:51@host-5.cluster2) Host "51" send 'Token' to Host "52"
-> [ 1.578950] (53:52@host-6.cluster1) Host "52" received "Token"
-> [ 1.578950] (53:52@host-6.cluster1) Host "52" send 'Token' to Host "53"
-> [ 1.609314] (54:53@host-6.cluster2) Host "53" received "Token"
-> [ 1.609314] (54:53@host-6.cluster2) Host "53" send 'Token' to Host "54"
-> [ 1.639679] (55:54@host-7.cluster1) Host "54" received "Token"
-> [ 1.639679] (55:54@host-7.cluster1) Host "54" send 'Token' to Host "55"
-> [ 1.670043] (56:55@host-7.cluster2) Host "55" received "Token"
-> [ 1.670043] (56:55@host-7.cluster2) Host "55" send 'Token' to Host "56"
-> [ 1.700408] (57:56@host-8.cluster1) Host "56" received "Token"
-> [ 1.700408] (57:56@host-8.cluster1) Host "56" send 'Token' to Host "57"
-> [ 1.730772] (58:57@host-8.cluster2) Host "57" received "Token"
-> [ 1.730772] (58:57@host-8.cluster2) Host "57" send 'Token' to Host "58"
-> [ 1.761137] (59:58@host-9.cluster1) Host "58" received "Token"
-> [ 1.761137] (59:58@host-9.cluster1) Host "58" send 'Token' to Host "59"
-> [ 1.791501] (60:59@host-9.cluster2) Host "59" received "Token"
-> [ 1.791501] (60:59@host-9.cluster2) Host "59" send 'Token' to Host "0"
-> [ 1.821865] (1:0@host-1.cluster1) Host "0" received "Token"
-> [ 1.821865] (0:maestro@) Simulation time 1.82187
+++ /dev/null
-/* Copyright (c) 2017-2020. 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. */
-
-#include "simgrid/msg.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_daemon, "Messages specific for this msg example");
-
-/* The worker process, working for a while before leaving */
-static int worker_process(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- XBT_INFO("Let's do some work (for 10 sec on Boivin).");
- msg_task_t task = MSG_task_create("easy work", 980.95e6, 0, NULL);
- MSG_task_execute(task);
- MSG_task_destroy(task);
-
- XBT_INFO("I'm done now. I leave even if it makes the daemon die.");
- return 0;
-}
-
-/* The daemon, displaying a message every 3 seconds until all other processes stop */
-static int daemon_process(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- MSG_process_daemonize(MSG_process_self());
-
- while (1) {
- XBT_INFO("Hello from the infinite loop");
- MSG_process_sleep(3.0);
- }
-
- XBT_INFO("I will never reach that point: daemons are killed when regular processes are done");
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- MSG_init(&argc, argv);
- xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
-
- MSG_create_environment(argv[1]);
- xbt_dynar_t hosts = MSG_hosts_as_dynar();
- MSG_process_create("worker", worker_process, NULL, xbt_dynar_getfirst_as(hosts, msg_host_t));
- MSG_process_create("daemon", daemon_process, NULL, xbt_dynar_getlast_as(hosts, msg_host_t));
- xbt_dynar_free(&hosts);
- msg_error_t res = MSG_main();
-
- return res != MSG_OK;
-}
+++ /dev/null
-/* Copyright (c) 2010-2020. 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. */
-
-#include "simgrid/msg.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-
-static int slave(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- XBT_INFO("Slave started");
- MSG_process_sleep(3);
- XBT_INFO("I'm done. See you!");
- return 0;
-}
-
-static int master(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- msg_process_t process;
-
- XBT_INFO("Start slave");
- process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
- XBT_INFO("Join the slave (timeout 2)");
- MSG_process_join(process, 2);
-
- XBT_INFO("Start slave");
- process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
- XBT_INFO("Join the slave (timeout 4)");
- MSG_process_join(process, 4);
-
- XBT_INFO("Start slave");
- process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
- XBT_INFO("Join the slave (timeout 2)");
- MSG_process_join(process, 2);
-
- XBT_INFO("Start slave");
- process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
- MSG_process_ref(process); // We have to take that ref because the process will stop before we join it
- XBT_INFO("Waiting 4");
- MSG_process_sleep(4);
- XBT_INFO("Join the slave after its end (timeout 1)");
- MSG_process_join(process, 1);
- MSG_process_unref(process); // Avoid to leak memory
-
- XBT_INFO("Goodbye now!");
-
- MSG_process_sleep(1);
-
- XBT_INFO("Goodbye now!");
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- msg_error_t res;
-
- MSG_init(&argc, argv);
- xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
-
- MSG_create_environment(argv[1]);
-
- MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
-
- res = MSG_main();
-
- XBT_INFO("Simulation time %g", MSG_get_clock());
-
- return res != MSG_OK;
-}
+++ /dev/null
-
-$ ${bindir:=.}/process-join ${platfdir}/small_platform.xml
-> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Start slave
-> [Tremblay:slave from master:(2) 0.000000] [msg_test/INFO] Slave started
-> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Join the slave (timeout 2)
-> [Tremblay:master:(1) 2.000000] [msg_test/INFO] Start slave
-> [Tremblay:slave from master:(3) 2.000000] [msg_test/INFO] Slave started
-> [Tremblay:master:(1) 2.000000] [msg_test/INFO] Join the slave (timeout 4)
-> [Tremblay:slave from master:(2) 3.000000] [msg_test/INFO] I'm done. See you!
-> [Tremblay:slave from master:(3) 5.000000] [msg_test/INFO] I'm done. See you!
-> [Tremblay:master:(1) 5.000000] [msg_test/INFO] Start slave
-> [Tremblay:slave from master:(4) 5.000000] [msg_test/INFO] Slave started
-> [Tremblay:master:(1) 5.000000] [msg_test/INFO] Join the slave (timeout 2)
-> [Tremblay:master:(1) 7.000000] [msg_test/INFO] Start slave
-> [Tremblay:slave from master:(5) 7.000000] [msg_test/INFO] Slave started
-> [Tremblay:master:(1) 7.000000] [msg_test/INFO] Waiting 4
-> [Tremblay:slave from master:(4) 8.000000] [msg_test/INFO] I'm done. See you!
-> [Tremblay:slave from master:(5) 10.000000] [msg_test/INFO] I'm done. See you!
-> [Tremblay:master:(1) 11.000000] [msg_test/INFO] Join the slave after its end (timeout 1)
-> [Tremblay:master:(1) 11.000000] [msg_test/INFO] Goodbye now!
-> [Tremblay:master:(1) 12.000000] [msg_test/INFO] Goodbye now!
-> [12.000000] [msg_test/INFO] Simulation time 12