-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2021. 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/engine.h"
#include "simgrid/forward.h"
#include "simgrid/mailbox.h"
-#include "xbt/asserts.h"
#include "xbt/log.h"
#include "xbt/str.h"
+#include "xbt/sysdep.h"
#define FINALIZE 221297 /* a magic number to tell people to stop working */
XBT_LOG_NEW_DEFAULT_CATEGORY(app_masterworker, "Messages specific for this example");
-/* Main function of the master process */
+/* Main function of the master actor */
static void master(int argc, char* argv[])
{
xbt_assert(argc == 5, "The master function expects 4 arguments from the XML deployment file");
- long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); /* - Number of tasks */
- double comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - Compute cost */
- long comm_size = xbt_str_parse_int(argv[3], "Invalid communication size: %s"); /* - Communication size */
- long workers_count = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s"); /* - Number of workers */
+ long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks"); /* - Number of tasks */
+ double comp_size = xbt_str_parse_double(argv[2], "Invalid computational size"); /* - Compute cost */
+ long comm_size = xbt_str_parse_int(argv[3], "Invalid communication size"); /* - Communication size */
+ long workers_count = xbt_str_parse_int(argv[4], "Invalid amount of workers"); /* - Number of workers */
XBT_INFO("Got %ld workers and %ld tasks to process", workers_count, number_of_tasks);
}
}
-/* Main functions of the Worker processes */
+/* Main functions of the Worker actors */
static void worker(int argc, char* argv[])
{
xbt_assert(argc == 2,
"The worker expects a single argument from the XML deployment file: its worker ID (its numerical rank)");
char mailbox_name[80];
- long id = xbt_str_parse_int(argv[1], "Invalid argument %s");
+ long id = xbt_str_parse_int(argv[1], "Invalid argument");
snprintf(mailbox_name, 79, "worker-%ld", id);
sg_mailbox_t mailbox = sg_mailbox_by_name(mailbox_name);
simgrid_init(&argc, argv);
xbt_assert(argc > 2,
"Usage: %s platform_file deployment_file\n"
- "\tExample: %s msg_platform.xml msg_deployment.xml\n",
+ "\tExample: %s platform.xml deployment.xml\n",
argv[0], argv[0]);
simgrid_load_platform(argv[1]); /* - Load the platform description */
- simgrid_register_function("master", master); /* - Register the function to be executed by the processes */
+ simgrid_register_function("master", master); /* - Register the function to be executed by the actors */
simgrid_register_function("worker", worker);
simgrid_load_deployment(argv[2]); /* - Deploy the application */