From 324a92e9d2403c2fafb9b9d816d8f1d4fffb9f58 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Sat, 2 Dec 2017 11:39:47 +0100 Subject: [PATCH 1/1] move converted MSG process examples to the dungeon --- .gitignore | 9 +++---- examples/msg/CMakeLists.txt | 6 ++--- examples/msg/README.doc | 12 ---------- .../s4u/actor-suspend/s4u-actor-suspend.tesh | 2 +- teshsuite/msg/CMakeLists.txt | 4 ++-- .../msg/process-daemon/process-daemon.c | 0 .../msg/process-daemon/process-daemon.tesh | 2 +- .../msg/process-migration/process-migration.c | 14 +++++------ .../process-migration/process-migration.tesh | 2 +- .../msg/process-suspend/process-suspend.c | 24 +++++++++---------- .../msg/process-suspend/process-suspend.tesh | 2 +- 11 files changed, 33 insertions(+), 44 deletions(-) rename {examples => teshsuite}/msg/process-daemon/process-daemon.c (100%) rename {examples => teshsuite}/msg/process-daemon/process-daemon.tesh (79%) rename {examples => teshsuite}/msg/process-migration/process-migration.c (84%) rename {examples => teshsuite}/msg/process-migration/process-migration.tesh (83%) rename {examples => teshsuite}/msg/process-suspend/process-suspend.c (75%) rename {examples => teshsuite}/msg/process-suspend/process-suspend.tesh (92%) diff --git a/.gitignore b/.gitignore index f9fd051a4d..0d6f60d2d4 100644 --- a/.gitignore +++ b/.gitignore @@ -137,7 +137,6 @@ examples/msg/dht-pastry/dht-pastry examples/msg/energy-consumption/energy-consumption examples/msg/energy-onoff/energy-onoff examples/msg/energy-pstate/energy-pstate -examples/msg/energy-ptask/energy-ptask examples/msg/energy-vm/energy-vm examples/msg/io-file/io-file examples/msg/io-file-unlink/io-file-unlink @@ -146,12 +145,9 @@ examples/msg/io-storage/io-storage examples/msg/platform-failures/platform-failures examples/msg/plugin-hostload/plugin-hostload examples/msg/process-create/process-create -examples/msg/process-daemon/process-daemon examples/msg/process-kill/process-kill examples/msg/process-join/process-join -examples/msg/process-migration/process-migration examples/msg/process-startkilltime/process-startkilltime -examples/msg/process-suspend/process-suspend examples/msg/app-masterworker/app-masterworker examples/msg/mc/bugged1 examples/msg/mc/bugged1_liveness @@ -210,6 +206,7 @@ examples/s4u/basic/s4u-basic_deployment examples/s4u/basic/s4u-basic_function examples/s4u/dht-chord/s4u-dht-chord examples/s4u/energy-link/s4u-energy-link +examples/s4u/energy-ptask/s4u-energy-ptask examples/s4u/io/s4u-io examples/s4u/mutex/s4u-mutex examples/s4u/plugin-hostload/s4u-plugin-hostload @@ -265,6 +262,7 @@ teshsuite/msg/actions-storage/actions-storage teshsuite/msg/app-bittorrent/bittorrent teshsuite/msg/cloud-sharing/cloud-sharing teshsuite/msg/concurrent_rw/concurrent_rw +teshsuite/msg/energy-ptask/energy-ptask teshsuite/msg/get_sender/get_sender teshsuite/msg/host_on_off/host_on_off teshsuite/msg/host_on_off_processes/host_on_off_processes @@ -273,6 +271,9 @@ teshsuite/msg/host_on_off_wait/host_on_off_wait teshsuite/msg/listen_async/listen_async teshsuite/msg/pid/pid teshsuite/msg/process/process +teshsuite/msg/process-daemon/process-daemon +teshsuite/msg/process-migration/process-migration +teshsuite/msg/process-suspend/process-suspend teshsuite/msg/process-yield/process-yield teshsuite/msg/storage_client_server/storage_client_server teshsuite/msg/task_destroy_cancel/task_destroy_cancel diff --git a/examples/msg/CMakeLists.txt b/examples/msg/CMakeLists.txt index be821f78bf..7b17a53644 100644 --- a/examples/msg/CMakeLists.txt +++ b/examples/msg/CMakeLists.txt @@ -4,7 +4,7 @@ foreach(x app-masterworker app-pingpong app-token-ring async-wait async-waitall dht-pastry energy-consumption energy-onoff energy-pstate energy-vm platform-failures io-file io-remote io-storage task-priority plugin-hostload - process-create process-daemon process-join process-migration process-suspend + process-create process-join platform-properties process-startkilltime synchro-semaphore trace-categories trace-route-user-variables trace-link-user-variables trace-masterworker trace-platform trace-process-migration trace-host-user-variables) @@ -83,8 +83,8 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/a foreach(x app-chainsend app-masterworker app-pingpong app-token-ring async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-pastry dht-kademlia platform-failures io-file io-remote io-storage task-priority - process-create process-daemon process-join process-migration process-startkilltime process-suspend - platform-properties synchro-semaphore) + process-create process-join process-startkilltime + platform-properties synchro-semaphore) ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/${x} ${x}.tesh) endforeach() diff --git a/examples/msg/README.doc b/examples/msg/README.doc index 17aeb0a8d5..20898639c7 100644 --- a/examples/msg/README.doc +++ b/examples/msg/README.doc @@ -71,16 +71,6 @@ shipped in the archive: Most processes are started from the deployment XML file, but they can also be used with the @ref MSG_process_create() function. - - Suspend and Resume processes. - @ref examples/msg/process-suspend/process-suspend.c \n - Processes can be suspended and resumed during their executions - thanks to the @ref MSG_process_suspend and @ref MSG_process_resume functions. - - - - Migrating processes. - @ref examples/msg/process-migration/process-migration.c \n - Processes can move or be moved from a host to another with the @ref MSG_process_migrate function. - - Controling the process life cycle from the XML. @ref examples/msg/process-startkilltime/process-startkilltime.c \n You can specify a start time and a kill time in the deployment @@ -228,8 +218,6 @@ top of the example file). @example examples/msg/async-waitany/async-waitany.c @example examples/msg/process-create/process-create.c -@example examples/msg/process-suspend/process-suspend.c -@example examples/msg/process-migration/process-migration.c @example examples/msg/process-startkilltime/process-startkilltime.c @example examples/msg/trace-platform/trace-platform.c diff --git a/examples/s4u/actor-suspend/s4u-actor-suspend.tesh b/examples/s4u/actor-suspend/s4u-actor-suspend.tesh index f5d897c166..54f9cdf123 100644 --- a/examples/s4u/actor-suspend/s4u-actor-suspend.tesh +++ b/examples/s4u/actor-suspend/s4u-actor-suspend.tesh @@ -1,6 +1,6 @@ #! ./tesh -p Testing the suspend/resume feature of MSG +p Testing the suspend/resume feature of S4U ! output sort 19 $ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-suspend ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index bdb83bff3d..62b1507a78 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,6 +1,6 @@ # C examples foreach(x actions-comm actions-storage cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes - process-kill process-yield + process-daemon process-kill process-migration process-suspend process-yield energy-ptask trace_integration) add_executable (${x} ${x}/${x}.c) @@ -56,7 +56,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/acti foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel task_listen_from task_progress - process-kill process-yield + process-daemon process-kill process-migration process-suspend process-yield energy-ptask trace_integration) ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh) diff --git a/examples/msg/process-daemon/process-daemon.c b/teshsuite/msg/process-daemon/process-daemon.c similarity index 100% rename from examples/msg/process-daemon/process-daemon.c rename to teshsuite/msg/process-daemon/process-daemon.c diff --git a/examples/msg/process-daemon/process-daemon.tesh b/teshsuite/msg/process-daemon/process-daemon.tesh similarity index 79% rename from examples/msg/process-daemon/process-daemon.tesh rename to teshsuite/msg/process-daemon/process-daemon.tesh index 25c0f10608..91cf79e7d8 100644 --- a/examples/msg/process-daemon/process-daemon.tesh +++ b/teshsuite/msg/process-daemon/process-daemon.tesh @@ -2,7 +2,7 @@ p Testing the process daemonization feature of MSG -$ $SG_TEST_EXENV ${bindir:=.}/process-daemon ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/process-daemon ${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 diff --git a/examples/msg/process-migration/process-migration.c b/teshsuite/msg/process-migration/process-migration.c similarity index 84% rename from examples/msg/process-migration/process-migration.c rename to teshsuite/msg/process-migration/process-migration.c index e34e950b8e..b9aa9030e7 100644 --- a/examples/msg/process-migration/process-migration.c +++ b/teshsuite/msg/process-migration/process-migration.c @@ -11,13 +11,13 @@ msg_bar_t barrier; static msg_process_t controlled_process = NULL; /* The Emigrant process will be moved from host to host. */ -static int emigrant(int argc, char *argv[]) +static int emigrant(int argc, char* argv[]) { XBT_INFO("I'll look for a new job on another machine ('Boivin') where the grass is greener."); - MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin")); /* - First, move to another host by myself */ + MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin")); /* - First, move to another host by myself */ XBT_INFO("Yeah, found something to do"); - msg_task_t task = MSG_task_create("job", 98095000, 0, NULL); /* - Execute some work there */ + msg_task_t task = MSG_task_create("job", 98095000, 0, NULL); /* - Execute some work there */ MSG_task_execute(task); MSG_task_destroy(task); MSG_process_sleep(2); @@ -35,9 +35,9 @@ static int emigrant(int argc, char *argv[]) } /* The policeman check for emigrants and move them back to 'Jacquelin' */ -static int policeman(int argc, char *argv[]) +static int policeman(int argc, char* argv[]) { - XBT_INFO("Wait at the checkpoint."); /* - block on the mutex+condition */ + XBT_INFO("Wait at the checkpoint."); /* - block on the mutex+condition */ MSG_barrier_wait(barrier); MSG_process_migrate(controlled_process, MSG_host_by_name("Jacquelin")); /* - Move an emigrant to Jacquelin */ XBT_INFO("I moved the emigrant"); @@ -46,12 +46,12 @@ static int policeman(int argc, char *argv[]) return 0; } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { 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]); /* - Load the platform description */ + MSG_create_environment(argv[1]); /* - Load the platform description */ /* - Create and deploy the emigrant and policeman processes */ MSG_process_create("emigrant", emigrant, NULL, MSG_get_host_by_name("Jacquelin")); MSG_process_create("policeman", policeman, NULL, MSG_get_host_by_name("Boivin")); diff --git a/examples/msg/process-migration/process-migration.tesh b/teshsuite/msg/process-migration/process-migration.tesh similarity index 83% rename from examples/msg/process-migration/process-migration.tesh rename to teshsuite/msg/process-migration/process-migration.tesh index 635f3ba59f..9db6b71edd 100644 --- a/examples/msg/process-migration/process-migration.tesh +++ b/teshsuite/msg/process-migration/process-migration.tesh @@ -3,7 +3,7 @@ p Testing the migration feature of MSG ! output sort 19 -$ $SG_TEST_EXENV ${bindir:=.}/process-migration ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/process-migration ${platfdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:emigrant@Jacquelin) I'll look for a new job on another machine ('Boivin') where the grass is greener. > [ 0.000000] (1:emigrant@Boivin) Yeah, found something to do > [ 0.000000] (2:policeman@Boivin) Wait at the checkpoint. diff --git a/examples/msg/process-suspend/process-suspend.c b/teshsuite/msg/process-suspend/process-suspend.c similarity index 75% rename from examples/msg/process-suspend/process-suspend.c rename to teshsuite/msg/process-suspend/process-suspend.c index 19184ef69a..28171b195b 100644 --- a/examples/msg/process-suspend/process-suspend.c +++ b/teshsuite/msg/process-suspend/process-suspend.c @@ -9,13 +9,13 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_suspend, "Messages specific for this msg example"); /* The Lazy guy only wants to sleep, but can be awaken by the dream_master process. */ -static int lazy_guy(int argc, char *argv[]) +static int lazy_guy(int argc, char* argv[]) { XBT_INFO("Nobody's watching me ? Let's go to sleep."); - MSG_process_suspend(MSG_process_self()); /* - Start by suspending itself */ + MSG_process_suspend(MSG_process_self()); /* - Start by suspending itself */ XBT_INFO("Uuuh ? Did somebody call me ?"); - XBT_INFO("Going to sleep..."); /* - Then repetitively go to sleep, but got awaken */ + XBT_INFO("Going to sleep..."); /* - Then repetitively go to sleep, but got awaken */ MSG_process_sleep(10.0); XBT_INFO("Mmm... waking up."); @@ -33,22 +33,22 @@ static int lazy_guy(int argc, char *argv[]) } /* The Dream master: */ -static int dream_master(int argc, char *argv[]) +static int dream_master(int argc, char* argv[]) { XBT_INFO("Let's create a lazy guy."); /* - Create a lazy_guy process */ msg_process_t lazy = MSG_process_create("Lazy", lazy_guy, NULL, MSG_host_self()); XBT_INFO("Let's wait a little bit..."); - MSG_process_sleep(10.0); /* - Wait for 10 seconds */ + MSG_process_sleep(10.0); /* - Wait for 10 seconds */ XBT_INFO("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!"); - MSG_process_resume(lazy); /* - Then wake up the lazy_guy */ + MSG_process_resume(lazy); /* - Then wake up the lazy_guy */ - MSG_process_sleep(5.0); /* Repeat two times: */ + MSG_process_sleep(5.0); /* Repeat two times: */ XBT_INFO("Suspend the lazy guy while he's sleeping..."); - MSG_process_suspend(lazy); /* - Suspend the lazy_guy while he's asleep */ + MSG_process_suspend(lazy); /* - Suspend the lazy_guy while he's asleep */ XBT_INFO("Let him finish his siesta."); - MSG_process_sleep(10.0); /* - Wait for 10 seconds */ + MSG_process_sleep(10.0); /* - Wait for 10 seconds */ XBT_INFO("Wake up, lazy guy!"); - MSG_process_resume(lazy); /* - Then wake up the lazy_guy again */ + MSG_process_resume(lazy); /* - Then wake up the lazy_guy again */ MSG_process_sleep(5.0); XBT_INFO("Suspend again the lazy guy while he's sleeping..."); @@ -69,12 +69,12 @@ static int dream_master(int argc, char *argv[]) return 0; } -int main(int argc, char *argv[]) +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]); /* - Load the platform description */ + MSG_create_environment(argv[1]); /* - Load the platform description */ MSG_function_register("dream_master", dream_master); /* - Create and deploy the dream_master */ xbt_dynar_t hosts = MSG_hosts_as_dynar(); MSG_process_create("dream_master", dream_master, NULL, xbt_dynar_getfirst_as(hosts, msg_host_t)); diff --git a/examples/msg/process-suspend/process-suspend.tesh b/teshsuite/msg/process-suspend/process-suspend.tesh similarity index 92% rename from examples/msg/process-suspend/process-suspend.tesh rename to teshsuite/msg/process-suspend/process-suspend.tesh index 2e406c4e7e..b3e0962fb4 100644 --- a/examples/msg/process-suspend/process-suspend.tesh +++ b/teshsuite/msg/process-suspend/process-suspend.tesh @@ -3,7 +3,7 @@ p Testing the suspend/resume feature of MSG ! output sort 19 -$ $SG_TEST_EXENV ${bindir:=.}/process-suspend ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/process-suspend ${platfdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:dream_master@Boivin) Let's create a lazy guy. > [ 0.000000] (2:Lazy@Boivin) Nobody's watching me ? Let's go to sleep. > [ 0.000000] (1:dream_master@Boivin) Let's wait a little bit... -- 2.20.1