From 0e4dfc88e449759be5ef90a53c7fcb828e555af2 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 4 Mar 2020 13:15:28 +0100 Subject: [PATCH] convert and simplify msg/process-lifetime --- .gitignore | 3 + MANIFEST.in | 9 +-- examples/c/CMakeLists.txt | 7 +- examples/c/actor-lifetime/actor-lifetime.c | 48 ++++++++++++++ examples/c/actor-lifetime/actor-lifetime.tesh | 13 ++++ .../c/actor-lifetime/actor-lifetime_d.xml | 8 +++ .../actor-lifetime/s4u-actor-lifetime.tesh | 1 - teshsuite/msg/CMakeLists.txt | 6 -- teshsuite/msg/process-lifetime/baseline_d.xml | 8 --- teshsuite/msg/process-lifetime/kill_d.xml | 13 ---- .../msg/process-lifetime/process-lifetime.c | 45 ------------- .../process-lifetime/process-lifetime.tesh | 65 ------------------- teshsuite/msg/process-lifetime/start_d.xml | 22 ------- .../msg/process-lifetime/start_kill_d.xml | 22 ------- 14 files changed, 80 insertions(+), 190 deletions(-) create mode 100644 examples/c/actor-lifetime/actor-lifetime.c create mode 100644 examples/c/actor-lifetime/actor-lifetime.tesh create mode 100644 examples/c/actor-lifetime/actor-lifetime_d.xml delete mode 100644 teshsuite/msg/process-lifetime/baseline_d.xml delete mode 100644 teshsuite/msg/process-lifetime/kill_d.xml delete mode 100644 teshsuite/msg/process-lifetime/process-lifetime.c delete mode 100644 teshsuite/msg/process-lifetime/process-lifetime.tesh delete mode 100644 teshsuite/msg/process-lifetime/start_d.xml delete mode 100644 teshsuite/msg/process-lifetime/start_kill_d.xml diff --git a/.gitignore b/.gitignore index 80d0695a7a..fe6000b9cb 100644 --- a/.gitignore +++ b/.gitignore @@ -122,18 +122,21 @@ examples/c/actor-daemon/actor-daemon-c examples/c/actor-exiting/actor-exiting-c examples/c/actor-join/actor-join-c examples/c/actor-kill/actor-kill-c +examples/c/actor-lifetime/actor-lifetime-c examples/c/actor-migrate/actor-migrate-c examples/c/actor-suspend/actor-suspend-c examples/c/actor-yield/actor-yield-c examples/c/app-chainsend/app-chainsend-c examples/c/app-pingpong/app-pingpong-c examples/c/app-token-ring/app-token-ring-c +examples/c/async-wait/async-wait-c examples/c/async-waitall/async-waitall-c examples/c/async-waitany/async-waitany-c examples/c/cloud-capping/cloud-capping-c examples/c/cloud-migration/cloud-migration-c examples/c/cloud-simple/cloud-simple-c examples/c/energy-exec/energy-exec-c +examples/c/energy-exec-ptask/energy-exec-ptask-c examples/c/energy-vm/energy-vm-c examples/c/exec-dvfs/exec-dvfs-c examples/c/io-disk-raw/io-disk-raw-c diff --git a/MANIFEST.in b/MANIFEST.in index f87c2662f8..f0e936d3ff 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -27,6 +27,9 @@ include examples/c/actor-join/actor-join.c include examples/c/actor-join/actor-join.tesh include examples/c/actor-kill/actor-kill.c include examples/c/actor-kill/actor-kill.tesh +include examples/c/actor-lifetime/actor-lifetime.c +include examples/c/actor-lifetime/actor-lifetime.tesh +include examples/c/actor-lifetime/actor-lifetime_d.xml include examples/c/actor-migrate/actor-migrate.c include examples/c/actor-migrate/actor-migrate.tesh include examples/c/actor-suspend/actor-suspend.c @@ -667,12 +670,6 @@ include teshsuite/msg/io-file/io-file.tesh include teshsuite/msg/platform-properties/platform-properties.c include teshsuite/msg/platform-properties/platform-properties.tesh include teshsuite/msg/platform-properties/platform-properties_d.xml -include teshsuite/msg/process-lifetime/baseline_d.xml -include teshsuite/msg/process-lifetime/kill_d.xml -include teshsuite/msg/process-lifetime/process-lifetime.c -include teshsuite/msg/process-lifetime/process-lifetime.tesh -include teshsuite/msg/process-lifetime/start_d.xml -include teshsuite/msg/process-lifetime/start_kill_d.xml include teshsuite/msg/task-priority/task-priority.c include teshsuite/msg/task-priority/task-priority.tesh include teshsuite/msg/task-priority/task-priority_d.xml diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index 6ceedc41f1..ed0ddcf6eb 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -2,7 +2,8 @@ ###################################################################### foreach(x - actor-create actor-daemon actor-exiting actor-join actor-kill actor-migrate actor-suspend actor-yield + actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-suspend + actor-yield app-pingpong app-token-ring async-wait async-waitall async-waitany cloud-capping cloud-migration cloud-simple @@ -42,6 +43,7 @@ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/app-ch PARENT_SCOPE) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/actor-create_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/actor-lifetime_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/actor-yield_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/app-chainsend_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/app-pingpong_d.xml @@ -55,7 +57,8 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/actor-cr PARENT_SCOPE) foreach(x - actor-create actor-daemon actor-exiting actor-join actor-kill actor-migrate actor-suspend actor-yield + actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-suspend + actor-yield app-chainsend app-pingpong app-token-ring async-wait async-waitall async-waitany cloud-capping cloud-migration cloud-simple diff --git a/examples/c/actor-lifetime/actor-lifetime.c b/examples/c/actor-lifetime/actor-lifetime.c new file mode 100644 index 0000000000..f980f667b6 --- /dev/null +++ b/examples/c/actor-lifetime/actor-lifetime.c @@ -0,0 +1,48 @@ +/* Copyright (c) 2007-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 "xbt/asserts.h" +#include "xbt/log.h" + +#include /* snprintf */ + +XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific for this example"); + +/* Executed on process termination*/ +static int my_onexit(XBT_ATTRIB_UNUSED int ignored1, XBT_ATTRIB_UNUSED 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 */ +static void sleeper(int argc, char* argv[]) +{ + sg_actor_on_exit(my_onexit, NULL); + + XBT_INFO("Hello! I go to sleep."); + sg_actor_sleep_for(10); + XBT_INFO("Done sleeping."); +} + +int main(int argc, char* argv[]) +{ + simgrid_init(&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]); + + simgrid_load_platform(argv[1]); /* - Load the platform description */ + simgrid_register_function("sleeper", sleeper); + simgrid_load_deployment(argv[2]); /* - Deploy the sleeper processes with explicit start/kill times */ + + simgrid_run(); /* - Run the simulation */ + + return 0; +} diff --git a/examples/c/actor-lifetime/actor-lifetime.tesh b/examples/c/actor-lifetime/actor-lifetime.tesh new file mode 100644 index 0000000000..ba0616e44c --- /dev/null +++ b/examples/c/actor-lifetime/actor-lifetime.tesh @@ -0,0 +1,13 @@ +#!/usr/bin/env tesh + +$ ${bindir:=.}/actor-lifetime-c ${platfdir}/cluster_backbone.xml actor-lifetime_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:sleeper@node-0.simgrid.org) Hello! I go to sleep. +> [ 0.000000] (2:sleeper@node-1.simgrid.org) Hello! I go to sleep. +> [ 2.000000] (3:sleeper@node-0.simgrid.org) Hello! I go to sleep. +> [ 3.000000] (2:sleeper@node-1.simgrid.org) Exiting now (done sleeping or got killed). +> [ 4.000000] (4:sleeper@node-2.simgrid.org) Hello! I go to sleep. +> [ 7.000000] (4:sleeper@node-2.simgrid.org) Exiting now (done sleeping or got killed). +> [ 10.000000] (1:sleeper@node-0.simgrid.org) Done sleeping. +> [ 10.000000] (1:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed). +> [ 12.000000] (3:sleeper@node-0.simgrid.org) Done sleeping. +> [ 12.000000] (3:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed). diff --git a/examples/c/actor-lifetime/actor-lifetime_d.xml b/examples/c/actor-lifetime/actor-lifetime_d.xml new file mode 100644 index 0000000000..dd59a51c48 --- /dev/null +++ b/examples/c/actor-lifetime/actor-lifetime_d.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/examples/s4u/actor-lifetime/s4u-actor-lifetime.tesh b/examples/s4u/actor-lifetime/s4u-actor-lifetime.tesh index c3d3b15a29..082c1121d8 100644 --- a/examples/s4u/actor-lifetime/s4u-actor-lifetime.tesh +++ b/examples/s4u/actor-lifetime/s4u-actor-lifetime.tesh @@ -11,4 +11,3 @@ $ ${bindir:=.}/s4u-actor-lifetime ${platfdir}/cluster_backbone.xml s4u-actor-lif > [ 10.000000] (1:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed). > [ 12.000000] (3:sleeper@node-0.simgrid.org) Done sleeping. > [ 12.000000] (3:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed). - diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index a1f800bc73..e4dc4c4374 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,7 +1,6 @@ # C examples foreach(x cloud-two-tasks get_sender - process-lifetime platform-properties io-file task-priority @@ -46,10 +45,6 @@ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/ap set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/generate.py PARENT_SCOPE) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/app-bittorrent_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/platform-properties_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/process-lifetime/baseline_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/process-lifetime/kill_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/process-lifetime/start_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/process-lifetime/start_kill_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/task-priority/task-priority_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp1.0-hbp1.0.xml ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp3.0-hbp4.0.xml @@ -71,7 +66,6 @@ if(enable_msg) host_on_off_processes get_sender task_destroy_cancel task_listen_from task_progress - process-lifetime io-file platform-properties task-priority diff --git a/teshsuite/msg/process-lifetime/baseline_d.xml b/teshsuite/msg/process-lifetime/baseline_d.xml deleted file mode 100644 index c43dc771e5..0000000000 --- a/teshsuite/msg/process-lifetime/baseline_d.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/teshsuite/msg/process-lifetime/kill_d.xml b/teshsuite/msg/process-lifetime/kill_d.xml deleted file mode 100644 index 1d386bc9b6..0000000000 --- a/teshsuite/msg/process-lifetime/kill_d.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/teshsuite/msg/process-lifetime/process-lifetime.c b/teshsuite/msg/process-lifetime/process-lifetime.c deleted file mode 100644 index 4454ee817a..0000000000 --- a/teshsuite/msg/process-lifetime/process-lifetime.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2007-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 /* snprintf */ - -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); - -/* Executed on process termination*/ -static int my_onexit(XBT_ATTRIB_UNUSED int ignored1, XBT_ATTRIB_UNUSED 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 */ -static int sleeper(int argc, char* argv[]) -{ - xbt_assert(argc == 2); - XBT_INFO("Hello! I go to sleep."); - MSG_process_on_exit(my_onexit, NULL); - - MSG_process_sleep(xbt_str_parse_int(argv[1], "sleeper process expects an integer parameter but got %s")); - XBT_INFO("Done sleeping."); - return 0; -} - -int main(int argc, char* argv[]) -{ - MSG_init(&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]); - - MSG_create_environment(argv[1]); /* - Load the platform description */ - MSG_function_register("sleeper", sleeper); - MSG_launch_application(argv[2]); /* - Deploy the sleeper processes with explicit start/kill times */ - - msg_error_t res = MSG_main(); /* - Run the simulation */ - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res != MSG_OK; -} diff --git a/teshsuite/msg/process-lifetime/process-lifetime.tesh b/teshsuite/msg/process-lifetime/process-lifetime.tesh deleted file mode 100644 index 8f102839d9..0000000000 --- a/teshsuite/msg/process-lifetime/process-lifetime.tesh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env tesh - -p Test0 Process without time - -$ ${bindir:=.}/process-lifetime ${platfdir}/cluster_backbone.xml ${srcdir:=.}/baseline_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-0.simgrid.org) Hello! I go to sleep. -> [ 10.000000] (1:sleeper@node-0.simgrid.org) Done sleeping. -> [ 10.000000] (1:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed). -> [ 10.000000] (0:maestro@) Simulation time 10 - -p Test1 Process with start time - -$ ${bindir:=.}/process-lifetime ${platfdir}/cluster_backbone.xml ${srcdir:=.}/start_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-0.simgrid.org) Hello! I go to sleep. -> [ 1.000000] (2:sleeper@node-1.simgrid.org) Hello! I go to sleep. -> [ 2.000000] (3:sleeper@node-2.simgrid.org) Hello! I go to sleep. -> [ 3.000000] (4:sleeper@node-3.simgrid.org) Hello! I go to sleep. -> [ 4.000000] (5:sleeper@node-4.simgrid.org) Hello! I go to sleep. -> [ 5.000000] (6:sleeper@node-5.simgrid.org) Hello! I go to sleep. -> [ 10.000000] (1:sleeper@node-0.simgrid.org) Done sleeping. -> [ 10.000000] (1:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed). -> [ 11.000000] (2:sleeper@node-1.simgrid.org) Done sleeping. -> [ 11.000000] (2:sleeper@node-1.simgrid.org) Exiting now (done sleeping or got killed). -> [ 12.000000] (3:sleeper@node-2.simgrid.org) Done sleeping. -> [ 12.000000] (3:sleeper@node-2.simgrid.org) Exiting now (done sleeping or got killed). -> [ 13.000000] (4:sleeper@node-3.simgrid.org) Done sleeping. -> [ 13.000000] (4:sleeper@node-3.simgrid.org) Exiting now (done sleeping or got killed). -> [ 14.000000] (5:sleeper@node-4.simgrid.org) Done sleeping. -> [ 14.000000] (5:sleeper@node-4.simgrid.org) Exiting now (done sleeping or got killed). -> [ 15.000000] (6:sleeper@node-5.simgrid.org) Done sleeping. -> [ 15.000000] (6:sleeper@node-5.simgrid.org) Exiting now (done sleeping or got killed). -> [ 15.000000] (0:maestro@) Simulation time 15 - -p Test1 Process with kill time - -! output sort -$ ${bindir:=.}/process-lifetime ${platfdir}/cluster_backbone.xml ${srcdir:=.}/kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-1.simgrid.org) Hello! I go to sleep. -> [ 0.000000] (2:sleeper@node-2.simgrid.org) Hello! I go to sleep. -> [ 0.000000] (3:sleeper@node-3.simgrid.org) Hello! I go to sleep. -> [ 6.000000] (1:sleeper@node-1.simgrid.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (2:sleeper@node-2.simgrid.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (3:sleeper@node-3.simgrid.org) Done sleeping. -> [ 6.000000] (3:sleeper@node-3.simgrid.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (0:maestro@) Simulation time 6 - -p Test2 Process with start and kill times - -! output sort -$ ${bindir:=.}/process-lifetime ${platfdir}/cluster_backbone.xml ${srcdir:=.}/start_kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:sleeper@node-0.simgrid.org) Hello! I go to sleep. -> [ 1.000000] (2:sleeper@node-1.simgrid.org) Hello! I go to sleep. -> [ 2.000000] (3:sleeper@node-2.simgrid.org) Hello! I go to sleep. -> [ 3.000000] (4:sleeper@node-3.simgrid.org) Hello! I go to sleep. -> [ 4.000000] (5:sleeper@node-4.simgrid.org) Hello! I go to sleep. -> [ 5.000000] (1:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed). -> [ 5.000000] (6:sleeper@node-5.simgrid.org) Hello! I go to sleep. -> [ 6.000000] (2:sleeper@node-1.simgrid.org) Exiting now (done sleeping or got killed). -> [ 6.000000] (3:sleeper@node-2.simgrid.org) Done sleeping. -> [ 6.000000] (3:sleeper@node-2.simgrid.org) Exiting now (done sleeping or got killed). -> [ 7.000000] (4:sleeper@node-3.simgrid.org) Done sleeping. -> [ 7.000000] (4:sleeper@node-3.simgrid.org) Exiting now (done sleeping or got killed). -> [ 9.000000] (5:sleeper@node-4.simgrid.org) Exiting now (done sleeping or got killed). -> [ 10.000000] (6:sleeper@node-5.simgrid.org) Exiting now (done sleeping or got killed). -> [ 10.000000] (0:maestro@) Simulation time 10 diff --git a/teshsuite/msg/process-lifetime/start_d.xml b/teshsuite/msg/process-lifetime/start_d.xml deleted file mode 100644 index e26d0c89ea..0000000000 --- a/teshsuite/msg/process-lifetime/start_d.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/teshsuite/msg/process-lifetime/start_kill_d.xml b/teshsuite/msg/process-lifetime/start_kill_d.xml deleted file mode 100644 index 86c326698f..0000000000 --- a/teshsuite/msg/process-lifetime/start_kill_d.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -- 2.20.1