examples/msg/process-suspend/process-suspend
examples/msg/app-token-ring/app-token-ring
examples/msg/trace-categories/trace-categories
-examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables
+examples/msg/trace-route-user-variables/trace-route-user-variables
examples/msg/trace-link-user-variables/trace-link-user-variables
examples/msg/trace-masterworker/trace-masterworker
examples/msg/trace-process-migration/trace-process-migration
examples/msg/trace-simple/trace-simple
examples/msg/trace-platform/trace-platform
-examples/msg/trace-user-variables/trace-user-variables
+examples/msg/trace-host-user-variables/trace-host-user-variables
examples/s4u/basic/s4u_basic
examples/s4u/io/s4u_io
examples/simdag/daxload/sd_daxload
@CMAKE_HOME_DIRECTORY@/src/simdag \
@CMAKE_HOME_DIRECTORY@/src/simix \
@CMAKE_BINARY_DIR@/include \
- @CMAKE_BINARY_DIR@/src
-
-
-###################################################
-## PLEASE DON'T MESS WITH THE ORDER OF EXAMPLES ## (unless you know what you are doing, of course)
-###################################################
-
-INPUT += @CMAKE_HOME_DIRECTORY@/examples/msg/README.doc \
- @CMAKE_HOME_DIRECTORY@/examples/msg/process-suspend/process-suspend.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/process-kill/process-kill.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/process-migration/process-migration.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/process-startkilltime/process-startkilltime.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-simple/trace-simple.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-platform/trace-platform.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-categories/trace-categories.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-masterworker/trace-masterworker.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-process-migration/trace-process-migration.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-user-variables/trace-user-variables.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-link-user-variables/trace-link-user-variables.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/network-ns3/network-ns3.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/io-storage/io-storage.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/io-file/io-file.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/io-remote/io-remote.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/actions-comm/actions-comm.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/actions-storage/actions-storage.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/app-pmm/ \
- @CMAKE_HOME_DIRECTORY@/examples/msg/dht-chord \
- @CMAKE_HOME_DIRECTORY@/examples/msg/task-priority/task-priority.c \
- @CMAKE_HOME_DIRECTORY@/examples/msg/properties/properties.c
+ @CMAKE_BINARY_DIR@/src \
+ @CMAKE_HOME_DIRECTORY@/examples/msg/README.doc
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
dht-chord dht-pastry energy-consumption energy-onoff energy-pstate energy-ptask energy-vm platform-failures
io-file io-remote io-storage task-priority process-kill process-migration process-suspend
platform-properties maestro-set process-startkilltime synchro-semaphore trace-categories
- trace-link-srcdst-user-variables trace-link-user-variables trace-masterworker trace-platform
- trace-process-migration trace-simple trace-user-variables)
+ trace-route-user-variables trace-link-user-variables trace-masterworker trace-platform
+ trace-process-migration trace-simple trace-host-user-variables)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
ADD_TESH_FACTORIES(msg-energy-${example} "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-${example}/energy-${example}.tesh)
endforeach()
-foreach (x categories link-srcdst-user-variables link-user-variables masterworker platform process-migration simple user-variables)
+foreach (x categories route-user-variables link-user-variables masterworker platform process-migration simple host-user-variables)
ADD_TESH(msg-trace-${x} --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/trace-${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/trace-${x} trace-${x}.tesh)
endforeach()
-This file follows the Doxygen syntax to be included in the documentation.
+This file follows the Doxygen syntax to be included in the
+documentation, but it should remain readable directly.
/**
@defgroup MSG_examples MSG examples
- @ref msg_ex_async
- @ref msg_ex_process
- @ref msg_ex_tracing
- - @ref msg_ex_tracing_user_variables
+ - @ref msg_ex_tracing_user_variables
- @ref msg_ex_models
- - @ref msg_ex_io
+ - @ref msg_ex_ns3
+ - @ref msg_ex_io
- @ref msg_ex_actions
- - @ref msg_ex_full_apps
+ - @ref msg_ex_apps
- @ref msg_ex_misc
@section msg_ex_basic Basic examples and features
until one activity of the set completes, no matter which terminates
first.
+@section msg_ex_process Acting on Processes
+
+ - <b>Suspend and Resume processes</b>.
+ @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.
+
+ - <b>Kill processes</b>.
+ @ref examples/msg/process-kill/process-kill.c \n
+ Processes can forcefully stop other processes with the @ref MSG_process_kill function.
+
+ - <b>Migrating processes</b>.
+ @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.
+
+ - <b>Controling the process life cycle from the XML</b>.
+ @ref examples/msg/process-startkilltime/process-startkilltime.c \n
+ You can specify a start time and a kill time in the deployment
+ file. See all *_d.xml files in this directory.
+
+TODO: add an example using @ref MSG_process_create()
+
+@section msg_ex_tracing Tracing and visualization features
+
+Tracing can be activated by various configuration options which
+are illustrated in these example. See also the
+@ref tracing_tracing_options "full list of options related to tracing".
+
+ - <b>Basic example</b>. @ref examples/msg/trace-simple/trace-simple.c \n
+ In this very simple program, each process creates, executes,
+ and destroy a task. Recommanded options:
+ @verbatim --cfg=tracing:yes --cfg=tracing/uncategorized:yes @endverbatim
+
+ - <b>Platform tracing</b>.
+ @ref examples/msg/trace-platform/trace-platform.c \n
+ This program is a toy example just loading the platform, so that
+ you can play with the platform visualization. Recommanded options:
+ @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes
+ @endverbatim
+
+ - <b>Setting Categories</b>.
+ @ref examples/msg/trace-categories/trace-categories.c \n
+ This example declares several tracing categories
+ to that are used to classify its tasks. When the program is executed,
+ the tracing mechanism registers the resource utilization of hosts
+ and links according to these categories. Recommanded options:
+ @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
+ @endverbatim
+
+ - <b>Master Workers tracing</b>.
+ @ref examples/msg/trace-masterworker/trace-masterworker.c \n
+ This is an augmented version of our basic master/worker example
+ using several tracing features. It traces resource usage, sorted
+ out in several categories; Trace marks and user variables are also
+ used. Recommanded options:
+ @verbatim --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
+ @endverbatim
+
+ - <b>Process migration tracing</b>.
+ @ref examples/msg/trace-process-migration/trace-process-migration.c \n
+ This version is enhanced so that the process migrations can be
+ displayed as arrows in a Gantt-chart visualization. Recommanded
+ options to that extend:
+ @verbatim -cfg=tracing:yes --cfg=tracing/msg/process:yes
+ @endverbatim
+
+TODO: These tracing examples should be integrated in the examples to
+not duplicate the C files. A full command line to see the result in
+the right tool (viva/vite/FrameSoc) should be given along with some
+screenshots.
+
+@subsection msg_ex_tracing_user_variables Tracing user variables
+
+You can also attach your own variables to a any resource described in
+the platform file. The following examples illustrate this feature.
+They have to be run with the following options:
+@verbatim --cfg=tracing:yes --cfg=tracing/platform:yes
+@endverbatim
+
+ - <b>Attaching variables to Hosts</b>.
+ @ref examples/msg/trace-host-user-variables/trace-host-user-variables.c
+
+ - <b>Attaching variables to Links</b>.
+ @ref examples/msg/trace-link-user-variables/trace-link-user-variables.c \n
+ The tricky part is that you have to know the name of the link you
+ want to enhance with a variable.
+
+ - <b>Attaching variables to network Routes</b>
+ @ref examples/msg/trace-route-user-variables/trace-route-user-variables.c \n
+ It is often easier to update a given variable for all links of a
+ given network path (identified by its source and destination
+ hosts) instead of knowing the name of each specific link.
+
+@section msg_ex_models Models-related examples
+
+@subsection msg_ex_ns3 NS3 as a SimGrid Network Model
+
+This example demonstrates how to use the bindings to the Network
+Simulator, as explained in @ref pls. The most
+interesting is probably not the C files since they are unchanged from
+the other simulations, but the associated files, such as the platform
+file to see how to declare a platform to be used with the PLS bindings
+of SimGrid and the tesh file to see how to actually start a simulation
+in these settings.
+
+ - @ref examples/msg/network-ns3/network-ns3.c. Simple ping-pong using
+ ns-3 instead of the SimGrid network models.
+
+TODO: merge the C files
+
+TODO: show the XML files instead if it's what is interesting. On a "XML example files" page that does not exist yet.
+
+@subsection msg_ex_io Simulating disks and files
+
+The examples of this section demonstrate how to interact with the
+simulated storages.
+
+ - <b>Basic example</b>.
+ @ref examples/msg/io-storage/io-storage.c \n
+ All main storage and file functions are demoed.
+
+ - <b>File Management</b>. @ref examples/msg/io-file/io-file.c \n
+ This example illustrates the use of operations on file
+ (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write,
+ or @ref MSG_file_close).
+
+ - <b>Remote I/O</b>. @ref examples/msg/io-remote/io-remote.c \n
+ I/O operations can also be done in a remote, i.e. when the
+ accessed disk is not mounted on the caller's host.
+
+@section msg_ex_actions Following Workload Traces
+
+This section details how to run trace-driven simulations. It is very
+handy when you want to test an algorithm or protocol that only react
+to external events. For example, many P2P protocols react to user
+requests, but do nothing if there is no such event.
+
+In such situations, you should write your protocol in C, and separate
+the workload that you want to play onto your protocol in a separate
+text file. Declare a function handling each type of the events in your
+trace, register them using @ref xbt_replay_action_register in your
+main, and then use @ref MSG_action_trace_run to launch the simulation.
+
+Then, you can either have one trace file containing all your events,
+or a file per simulated process: the former may be easier to work
+with, but the second is more efficient on very large traces. Check
+also the tesh files in the example directories for details.
+
+ - <b>Communication replay</b>.
+ @ref examples/msg/actions-comm/actions-comm.c \n
+ Presents a set of event handlers reproducing classical communication
+ primitives (synchronous and asynchronous send/receive, broadcast,
+ barrier, etc).
+
+ - <b>I/O replay</b>.
+ @ref examples/msg/actions-storage/actions-storage.c \n
+ Presents a set of event handlers reproducing classical I/O
+ primitives (open, read, write, close, etc).
+
+@section msg_ex_apps Examples of Full Applications
+
+ - <b>Parallel Matrix Multiplication</b>.
+ @ref examples/msg/app-pmm/app-pmm.c \n
+ This little application multiplies two matrices in parallel. Each
+ of the 9 processes computes a sub-block of the result, with the
+ sub-blocks of the input matrices exchanged between the processes. \n
+ This is a classical assignment in MPI lectures, here implemented
+ in MSG.
+
+ - <b>Chord P2P protocol</b>.
+ @ref examples/msg/dht-chord/dht-chord.c \n
+ This example implements the well known Chord protocol,
+ constituting a fully working non-trivial example. This
+ implementation is also very efficient, as demonstrated in
+ http://hal.inria.fr/inria-00602216/
+
+@section msg_ex_misc Miscellaneous
+
+ - <b>Task priorities</b>.
+ @ref examples/msg/task-priority/task-priority.c \n
+ Demonstrates the use of @ref MSG_task_set_priority to change the
+ computation priority of a given task.
+
+ - <b>User-defined properties</b>.
+ @ref examples/msg/platform-properties/platform-properties.c \n
+ Attaching arbitrary information to host, processes and
+ such, and retrieving them with @ref MSG_host_get_properties,
+ @ref MSG_host_get_property_value, @ref MSG_process_get_properties, and
+ @ref MSG_process_get_property_value. Also make sure to read the
+ platform and deployment XML files to see how to declare these data.
+
+TODO: Document the many other examples that we have
*/
As a human, you can stop reading at this point. The rest is garbage:
Every example must be listed in the following, but it's not possible
-to move this content upper as each example directive seems to eat the
-next doxygen commands.
+to move this content upper as each @example directive seems to eat
+everything until the next */ marker (and the content is placed at the
+top of the example file).
/**
@example examples/msg/async-wait/async-wait.c
@example examples/msg/async-waitall/async-waitall.c
@example examples/msg/async-waitall/async-waitany.c
-*/
-Basic examples and features
-===========================
-
- * migration/migration.c Demonstrates how to use the
- MSG_process_migrate() function to let processes change the host
- they run on after their start.
-
- * suspend/suspend.c: Demonstrates how to suspend and resume processes
- using MSG_process_suspend() and MSG_process_resume().
-
- * properties/msg_prop.c Attaching arbitrary information to host,
- processes and such, and retrieving them with
- MSG_host_get_properties(), MSG_host_get_property_value(),
- MSG_process_get_properties() and MSG_process_get_property_value().
- Also make sure to read the platform and deployment XML files to see
- how to declare these data.
-
- * parallel_task/parallel_task.c: Demonstrates the use of
- MSG_parallel_task_create(), to create special tasks that run on
- several hosts at the same time. The resulting simulations are very
- close to what can be achieved in SimDag, but still allows to use
- the other features of MSG (it'd be cool to be able to mix
- interfaces, but it's not possible ATM).
-
- * priority/priority.c: Demonstrates the use of
- MSG_task_set_priority() to change the computation priority of a
- given task.
-
-Tracing and visualization features
-==================================
- * tracing/simple.c very simple program that creates, executes and
- destroy a task
- * tracing/ms.c TODO
- * tracing/categories.c example with the declaration of multiple
- categories
- * tracing/procmig.c example to trace process migration using the mask
- TRACE_PROCESS
- * tracing/trace_platform.c: Demonstrates how to trace the platform
- * tracing/user_variables.c: Demonstrates how to trace user-provided
- variables
-
-Models-related examples
-=======================
-
-Packet level simulators
------------------------
-These examples demonstrate how to use the bindings to classical
-Packet-Level Simulators (PLS), as explained in the relevant part of
-the web documentation. The most interesting is probably not the C
-files since they are unchanged from the other simulations, but the
-associated files, such as the platform files to see how to declare a
-platform to be used with the PLS bindings of SimGrid and the tesh
-files to see how to actually start a simulation in these settings.
-
- * ns3: Simple ping-pong using ns3 instead of the SimGrid models
- * gtnets Simple ping-pong using GTNeTs instead of the SimGrid models
-
-Other resource kinds
---------------------
-This section contains some sparse examples of how to use the other
-kind of resources, such as disk. These resources are quite
-experimental for now, but here we go anyway.
-
- * io/file.c Example with the disk resource
-
-Trace driven simulations
-========================
-
-The actions/actions.c example demonstrates how to run trace-driven
-simulations. It is very handy when you want to test an algorithm or
-protocol that does nothing unless it receives some events from
-outside. For example, a P2P protocol reacts to requests from the user,
-but does nothing if there is no such event.
-
-In such situations, SimGrid allows to write your protocol in your C
-file, and the events to react to in a separate text file. Declare a
-function handling each of the events that you want to accept in your
-trace files, register them using MSG_action_register in your main, and
-then use MSG_action_trace_run to launch the simulation. You can either
-have one trace file containing all your events, or a file per
-simulated process. Check the tesh files in the example directory for
-details on how to do it.
-
-This example uses this approach to replay MPI-like traces. It comes
-with a set of event handlers reproducing MPI events. This is somehow
-similar to SMPI, yet differently implemented. This code should
-probably be changed to use SMPI internals instead, but wasn't, so far.
-
-Examples of full applications
-=============================
-
- * chord/chord.c: Classical Chord P2P protocol This example implements
- the well known Chord P2P protocol. Its main advantage is that it
- constitute a fully working non-trivial example. In addition, its
- implementation is rather efficient, as demonstrated in
- [57]http://hal.inria.fr/inria-00602216/
+@example examples/msg/process-suspend/process-suspend.c
+@example examples/msg/process-kill/process-kill.c
+@example examples/msg/process-migration/process-migration.c
+@example examples/msg/process-startkilltime/process-startkilltime.c
+
+@example examples/msg/trace-simple/trace-simple.c
+@example examples/msg/trace-platform/trace-platform.c
+@example examples/msg/trace-categories/trace-categories.c
+@example examples/msg/trace-masterworker/trace-masterworker.c
+@example examples/msg/trace-process-migration/trace-process-migration.c
+@example examples/msg/trace-user-variables/trace-user-variables.c
+@example examples/msg/trace-link-user-variables/trace-link-user-variables.c
+@example examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c
+@example examples/msg/network-ns3/network-ns3.c
+
+@example examples/msg/io-storage/io-storage.c
+@example examples/msg/io-file/io-file.c
+@example examples/msg/io-remote/io-remote.c
+
+@example examples/msg/actions-comm/actions-comm.c
+@example examples/msg/actions-storage/actions-storage.c
+
+@example examples/msg/app-pmm/app-pmm.c
+@example examples/msg/dht-chord
+
+@example examples/msg/task-priority/task-priority.c
+@example examples/msg/properties/properties.c
+
+*/
-/* Copyright (c) 2009-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2009-2016. 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/simix.h" /* semaphores for the barrier */
#include <xbt/replay.h>
-/** @addtogroup MSG_examples
- *
- * @section msg_ex_actions Trace driven simulations
- *
- * This section details how to run trace-driven simulations. It is very handy when you want to test an algorithm or
- * protocol that does nothing unless it receives some events from outside. For example, a P2P protocol reacts to
- * requests from the user, but does nothing if there is no such event.
- *
- * In such situations, SimGrid allows you to write your protocol in a C file, and the events to react to in a separate
- * text file. Declare a function handling each of the events that you want to accept in your trace files, register
- * them using \ref xbt_replay_action_register in your main, and then use \ref MSG_action_trace_run to launch the
- * simulation. You can either have one trace file containing all your events, or a file per simulated process. Check
- * the tesh files in the example directories for details on how to do it.
- *
- * - <b>Communication: actions-comm/actions-comm.c</b>. This example comes with a set of event handlers reproducing
- * some classical communication primitives (synchronous and asynchronous send/receive, broadcast, barrier, ...).
- */
-
XBT_LOG_NEW_DEFAULT_CATEGORY(actions, "Messages specific for this msg example");
int communicator_size = 0;
static void action_bcast(const char *const *action)
{
- int i;
- char *bcast_identifier;
char mailbox[80];
double comm_size = parse_double(action[2]);
msg_task_t task = NULL;
- const char *process_name;
double clock = MSG_get_clock();
process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
xbt_assert(communicator_size, "Size of Communicator is not defined, can't use collective operations");
- process_name = MSG_process_get_name(MSG_process_self());
+ const char * process_name = MSG_process_get_name(MSG_process_self());
- bcast_identifier = bprintf("bcast_%d", counters->bcast_counter++);
+ char *bcast_identifier = bprintf("bcast_%d", counters->bcast_counter++);
if (!strcmp(process_name, "p0")) {
XBT_DEBUG("%s: %s is the Root", bcast_identifier, process_name);
msg_comm_t *comms = xbt_new0(msg_comm_t, communicator_size - 1);
- for (i = 1; i < communicator_size; i++) {
+ for (int i = 1; i < communicator_size; i++) {
sprintf(mailbox, "%s_p0_p%d", bcast_identifier, i);
comms[i - 1] = MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
}
MSG_comm_waitall(comms, communicator_size - 1, -1);
- for (i = 1; i < communicator_size; i++)
+ for (int i = 1; i < communicator_size; i++)
MSG_comm_destroy(comms[i - 1]);
xbt_free(comms);
}
}
-/** Main function */
int main(int argc, char *argv[])
{
msg_error_t res = MSG_OK;
XBT_INFO("Simulation time %g", MSG_get_clock());
- /* Explicit finalization of the action module is required now*/
- MSG_action_exit();
+ MSG_action_exit(); /* Explicit finalization of the action module */
return res != MSG_OK;
}
-/* Copyright (c) 2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2015-2016. 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 <xbt/replay.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(storage_actions, "Messages specific for this example");
-/** @addtogroup MSG_examples
- *
- * - <b>I/O: actions-comm/actions-comm.c</b>. This example comes with a set of event handlers reproducing
- * some classical I/O primitives (open, read, write, close, ...).
- */
static xbt_dict_t opened_files = NULL;
-/* pmm - parallel matrix multiplication "double diffusion" */
+/* pmm - double broadcast parallel matrix multiplication */
-/* Copyright (c) 2006-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2016. 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 "xbt/matrix.h"
#include "xbt/xbt_os_time.h"
-/** @addtogroup MSG_examples
- * @section msg_ex_full_apps Examples of full applications
- *
- * - <b>Parallel Matrix Multiplication: app-pmm/app-pmm.c</b>. This little application is something that most MPI
- * developers have written during their studies. Here it is implemented in MSG.
- */
-
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pmm, "Messages specific for this msg example");
/* This example should always be executed using a deployment of GRID_SIZE * GRID_SIZE nodes. */
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2016. 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 <xbt/RngStream.h>
#include "src/mc/mc_replay.h" // FIXME: this is an internal header
-/** @addtogroup MSG_examples
- *
- * - <b>Chord P2P protocol dht-chord/dht-chord.c:</b>. This example implements the well known Chord P2P protocol. Its
- * main advantage is that it constitutes a fully working non-trivial example. In addition, its implementation is
- * rather efficient, as demonstrated in http://hal.inria.fr/inria-00602216/
- */
-
-
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chord, "Messages specific for this msg example");
#define COMM_SIZE 10
static void random_lookup(node_t);
static void quit_notify(node_t node);
-/* \brief Global initialization of the Chord simulation. */
+/* Global initialization of the Chord simulation. */
static void chord_initialize(void)
{
// compute the powers of 2 once for all
xbt_free(powers2);
}
-/**
- * \brief Turns an id into an equivalent id in [0, nb_keys).
- * \param id an id
- * \return the corresponding normalized id
- */
+/* Turns an id into an equivalent id in [0, nb_keys). */
static int normalize(int id)
{
// like id % nb_keys, but works with negatives numbers (and faster)
return id & (nb_keys - 1);
}
-/**
- * \brief Returns whether an id belongs to the interval [start, end].
+/* Returns whether an id belongs to the interval [start, end].
*
* The parameters are noramlized to make sure they are between 0 and nb_keys - 1).
* 1 belongs to [62, 3]
return id <= end;
}
-/**
- * \brief Gets the mailbox name of a host given its chord id.
+/* Gets the mailbox name of a host given its chord id.
* \param node_id id of a node
* \param mailbox pointer to where the mailbox name should be written
* (there must be enough space)
snprintf(mailbox, MAILBOX_NAME_SIZE - 1, "%d", node_id);
}
-/**
- * \brief Frees the memory used by a task.
- * \param task the MSG task to destroy
- */
+/* Frees the memory used by a task and destroy it */
static void task_free(void* task)
{
// TODO add a parameter data_free_function to MSG_task_create?
}
}
-/**
- * \brief Displays the finger table of a node.
- * \param node a node
- */
+/* Displays the finger table of a node. */
static void print_finger_table(node_t node)
{
if (XBT_LOG_ISENABLED(msg_chord, xbt_log_priority_verbose)) {
}
}
-/**
- * \brief Sets a finger of the current node.
+/* Sets a finger of the current node.
+ *
* \param node the current node
* \param finger_index index of the finger to set (0 to nb_bits - 1)
* \param id the id to set for this finger
}
}
-/**
- * \brief Sets the predecessor of the current node.
+/* Sets the predecessor of the current node.
+ *
* \param node the current node
* \param id the id to predecessor, or -1 to unset the predecessor
*/
}
}
-/**
- * \brief Node Function
+/* Node main Function
+ *
* Arguments:
* - my id
* - the id of a guy I know in the system (except for the first node)
return 0;
}
-/**
- * \brief This function is called when the current node receives a task.
+/* This function is called when the current node receives a task.
+ *
* \param node the current node
- * \param task the task to handle (don't touch it then:
- * it will be destroyed, reused or forwarded)
+ * \param task the task to handle (don't touch it afterward: it will be destroyed, reused or forwarded)
*/
static void handle_task(node_t node, msg_task_t task) {
}
}
-/**
- * \brief Initializes the current node as the first one of the system.
- * \param node the current node
- */
+/* Initializes the current node as the first one of the system */
static void create(node_t node)
{
XBT_DEBUG("Create a new Chord ring...");
print_finger_table(node);
}
-/**
- * \brief Makes the current node join the ring, knowing the id of a node
- * already in the ring
+/* Makes the current node join the ring, knowing the id of a node already in the ring
+ *
* \param node the current node
* \param known_id id of a node already in the ring
* \return 1 if the join operation succeeded, 0 otherwise
set_predecessor(node, -1); // no predecessor (yet)
/*
- int i;
- for (i = 0; i < nb_bits; i++) {
+ for (int i = 0; i < nb_bits; i++)
set_finger(node, i, known_id);
- }
*/
int successor_id = remote_find_successor(node, known_id, node->id);
return successor_id != -1;
}
-/**
- * \brief Makes the current node quit the system
- * \param node the current node
- */
+/* Makes the current node quit the system */
static void leave(node_t node)
{
XBT_DEBUG("Well Guys! I Think it's time for me to quit ;)");
quit_notify(node);
}
-/**
- * \brief Notifies the successor and the predecessor of the current node
- * of the departure
- * \param node the current node
- */
+/* Notifies the successor and the predecessor of the current node before leaving */
static void quit_notify(node_t node)
{
char mailbox[MAILBOX_NAME_SIZE];
}
-/**
- * \brief Makes the current node find the successor node of an id.
+/* Makes the current node find the successor node of an id.
+ *
* \param node the current node
* \param id the id to find
* \return the id of the successor node, or -1 if the request failed
return remote_find_successor(node, closest, id);
}
-/**
- * \brief Asks another node the successor node of an id.
+/* \brief Asks another node the successor node of an id.
+ *
* \param node the current node
* \param ask_to the node to ask to
* \param id the id to find
return successor;
}
-/**
- * \brief Asks another node its predecessor.
+/* Asks its predecessor to a remote node
+ *
* \param node the current node
* \param ask_to the node to ask to
* \return the id of its predecessor node, or -1 if the request failed
return predecessor_id;
}
-/**
- * \brief Returns the closest preceding finger of an id
- * with respect to the finger table of the current node.
+/* Returns the closest preceding finger of an id with respect to the finger table of the current node.
+ *
* \param node the current node
* \param id the id to find
* \return the closest preceding finger of that id
return node->id;
}
-/**
- * \brief This function is called periodically. It checks the immediate
- * successor of the current node.
- * \param node the current node
- */
+/* This function is called periodically. It checks the immediate successor of the current node. */
static void stabilize(node_t node)
{
XBT_DEBUG("Stabilizing node");
}
}
-/**
- * \brief Notifies the current node that its predecessor may have changed.
- * \param node the current node
- * \param candidate_id the possible new predecessor
- */
+/* Notifies the current node that its predecessor may have changed. */
static void notify(node_t node, int predecessor_candidate_id) {
if (node->pred_id == -1
}
}
-/**
- * \brief Notifies a remote node that its predecessor may have changed.
- * \param node the current node
- * \param notify_id id of the node to notify
- * \param candidate_id the possible new predecessor
- */
+/* Notifies a remote node that its predecessor may have changed. */
static void remote_notify(node_t node, int notify_id, int predecessor_candidate_id) {
task_data_t req_data = xbt_new0(s_task_data_t, 1);
MSG_task_dsend(task, mailbox, task_free);
}
-/**
- * \brief This function is called periodically.
- * It refreshes the finger table of the current node.
- * \param node the current node
- */
+/* refreshes the finger table of the current node (called periodically) */
static void fix_fingers(node_t node) {
XBT_DEBUG("Fixing fingers");
}
}
-/**
- * \brief This function is called periodically.
- * It checks whether the predecessor has failed
- * \param node the current node
- */
+/* checks whether the predecessor has failed (called periodically) */
static void check_predecessor(node_t node)
{
XBT_DEBUG("Checking whether my predecessor is alive");
}
}
-/**
- * \brief Performs a find successor request to a random id.
- * \param node the current node
- */
+/* Performs a find successor request to a random id */
static void random_lookup(node_t node)
{
int random_index = RngStream_RandInt (node->stream, 0, nb_bits - 1);
-/* Copyright (c) 2008-2010, 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2008-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * - <b>File management: io-file/io-file.c</b>. This example illustrates the use of operations on file
- * (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write, or @ref MSG_file_close).
- */
-
#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
#define FILENAME2 "c:\\Windows\\setupact.log"
#define FILENAME3 "/home/doc/simgrid/examples/platforms/g5k_cabinets.xml"
-/* Copyright (c) 2014-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2014-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * - <b>Remote I/O: io-remote/io-remote.c</b>. I/O operations can also be done in a remote, which is illustrated here.
- */
-
#include "simgrid/msg.h"
#define INMEGA (1024*1024)
-/* Copyright (c) 2006-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * @section msg_ex_io Simulation disks and files
- *
- * This section lists some examples of storage simulation. This part of SimGrid is still preliminary.
- *
- * - <b>Basic example: io-storage/io-storage.c</b>. This example implements all main storage and file functions.
- */
-
#include "simgrid/msg.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
static int host(int argc, char *argv[]){
const char* host_name = MSG_host_get_name(MSG_host_self());
- /** - Display information on the disks mounted by the current host */
+ /* - Display information on the disks mounted by the current host */
XBT_INFO("*** Storage info on %s ***", host_name);
xbt_dict_cursor_t cursor = NULL;
char* storage_name;
msg_storage_t storage = NULL;
- /** - Retrieve all mount points of current host */
+ /* - Retrieve all mount points of current host */
xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
xbt_dict_foreach(storage_list,cursor,mount_name,storage_name) {
- /** - For each disk mounted on host:
+ /* - For each disk mounted on host:
- Retrieve disk's information */
XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name);
storage = MSG_storage_get_by_name(storage_name);
}
xbt_dict_free(&storage_list);
- /** - Create a 200,000 bytes file named './tmp/data.txt' on /sd1 */
+ /* - Create a 200,000 bytes file named './tmp/data.txt' on /sd1 */
char* file_name = xbt_strdup("/home/tmp/data.txt");
msg_file_t file = NULL;
sg_size_t write, read, file_size;
- /** - Open an non-existing file which amounts to create it. */
+ /* - Open an non-existing file which amounts to create it. */
file = MSG_file_open(file_name, NULL);
write = MSG_file_write(file, 200000); // Write 200,000 bytes
XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name);
MSG_file_dump(file);
- /** - Check that sizes have changed */
+ /* - Check that sizes have changed */
XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage));
XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage));
- /** - Retrieve the size of created file and read it completely */
+ /* - Retrieve the size of created file and read it completely */
file_size = MSG_file_get_size(file);
MSG_file_seek(file, 0, SEEK_SET);
read = MSG_file_read(file, file_size);
XBT_INFO("Read %llu bytes on %s", read, file_name);
- /** - Then write 100,000 bytes in tmp/data.txt */
+ /* - Then write 100,000 bytes in tmp/data.txt */
write = MSG_file_write(file, 100000); // Write 100,000 bytes
XBT_INFO("Write %llu bytes on %s", write, file_name);
MSG_file_dump(file);
storage_name = xbt_strdup("Disk4");
storage = MSG_storage_get_by_name(storage_name);
- /** - Move file from ./tmp/data.txt to ./tmp/simgrid.readme */
+ /* - Move file from ./tmp/data.txt to ./tmp/simgrid.readme */
XBT_INFO("*** Move '/tmp/data.txt' into '/tmp/simgrid.readme'");
MSG_file_move(file, "/home/tmp/simgrid.readme");
- /** - Attach some user data to the file */
+ /* - Attach some user data to the file */
MSG_file_set_data(file, xbt_strdup("777"));
- /** - Then retrieve this data */
+ /* - Then retrieve this data */
char *data = MSG_file_get_data(file);
XBT_INFO("User data attached to the file: %s", data);
MSG_file_close(file);
free(file_name);
- /** - Attach some user data to disk1 */
+ /* - Attach some user data to disk1 */
XBT_INFO("*** Get/set data for storage element: %s ***",storage_name);
data = MSG_storage_get_data(storage);
xbt_free(data);
xbt_free(storage_name);
- /** - Finally dump disks contents */
+ /* - Finally dump disks contents */
XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self()));
xbt_dict_t contents = NULL;
contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2016. 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-/** @addtogroup MSG_examples
- *
- * @section msg_ex_models Models-related examples
- *
- * @subsection MSG_ex_PLS Packet level simulators
- *
- * This example demonstrates how to use the bindings to a classical Packet-Level Simulators (PLS), as explained in
- * \ref pls. The most interesting is probably not the C files since they are unchanged from the other simulations,
- * but the associated files, such as the platform file to see how to declare a platform to be used with the PLS
- * bindings of SimGrid and the tesh file to see how to actually start a simulation in these settings.
- *
- * - <b>ns-3: network-ns3/network-ns3.c</b>. Simple ping-pong using ns-3 instead of the SimGrid network models.
- */
-
int timer_start; //set as 1 in the master process
//keep a pointer to all surf running tasks.
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2016. 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"
-/** @addtogroup MSG_examples
- *
- * - <b>User-defined properties: properties/properties.c</b> Attaching arbitrary information to host, processes and
- * such, and retrieving them with @ref MSG_host_get_properties, @ref MSG_host_get_property_value,
- * @ref MSG_process_get_properties, and @ref MSG_process_get_property_value. Also make sure to read the platform and
- * deployment XML files to see how to declare these data.
- */
-
XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Property test");
static void test_host(const char*hostname)
-/* Copyright (c) 2007, 2009-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007, 2009-2016. 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"
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_kill, "Messages specific for this msg example");
-/** @addtogroup MSG_examples
- *
- * - <b>Killing: process-kill/process-kill.c</b>. Processes can also be killed by another if needed thanks to
- * the @ref MSG_process_kill function.
- */
static int victim(int argc, char *argv[])
{
XBT_INFO("Hello!");
XBT_INFO("Suspending myself");
- MSG_process_suspend(MSG_process_self()); /** - First suspend itself */
- XBT_INFO("OK, OK. Let's work"); /** - Then is resumed and start to execute a task */
+ MSG_process_suspend(MSG_process_self()); /* - First suspend itself */
+ XBT_INFO("OK, OK. Let's work"); /* - Then is resumed and start to execute a task */
MSG_task_execute(MSG_task_create("work", 1e9, 0, NULL));
- XBT_INFO("Bye!"); /** - But will never reach the end of it */
+ XBT_INFO("Bye!"); /* - But will never reach the end of it */
return 0;
}
static int killer(int argc, char *argv[])
{
- XBT_INFO("Hello!"); /** - First start a @ref victim process */
+ XBT_INFO("Hello!"); /* - First start a victim process */
msg_process_t poor_victim = MSG_process_create("victim", victim, NULL, MSG_host_by_name("Fafard"));
MSG_process_sleep(10.0);
- XBT_INFO("Resume process"); /** - Resume it from its suspended state */
+ XBT_INFO("Resume process"); /* - Resume it from its suspended state */
MSG_process_resume(poor_victim);
- XBT_INFO("Kill process"); /** - and then kill it */
+ XBT_INFO("Kill process"); /* - and then kill it */
MSG_process_kill(poor_victim);
XBT_INFO("OK, goodbye now.");
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 */
- /** - Create and deploy @ref killer process */
+ MSG_create_environment(argv[1]); /* - Load the platform description */
+ /* - Create and deploy killer process, that will create the victim process */
MSG_process_create("killer", killer, NULL, MSG_host_by_name("Tremblay"));
- res = MSG_main(); /** - Run the simulation */
+ res = MSG_main(); /* - Run the simulation */
XBT_INFO("Simulation time %g", MSG_get_clock());
return res != MSG_OK;
-/* Copyright (c) 2009-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2009-2016. 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_migration, "Messages specific for this msg example");
-/** @addtogroup MSG_examples
- *
- * - <b>Migration: process-migration/process-migration.c</b>. Processes can move or be moved from a host to another
- * while they are running thanks to the @ref MSG_process_migrate function.
- */
-
xbt_mutex_t checkpoint = NULL;
xbt_cond_t identification = NULL;
static msg_process_t controlled_process = NULL;
-/** The Emigrant will be moved from host to host. */
+/* The Emigrant process will be moved from host to host. */
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);
XBT_INFO("Moving back home after work");
- MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Jacquelin")); /** - Move back to original location */
- MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin")); /** - Go back to the other host to sleep*/
+ MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Jacquelin")); /* - Move back to original location */
+ MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin")); /* - Go back to the other host to sleep*/
MSG_process_sleep(4);
- xbt_mutex_acquire(checkpoint); /** - Get controlled at checkpoint */
- controlled_process = MSG_process_self(); /** - and get moved back by @ref policeman */
+ xbt_mutex_acquire(checkpoint); /* - Get controlled at checkpoint */
+ controlled_process = MSG_process_self(); /* - and get moved back by the policeman process */
xbt_cond_broadcast(identification);
xbt_mutex_release(checkpoint);
MSG_process_suspend(MSG_process_self());
return 0;
}
-/** The policeman check for emigrants and move them back to 'Jacquelin' */
+/* The policeman check for emigrants and move them back to 'Jacquelin' */
static int policeman(int argc, char *argv[])
{
xbt_mutex_acquire(checkpoint);
- XBT_INFO("Wait at the checkpoint."); /** - Wait at @ref checkpoint to control the @ref identification of processes */
+ XBT_INFO("Wait at the checkpoint."); /* - block on the mutex+condition */
while (controlled_process == NULL) xbt_cond_wait(identification, checkpoint);
- MSG_process_migrate(controlled_process, MSG_host_by_name("Jacquelin")); /** - Move an emigrant to Jacquelin */
+ MSG_process_migrate(controlled_process, MSG_host_by_name("Jacquelin")); /* - Move an emigrant to Jacquelin */
XBT_INFO("I moved the emigrant");
MSG_process_resume(controlled_process);
xbt_mutex_release(checkpoint);
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 */
- /** - Create and deploy @ref emigrant and @ref policeman processes */
+ 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"));
- checkpoint = xbt_mutex_init(); /** - Initiate @ref checkpoint and @ref identification*/
+ checkpoint = xbt_mutex_init(); /* - Initiate the mutex and conditions */
identification = xbt_cond_init();
- res = MSG_main(); /** - Run the simulation */
+ res = MSG_main(); /* - Run the simulation */
XBT_INFO("Simulation time %g", MSG_get_clock());
xbt_cond_destroy(identification);
xbt_mutex_destroy(checkpoint);
-/* Copyright (c) 2007, 2009-2010, 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2016. 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-/** @addtogroup MSG_examples
- *
- * - <b>Life-Cycle: process-startkilltime/process-startkilltime.c</b>. The <i>creation</i> and <i>termination</i>
- * times of processes can be explicitly given in the deployment file (see *_d.xml files in example directory).
- */
-
-/** Executed on process termination*/
+/* Executed on process termination*/
static int my_onexit(void* ignored1, void *ignored2) {
- XBT_INFO("Exiting now (done sleeping or got killed)."); /** - Just display an informative message (see tesh file) */
+ XBT_INFO("Exiting now (done sleeping or got killed)."); /* - Just display an informative message (see tesh file) */
return 0;
}
-/** Just sleep until termination */
+/* Just sleep until termination */
static int sleeper(int argc, char *argv[])
{
XBT_INFO("Hello! I go to sleep.");
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_create_environment(argv[1]); /* - Load the platform description */
MSG_function_register("sleeper", sleeper);
- MSG_launch_application(argv[2]); /** - Deploy the @ref sleeper processes with explicit start/kill times */
+ MSG_launch_application(argv[2]); /* - Deploy the sleeper processes with explicit start/kill times */
- res = MSG_main(); /** - Run the simulation */
+ res = MSG_main(); /* - Run the simulation */
XBT_INFO("Simulation time %g", MSG_get_clock());
return res != MSG_OK;
}
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_suspend, "Messages specific for this msg example");
-#define SLEEP(duration) \
- if (MSG_process_sleep(duration) != MSG_OK) \
- xbt_die("What's going on??? I failed to sleep!");
-
-/** @addtogroup MSG_examples
- * @section msg_ex_process Acting on Processes
- *
- * - <b>Suspend/Resume: process-suspend/process-suspend.c</b>. Processes can be suspended and resumed during
- * their executions thanks to the @ref MSG_process_suspend and @ref MSG_process_resume functions.
- */
-
-/** The Lazy guy only wants to sleep, but can be awaken by the @ref dream_master. */
+/* The Lazy guy only wants to sleep, but can be awaken by the dream_master process. */
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 */
- SLEEP(10.0);
+ XBT_INFO("Going to sleep..."); /* - Then repetitively go to sleep, but got awaken */
+ MSG_process_sleep(10.0);
XBT_INFO("Mmm... waking up.");
XBT_INFO("Going to sleep one more time...");
- SLEEP(10.0);
+ MSG_process_sleep(10.0);
XBT_INFO("Waking up once for all!");
XBT_INFO("Mmmh, goodbye now.");
return 0;
}
-/** The Dream master: */
+/* The Dream master: */
static int dream_master(int argc, char *argv[])
{
msg_process_t lazy = NULL;
- XBT_INFO("Let's create a lazy guy."); /** - Create a @ref lazy_guy process */
+ XBT_INFO("Let's create a lazy guy."); /* - Create a lazy_guy process */
lazy = MSG_process_create("Lazy", lazy_guy, NULL, MSG_host_self());
XBT_INFO("Let's wait a little bit...");
- 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 @ref lazy_guy */
+ MSG_process_resume(lazy); /* - Then wake up the lazy_guy */
- 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 @ref 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.");
- 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 @ref lazy_guy again */
+ MSG_process_resume(lazy); /* - Then wake up the lazy_guy again */
- SLEEP(5.0);
+ MSG_process_sleep(5.0);
XBT_INFO("Suspend again the lazy guy while he's sleeping...");
MSG_process_suspend(lazy);
XBT_INFO("This time, don't let him finish his siesta.");
- SLEEP(2.0);
+ MSG_process_sleep(2.0);
XBT_INFO("Wake up, lazy guy!");
MSG_process_resume(lazy);
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_function_register("dream_master", dream_master); /** - Create and deploy the @ref dream_master */
+ 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));
xbt_dynar_free(&hosts);
- res = MSG_main(); /** - Run the simulation */
+ res = MSG_main(); /* - Run the simulation */
XBT_INFO("Simulation time %g", MSG_get_clock());
return res != MSG_OK;
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2016. 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"
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-/** @addtogroup MSG_examples
- *
- * @section msg_ex_misc Miscellaneous
- * - <b>Task priorities: task-priority/task-priority.c</b>. This examples demonstrates the use of
- * @ref MSG_task_set_priority to change the computation priority of a given task.
- */
-
static int test(int argc, char *argv[])
{
double computation_amount = xbt_str_parse_double(argv[1], "Invalid argument: %s");
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * - <b>Setting Categories: trace-categories/trace-categories.c</b>. This example declares several tracing categories
- * that are used to classify tasks. When the program is executed, the tracing mechanism registers the resource
- * utilization of hosts and links according to these categories. You might want to run this program with the following
- * options: <i>--cfg=tracing:yes</i>, <i>--cfg=tracing/categorized:yes</i>, <i>--cfg=tracing/uncategorized:yes</i>,
- * <i>--cfg=viva/categorized:viva_cat.plist</i>, and <i>--cfg=viva/uncategorized:viva_uncat.plist</i>.
- */
-
#include "simgrid/msg.h"
static int master(int argc, char *argv[])
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
long workers_count = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s");
- int i;
- for (i = 0; i < number_of_tasks; i++) {
+ for (int i = 0; i < number_of_tasks; i++) {
msg_task_t task = NULL;
- //creating task and setting its category
+ /* creating task and setting its category */
if (i % 2) {
task = MSG_task_create("task_compute", 10000000, 0, NULL);
MSG_task_set_category(task, "compute");
MSG_task_send(task, "master_mailbox");
}
- for (i = 0; i < workers_count; i++) {
+ for (int i = 0; i < workers_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 1000, 0);
MSG_task_set_category(finalize, "finalize");
MSG_task_send(finalize, "master_mailbox");
MSG_create_environment(argv[1]);
- //declaring user categories with RGB colors
+ /* declaring user categories with RGB colors */
TRACE_category_with_color ("compute", "1 0 0"); //red
TRACE_category_with_color ("request", "0 1 0"); //green
TRACE_category_with_color ("data", "0 0 1"); //blue
-/* Copyright (c) 2010, 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010, 2012-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * @section msg_ex_tracing_user_variables Tracing user variables
- * The tracing mechanism of SimGrid also allows to associate user variables to resources described in the platform file.
- * The following examples illustrate this feature. They have to be run with the <i>--cfg=tracing:yes</i> and
- * <i>--cfg=tracing/platform:yes</i> options.
- *
- * - <b>Hosts: trace-user-variables/trace-user-variables.c</b>. This example shows how user defined variables can be
- * associated to an host and how to manage the tracing of their evolution.
- */
#include <stdio.h>
#include "simgrid/msg.h"
static int trace_fun(int argc, char *argv[])
{
const char *hostname = MSG_host_get_name(MSG_host_self());
- int i;
//the hostname has an empty HDD with a capacity of 100000 (bytes)
TRACE_host_variable_set(hostname, "HDD_capacity", 100000);
TRACE_host_variable_set(hostname, "HDD_utilization", 0);
- for (i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
//create and execute a task just to make the simulated time advance
msg_task_t task = MSG_task_create("task", 10000, 0, NULL);
MSG_task_execute (task);
TRACE_host_variable_add(hostname, "HDD_utilization", 100);
}
- for (i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
//create and execute a task just to make the simulated time advance
msg_task_t task = MSG_task_create("task", 10000, 0, NULL);
MSG_task_execute (task);
#! ./tesh
-p Tracing user variables
-$ $SG_TEST_EXENV ${bindir:=.}/trace-user-variables$EXEEXT --cfg=tracing:yes --cfg=tracing/platform:yes ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
+p Tracing user variables for hosts
+$ $SG_TEST_EXENV ${bindir:=.}/trace-host-user-variables$EXEEXT --cfg=tracing:yes --cfg=tracing/platform:yes ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/platform' to 'yes'
> [0.004078] [msg_test/INFO] Declared host variables:
$ rm -f viva_graph.plist
p Not tracing user variables
-$ $SG_TEST_EXENV ${bindir:=.}/trace-user-variables$EXEEXT ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
+$ $SG_TEST_EXENV ${bindir:=.}/trace-host-user-variables$EXEEXT ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
-/* Copyright (c) 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2016. 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>
-/** @addtogroup MSG_examples
- *
- * - <b>Links: trace-link-user-variables/trace-link-user-variables.c</b>. You need to provide the name of the link to
- * update the value of the variable associated to that link.
- */
-
//dump function to create and execute a task
static void create_and_execute_task (void)
{
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * - <b>Master/Worker: trace-masterworker/trace-masterworker.c</b> This is an augmented version of our basic
- * master/worker example. It uses several tracing functions that enable the tracing of categorized resource
- * utilization, the use of trace marks, and user variables associated to the hosts of the platform file. You might
- * want to run this program with the following configuration options:
- * <i>--cfg=tracing/categorized:yes</i>, <i>--cfg=tracing/uncategorized:yes</i>,
- * <i>--cfg=viva/categorized:viva_cat.plist</i>, and <i>--cfg=viva/uncategorized:viva_uncat.plist</i>.
- */
-
#include "simgrid/msg.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_trace_masterworker, "Messages specific for this msg example");
TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_master", 1);
TRACE_mark("msmark", "start_send_tasks");
- int i;
- for (i = 0; i < number_of_tasks; i++) {
+ for (int i = 0; i < number_of_tasks; i++) {
msg_task_t task = NULL;
task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
}
TRACE_mark("msmark", "finish_send_tasks");
- for (i = 0; i < workers_count; i++) {
+ for (int i = 0; i < workers_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
MSG_task_set_category(finalize, "finalize");
MSG_task_send(finalize, "master_mailbox");
-/* Copyright (c) 2010, 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010, 2012-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * - <b>Tracing the platform: trace-platform/trace-platform.c</b>. This example just loads a platform file to
- * demonstrate how it can be traced into the Paje trace file format. You might want to run this program with the
- * following options: <i>--cfg=tracing:yes</i> and <i>--cfg=tracing/categorized:yes</i>.
- */
-
#include "simgrid/msg.h"
int main(int argc, char *argv[])
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2016. 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. */
-/** @addtogroup MSG_examples
- *
- * - <b>Process migration: trace-process-migration/trace-process-migration.c</b>. Running this program with the
- * <i>--cfg=tracing:yes</i> and <i>--cfg=tracing/msg/process:yes</i> options enables a Gantt-chart visualization of
- * where the process has been hosted during its execution. Migrations are represented by arrows from the origin to
- * the destination host.
- */
-
#include "simgrid/msg.h"
-/** The guy we will move from host to host. It move alone and then is moved by policeman back */
+/* The guy we will move from host to host. It move alone and then is moved by policeman back */
static int emigrant(int argc, char *argv[])
{
msg_task_t task = NULL;
-/* Copyright (c) 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2016. 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>
-/** @addtogroup MSG_examples
- *
- * - <b>Routes: trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c</b>. Instead of providing the name
- * of the link to update one of its variable, this example shows how to provide two hosts as parameter (source and
- * destination, as defined in the platform file). The tracing mechanism will get the route between these two hosts, if
- * it is defined in the platform file, and update the variable of all the links of that route to the value provided.
- */
-
//dump function to create and execute a task
static void create_and_execute_task (void)
{
#! ./tesh
p Trace user variables associated to links of the platform file
-$ $SG_TEST_EXENV ${bindir:=.}/trace-link-srcdst-user-variables$EXEEXT --cfg=tracing:yes --cfg=tracing/platform:yes ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
+$ $SG_TEST_EXENV ${bindir:=.}/trace-route-user-variables$EXEEXT --cfg=tracing:yes --cfg=tracing/platform:yes ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/platform' to 'yes'
-/* Copyright (c) 2010, 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010, 2012-2016. 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"
-/** @addtogroup MSG_examples
- *
- * @section msg_ex_tracing Tracing and visualization features
- * Tracing can be activated by various configuration options which are illustrated in these example.
- * See \ref tracing_tracing_options for details.
- * - <b>Basic example: trace-simple/trace-simple.c</b>. In this very simple program, each process creates, executes,
- * and destroy a task. You might want to run it with the <i>--cfg=tracing/uncategorized:yes</i> option.
- */
-
static int simple_func(int argc, char *argv[])
{
msg_task_t task = MSG_task_create("task", 100, 0, NULL);
#! ./tesh
p Simple tracing example
-$ $SG_TEST_EXENV ${bindir:=.}/trace-simple$EXEEXT --cfg=tracing:yes --cfg=tracing/filename:trace_simple.trace --cfg=tracing/uncategorized:yes ${srcdir:=.}/small_platform.xml
+$ $SG_TEST_EXENV ${bindir:=.}/trace-simple$EXEEXT --cfg=tracing:yes --cfg=tracing/filename:trace-simple.trace --cfg=tracing/uncategorized:yes ${srcdir:=.}/small_platform.xml
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'trace_simple.trace'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'trace-simple.trace'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
-$ tail -n +3 trace_simple.trace
+$ tail -n +3 trace-simple.trace
> %EventDef PajeDefineContainerType 0
> % Alias string
> % Type string
> 7 0.000001 1 2
> 7 0.000001 1 4
-$ rm -f trace_simple.trace
+$ rm -f trace-simple.trace