-foreach (example actor-create actor-daemon actor-join actor-kill actor-kill-pid
+foreach (example actor-create actor-daemon actor-join actor-kill
actor-lifetime actor-migration actor-suspend actor-yield
app-chainsend app-masterworker app-pingpong app-token-ring
async-wait async-waitany async-waitall
${CMAKE_CURRENT_SOURCE_DIR}/replay-storage/s4u-replay-storage.txt
${CMAKE_CURRENT_SOURCE_DIR}/README.doc PARENT_SCOPE)
-foreach(example actor-create actor-daemon actor-join actor-kill actor-kill-pid
+foreach(example actor-create actor-daemon actor-join actor-kill
actor-lifetime actor-migration actor-suspend actor-yield
app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
async-wait async-waitall async-waitany
+++ /dev/null
-/* Copyright (c) 2017-2018 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(s4u_actor_kill_pid, "Messages specific for this s4u example");
-
-static int on_exit(void*, void*)
-{
- XBT_INFO("I have been killed!");
- return 0;
-}
-
-static void victimA_fun()
-{
- simgrid::s4u::this_actor::onExit(on_exit, nullptr);
- XBT_INFO("Hello!");
- XBT_INFO("Suspending myself");
- simgrid::s4u::this_actor::suspend(); /* - Start by suspending itself */
- XBT_INFO("OK, OK. Let's work"); /* - Then is resumed and start to execute a task */
- simgrid::s4u::this_actor::execute(1e9);
- XBT_INFO("Bye!"); /* - But will never reach the end of it */
-}
-
-static void victimB_fun()
-{
- XBT_INFO("Terminate before being killed");
-}
-
-static void killer()
-{
- XBT_INFO("Hello!"); /* - First start a victim process */
- simgrid::s4u::ActorPtr victimA =
- simgrid::s4u::Actor::createActor("victim A", simgrid::s4u::Host::by_name("Fafard"), victimA_fun);
- simgrid::s4u::ActorPtr victimB =
- simgrid::s4u::Actor::createActor("victim B", simgrid::s4u::Host::by_name("Jupiter"), victimB_fun);
- simgrid::s4u::this_actor::sleep_for(10); /* - Wait for 10 seconds */
-
- XBT_INFO("Resume the victim A"); /* - Resume it from its suspended state */
- victimA->resume();
- simgrid::s4u::this_actor::sleep_for(2);
-
- aid_t pidA = victimA->getPid();
- XBT_INFO("Kill the victim A (pid=%lu)", pidA); /* - and then kill it */
- simgrid::s4u::Actor::kill(pidA);
-
- aid_t pidB = victimB->getPid();
- XBT_INFO("Kill victimB (pid=%lu), even if it's already dead", pidB); /* that's a no-op, there is no zombies in SimGrid */
- try
- {
- simgrid::s4u::Actor::kill(pidB);
- } catch (const std::runtime_error& e) {
- XBT_DEBUG("Caught exception: %s", e.what());
- }
- simgrid::s4u::this_actor::sleep_for(1);
-
- XBT_INFO("Killing everybody but myself");
- simgrid::s4u::Actor::killAll();
-
- aid_t pidMe = simgrid::s4u::this_actor::getPid();
- XBT_INFO("OK, goodbye now. I commit a suicide (pid=%lu).", pidMe);
- simgrid::s4u::Actor::kill(pidMe);
-
- XBT_INFO("This line will never get displayed: I'm already dead since the previous line.");
-}
-
-int main(int argc, char* argv[])
-{
- simgrid::s4u::Engine e(&argc, argv);
- xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
-
- e.loadPlatform(argv[1]); /* - Load the platform description */
- /* - Create and deploy killer process, that will create the victim actors */
- simgrid::s4u::Actor::createActor("killer", simgrid::s4u::Host::by_name("Tremblay"), killer);
-
- e.run(); /* - Run the simulation */
-
- XBT_INFO("Simulation time %g", e.getClock());
-
- return 0;
-}
+++ /dev/null
-#!/usr/bin/env tesh
-
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-kill-pid ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n"
->[ 0.000000] (killer@Tremblay) Hello!
->[ 0.000000] (victim A@Fafard) Hello!
->[ 0.000000] (victim A@Fafard) Suspending myself
->[ 0.000000] (victim B@Jupiter) Terminate before being killed
->[ 10.000000] (killer@Tremblay) Resume the victim A
->[ 10.000000] (victim A@Fafard) OK, OK. Let's work
->[ 12.000000] (killer@Tremblay) Kill the victim A (pid=2)
->[ 12.000000] (victim A@Fafard) I have been killed!
->[ 12.000000] (killer@Tremblay) Kill victimB (pid=3), even if it's already dead
->[ 13.000000] (killer@Tremblay) Killing everybody but myself
->[ 13.000000] (killer@Tremblay) OK, goodbye now. I commit a suicide (pid=1).
->[ 13.000000] (maestro@) Simulation time 13
> [ 10.000000] (victim A@Fafard) OK, OK. Let's work
> [ 12.000000] (killer@Tremblay) Kill the victim A
> [ 12.000000] (victim A@Fafard) I have been killed!
-> [ 12.000000] (killer@Tremblay) Kill victimB, even if it's already dead
-> [ 13.000000] (killer@Tremblay) Killing everybody but myself
-> [ 13.000000] (killer@Tremblay) OK, goodbye now. I commit a suicide.
-> [ 13.000000] (maestro@) Simulation time 13
+> [ 13.000000] (killer@Tremblay) Kill victimB, even if it's already dead
+> [ 14.000000] (killer@Tremblay) Killing everybody but myself
+> [ 14.000000] (killer@Tremblay) OK, goodbye now. I commit a suicide.
+> [ 14.000000] (maestro@) Simulation time 14