X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fa222c38f9b796be07ab4351ffc810a61a8fd705..28bb7c8be1ed83295ff75f57c086493733a11228:/teshsuite/msg/pid/pid.c diff --git a/teshsuite/msg/pid/pid.c b/teshsuite/msg/pid/pid.c index 483ca0be0e..f47aa0741b 100644 --- a/teshsuite/msg/pid/pid.c +++ b/teshsuite/msg/pid/pid.c @@ -5,15 +5,14 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/msg.h" -#include "xbt/sysdep.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); + const char* mailbox = "mailbox"; #define task_comp_size 1000 #define task_comm_size 100000 -static int onexit(smx_process_exit_status_t status, int *pid){ +static int my_onexit(smx_process_exit_status_t status, int *pid){ XBT_INFO("Process \"%d\" killed.", *pid); return 0; } @@ -21,7 +20,7 @@ static int onexit(smx_process_exit_status_t status, int *pid){ static int sendpid(int argc, char *argv[]) { int pid = MSG_process_self_PID(); - MSG_process_on_exit((int_f_pvoid_pvoid_t)onexit, &pid); + MSG_process_on_exit((int_f_pvoid_pvoid_t)my_onexit, &pid); msg_task_t task = MSG_task_create("pid", task_comp_size, task_comm_size, &pid); XBT_INFO("Sending pid of \"%d\".", pid); MSG_task_send(task, mailbox); @@ -32,9 +31,9 @@ static int sendpid(int argc, char *argv[]) static int killall(int argc, char *argv[]){ msg_task_t task = NULL; - _XBT_GNUC_UNUSED int res; - int i; - for (i=0; i<3;i++) { + XBT_ATTRIB_UNUSED int res; + + for (int i=0; i<3;i++) { res = MSG_task_receive(&(task), mailbox); int pid = *(int*)MSG_task_get_data(task); MSG_task_destroy(task); @@ -45,25 +44,21 @@ static int killall(int argc, char *argv[]){ return 0; } -/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); - /* Application deployment */ - MSG_function_register("sendpid", &sendpid); - MSG_function_register("killall", &killall); - - MSG_process_killall(atoi(argv[3])); + MSG_process_killall(atoi(argv[2])); MSG_create_environment(argv[1]); - MSG_launch_application(argv[2]); + MSG_process_create("sendpid", sendpid, NULL, MSG_get_host_by_name("Tremblay")); + MSG_process_create("sendpid", sendpid, NULL, MSG_get_host_by_name("Tremblay")); + MSG_process_create("sendpid", sendpid, NULL, MSG_get_host_by_name("Tremblay")); + MSG_process_create("killall", killall, NULL, MSG_get_host_by_name("Tremblay")); + res = MSG_main(); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; }