From: Martin Quinson Date: Sun, 15 Oct 2017 19:56:27 +0000 (+0200) Subject: cosmetics after integrating #229 X-Git-Tag: v3.18~445 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a741ed15d0642691a78c706ca91c857b9eb4ae93 cosmetics after integrating #229 --- diff --git a/examples/s4u/CMakeLists.txt b/examples/s4u/CMakeLists.txt index 4d14919b47..669aba8d27 100644 --- a/examples/s4u/CMakeLists.txt +++ b/examples/s4u/CMakeLists.txt @@ -1,7 +1,7 @@ foreach (example actions-comm actions-storage - actor-create actor-daemon actor-execute actor-kill actor-migration actor-suspend + actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend app-masterworker app-pingpong app-token-ring - async-wait async-waitany async-waitall actor-startkilltime + async-wait async-waitany async-waitall plugin-hostload io mutex) add_executable (s4u-${example} ${example}/s4u-${example}.cpp) target_link_libraries(s4u-${example} simgrid) @@ -32,11 +32,12 @@ endforeach() set(examples_src ${examples_src} PARENT_SCOPE) set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent.tesh ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord.tesh + ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime.tesh ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait.tesh ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany.tesh ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall.tesh ${CMAKE_CURRENT_SOURCE_DIR}/actor-execute/s4u-actor-execute.tesh - ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-startkilltime.tesh PARENT_SCOPE) + PARENT_SCOPE) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/s4u-actions-storage_d.xml @@ -47,10 +48,8 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-a ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-baseline_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-kill_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-start_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-star_kill_d.xml PARENT_SCOPE) + ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml + PARENT_SCOPE) set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split-p0.txt ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split-p1.txt ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm.txt @@ -58,9 +57,9 @@ set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-a ${CMAKE_CURRENT_SOURCE_DIR}/README.doc PARENT_SCOPE) foreach(example actions-comm actions-storage - actor-create actor-daemon actor-execute actor-kill actor-migration actor-suspend + actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend app-bittorrent app-masterworker app-pingpong app-token-ring - async-wait async-waitall async-waitany actor-startkilltime + async-wait async-waitall async-waitany dht-chord plugin-hostload io mutex) ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u-${example}.tesh) endforeach() diff --git a/examples/s4u/README.doc b/examples/s4u/README.doc index 58bcb14079..a3763fb427 100644 --- a/examples/s4u/README.doc +++ b/examples/s4u/README.doc @@ -86,10 +86,11 @@ documentation, but it should remain readable directly. @ref examples/s4u/actor-kill/s4u-actor-kill.cpp \n Actors can forcefully stop other actors with the @ref kill method. - - Controling the actor life cycle. - @ref examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp \n - You can specify a start time and a kill time in the deployment - file. See all *_d.xml files in this directory. + - Controling the actor life cycle from the XML. + @ref examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp + @ref examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml + \n + You can specify a start time and a kill time in the deployment file. - Migrating Actors. @ref examples/s4u/actor-migration/s4u-actor-migration.cpp \n @@ -138,6 +139,8 @@ also the tesh files in the example directories for details. @example examples/s4u/actor-daemon/s4u-actor-daemon.cpp @example examples/s4u/actor-execute/s4u-actor-execute.cpp @example examples/s4u/actor-kill/s4u-actor-kill.cpp +@example examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp +@example examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml @example examples/s4u/actor-migration/s4u-actor-migration.cpp @example examples/s4u/actor-suspend/s4u-actor-suspend.cpp @example examples/s4u/app-token-ring/s4u-app-token-ring.cpp diff --git a/examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp b/examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp new file mode 100644 index 0000000000..41a62d5743 --- /dev/null +++ b/examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp @@ -0,0 +1,46 @@ +/* Copyright (c) 2007-2017. 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/s4u.hpp" + +XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific for this s4u example"); + +/* Executed on process termination, to display a message helping to understand the output */ +static int my_onexit(void* ignored1, void* ignored2) +{ + XBT_INFO("Exiting now (done sleeping or got killed)."); + return 0; +} + +/* Just sleep until termination */ +class sleeper { + +public: + explicit sleeper(std::vector args) + { + XBT_INFO("Hello! I go to sleep."); + simcall_process_on_exit(SIMIX_process_self(), my_onexit, NULL); + + simgrid::s4u::this_actor::sleep_for(10); + } + void operator()() { XBT_INFO("Done sleeping."); } +}; + +int main(int argc, char* argv[]) +{ + simgrid::s4u::Engine e(&argc, argv); + + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", + argv[0], argv[0]); + + e.loadPlatform(argv[1]); /* - Load the platform description */ + e.registerFunction("sleeper"); + e.loadDeployment(argv[2]); /* - Deploy the sleeper processes with explicit start/kill times */ + + e.run(); /* - Run the simulation */ + + return 0; +} diff --git a/examples/s4u/actor-lifetime/s4u-actor-lifetime.tesh b/examples/s4u/actor-lifetime/s4u-actor-lifetime.tesh new file mode 100644 index 0000000000..9b525ce2b3 --- /dev/null +++ b/examples/s4u/actor-lifetime/s4u-actor-lifetime.tesh @@ -0,0 +1,14 @@ +#! ./tesh + +$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-lifetime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-lifetime/s4u-actor-lifetime_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep. +> [ 0.000000] (2:sleeper@node-1.acme.org) Hello! I go to sleep. +> [ 2.000000] (3:sleeper@node-0.acme.org) Hello! I go to sleep. +> [ 3.000000] (2:sleeper@node-1.acme.org) Exiting now (done sleeping or got killed). +> [ 4.000000] (4:sleeper@node-2.acme.org) Hello! I go to sleep. +> [ 7.000000] (4:sleeper@node-2.acme.org) Exiting now (done sleeping or got killed). +> [ 10.000000] (1:sleeper@node-0.acme.org) Done sleeping. +> [ 10.000000] (1:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed). +> [ 12.000000] (3:sleeper@node-0.acme.org) Done sleeping. +> [ 12.000000] (3:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed). + diff --git a/examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml b/examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml new file mode 100644 index 0000000000..c69e987886 --- /dev/null +++ b/examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/examples/s4u/actor-startkilltime/s4u-actor-baseline_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-baseline_d.xml deleted file mode 100644 index e24ccedf13..0000000000 --- a/examples/s4u/actor-startkilltime/s4u-actor-baseline_d.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/examples/s4u/actor-startkilltime/s4u-actor-kill_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-kill_d.xml deleted file mode 100644 index 6d7d312410..0000000000 --- a/examples/s4u/actor-startkilltime/s4u-actor-kill_d.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/examples/s4u/actor-startkilltime/s4u-actor-start_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-start_d.xml deleted file mode 100644 index 3d6934b178..0000000000 --- a/examples/s4u/actor-startkilltime/s4u-actor-start_d.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/s4u/actor-startkilltime/s4u-actor-start_kill_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-start_kill_d.xml deleted file mode 100644 index 7292ca2fbb..0000000000 --- a/examples/s4u/actor-startkilltime/s4u-actor-start_kill_d.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp b/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp deleted file mode 100644 index f8ba252b1b..0000000000 --- a/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2007-2016. 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/s4u.hpp" - #include - #include - -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); - -/* Executed on process termination*/ -static int my_onexit(void* ignored1, void *ignored2) { - XBT_INFO("Exiting now (done sleeping or got killed)."); /* - Just display an informative message (see tesh file) */ - return 0; -} - -/* Just sleep until termination */ -class sleeper { - -public: - explicit sleeper(std::vector args) -{ - XBT_INFO("Hello! I go to sleep."); - simcall_process_on_exit(SIMIX_process_self(), my_onexit, NULL); - - simgrid::s4u::this_actor::sleep_for(std::stoi(args[1])); - -} -void operator()() -{ - XBT_INFO("Done sleeping."); -} -}; - -int main(int argc, char *argv[]) -{ - simgrid::s4u::Engine e(&argc, argv); - - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - - e.loadPlatform(argv[1]); /* - Load the platform description */ - e.registerFunction("sleeper"); - e.loadDeployment(argv[2]); /* - Deploy the sleeper processes with explicit start/kill times */ - - e.run(); /* - Run the simulation */ - - XBT_INFO("Simulation time %g", SIMIX_get_clock()); - return 0; -} diff --git a/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.tesh b/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.tesh deleted file mode 100644 index f8e7b5c58f..0000000000 --- a/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.tesh +++ /dev/null @@ -1,63 +0,0 @@ -#! ./tesh - -p Test0 actor without time - -$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-baseline_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep. -> [ 10.000000] (1:sleeper@node-0.acme.org) Done sleeping. -> [ 10.000000] (1:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed). -> [ 10.000000] (0:maestro@) Simulation time 10 - -p Test1 actor with start time - -$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-start_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep. -> [ 1.000000] (2:sleeper@node-1.acme.org) Hello! I go to sleep. -> [ 2.000000] (3:sleeper@node-2.acme.org) Hello! I go to sleep. -> [ 3.000000] (4:sleeper@node-3.acme.org) Hello! I go to sleep. -> [ 4.000000] (5:sleeper@node-4.acme.org) Hello! I go to sleep. -> [ 5.000000] (6:sleeper@node-5.acme.org) Hello! I go to sleep. -> [ 10.000000] (1:sleeper@node-0.acme.org) Done sleeping. -> [ 10.000000] (1:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed). -> [ 11.000000] (2:sleeper@node-1.acme.org) Done sleeping. -> [ 11.000000] (2:sleeper@node-1.acme.org) Exiting now (done sleeping or got killed). -> [ 12.000000] (3:sleeper@node-2.acme.org) Done sleeping. -> [ 12.000000] (3:sleeper@node-2.acme.org) Exiting now (done sleeping or got killed). -> [ 13.000000] (4:sleeper@node-3.acme.org) Done sleeping. -> [ 13.000000] (4:sleeper@node-3.acme.org) Exiting now (done sleeping or got killed). -> [ 14.000000] (5:sleeper@node-4.acme.org) Done sleeping. -> [ 14.000000] (5:sleeper@node-4.acme.org) Exiting now (done sleeping or got killed). -> [ 15.000000] (6:sleeper@node-5.acme.org) Done sleeping. -> [ 15.000000] (6:sleeper@node-5.acme.org) Exiting now (done sleeping or got killed). -> [ 15.000000] (0:maestro@) Simulation time 15 - -p Test1 actor with kill time - -$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-1.acme.org) Hello! I go to sleep. -> [ 0.000000] (2:sleeper@node-2.acme.org) Hello! I go to sleep. -> [ 0.000000] (3:sleeper@node-3.acme.org) Hello! I go to sleep. -> [ 6.000000] (1:sleeper@node-1.acme.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (2:sleeper@node-2.acme.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (3:sleeper@node-3.acme.org) Done sleeping. -> [ 6.000000] (3:sleeper@node-3.acme.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (0:maestro@) Simulation time 6 - -p Test2 actor with start and kill times - -$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-start_kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep. -> [ 1.000000] (2:sleeper@node-1.acme.org) Hello! I go to sleep. -> [ 2.000000] (3:sleeper@node-2.acme.org) Hello! I go to sleep. -> [ 3.000000] (4:sleeper@node-3.acme.org) Hello! I go to sleep. -> [ 4.000000] (5:sleeper@node-4.acme.org) Hello! I go to sleep. -> [ 5.000000] (1:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed). -> [ 5.000000] (6:sleeper@node-5.acme.org) Hello! I go to sleep. -> [ 6.000000] (2:sleeper@node-1.acme.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (3:sleeper@node-2.acme.org) Done sleeping. -> [ 6.000000] (3:sleeper@node-2.acme.org) Exiting now (done sleeping or got killed). -> [ 7.000000] (4:sleeper@node-3.acme.org) Done sleeping. -> [ 7.000000] (4:sleeper@node-3.acme.org) Exiting now (done sleeping or got killed). -> [ 9.000000] (5:sleeper@node-4.acme.org) Exiting now (done sleeping or got killed). -> [ 10.000000] (6:sleeper@node-5.acme.org) Exiting now (done sleeping or got killed). -> [ 10.000000] (0:maestro@) Simulation time 10