*.bpr
*.bpf
### Documentation
+doc/allclasses-frame.html
+doc/allclasses-noframe.html
+doc/constant-values.html
+doc/deprecated-list.html
+doc/help-doc.html
+doc/index-all.html
+doc/index.html
+doc/org/
+doc/overview-frame.html
+doc/overview-summary.html
+doc/overview-tree.html
+doc/package-list
+doc/resources/
+doc/serialized-form.html
+doc/stylesheet.css
doc/all_bib.html
doc/logcategories.sh
doc/realtoc.sh
examples/msg/z_gtnets.trace
examples/msg/gpu/test_MSG_gpu_task_create
examples/msg/cloud/bound
+examples/msg/cloud/master_worker_vm
examples/msg/cloud/migrate_vm
examples/msg/cloud/multicore
examples/msg/cloud/scale
examples/msg/tracing/volume
examples/msg/io/file
examples/msg/io/file_unlink
+examples/msg/io/remote
examples/msg/io/storage
examples/msg/mc/bugged3
examples/msg/mc/test/snapshot_comparison1
teshsuite/xbt/parallel_log_crashtest
teshsuite/msg/storage/concurrent_rw
teshsuite/msg/host_on_off/host_on_off
+teshsuite/msg/host_on_off_processes/host_on_off_processes
teshsuite/msg/process/process
teshsuite/msg/process_join/process_join
teshsuite/msg/storage/storage_basic
examples/java/suspend/java_suspend_compiled
examples/java/tracing/java_tracing_compiled
examples/java/reservationSurfPlugin/java_reservation_surf_plugin_compiled
+examples/java/surfCpuModel/java_surf_cpu_model_compiled
examples/java/surfPlugin/java_surf_plugin_compiled
/CMakeCache.txt
SimGrid (3.12) NOT RELEASED; urgency=low
- (to complete)
+ SIMIX:
+ * New functions
+ - SIMIX_process_throw: raises an exception in a remote process
+
-- $date Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
examples/msg/energy/e1/CMakeLists.txt
examples/msg/energy/e2/CMakeLists.txt
examples/msg/energy/e3/CMakeLists.txt
+ examples/msg/exception/CMakeLists.txt
examples/msg/gpu/CMakeLists.txt
examples/msg/gtnets/CMakeLists.txt
examples/msg/icomms/CMakeLists.txt
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e1)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e2)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e3)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/exception)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/gpu)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/gtnets)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/icomms)
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(exception exception.c)
+
+### Add definitions for compile
+target_link_libraries(exception simgrid)
+
+set(tesh_files
+ ${tesh_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/exception.tesh
+ PARENT_SCOPE
+ )
+set(examples_src
+ ${examples_src}
+ ${CMAKE_CURRENT_SOURCE_DIR}/exception.c
+ PARENT_SCOPE
+ )
+set(xml_files
+ ${xml_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/deployment_exception.xml
+ PARENT_SCOPE
+ )
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
+set(txt_files
+ ${txt_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+ <process host="Jacquelin" function="terrorist"/>
+</platform>
--- /dev/null
+/* Copyright (c) 2007, 2009-2014. 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 "msg/msg.h"
+#include "xbt.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test_exception,
+ "Messages specific for this msg example");
+
+/** @addtogroup MSG_examples
+ *
+ * - <b>exception/exception.c</b>: Demonstrates how to send an exception to a remote guy
+ */
+
+/** Victim. This process gets a lot of remote exceptions */
+static int victim(int argc, char *argv[]) {
+
+ xbt_ex_t e;
+ XBT_INFO("Let's get suspended.");
+ TRY {
+ MSG_process_suspend(MSG_process_self());
+ } CATCH(e) {
+ XBT_INFO("The received exception resumed my execution. Good. Here is it: ----------------------->8----");
+ xbt_ex_display(&e);
+ XBT_INFO("(end of the first exception) ----8<------------------------");
+ xbt_ex_free(e);
+ }
+
+ msg_error_t res = MSG_OK;
+ int gotit = 0;
+ XBT_INFO("Let's sleep for 10 seconds.");
+ TRY {
+ res = MSG_process_sleep(10);
+ } CATCH(e) {
+ XBT_INFO("Got the second exception: ----------------------->8----");
+ xbt_ex_display(&e);
+ XBT_INFO("(end of the second exception) ----8<------------------------");
+ xbt_ex_free(e);
+ }
+
+ if (res != MSG_TASK_CANCELED)
+ xbt_die("Sleep action not canceled through the exception. This is not a method. (retval: %d)",res);
+ if (!gotit)
+ xbt_die("I was expecting to get an exception during my nap.");
+ XBT_INFO("My little nap got canceled through a raw exception. Excellent.");
+
+ XBT_INFO("That's enough now. I quit.");
+ return 0;
+}
+
+/** Terrorist. This process sends a bunch of exceptions to the victim. */
+static int terrorist(int argc, char *argv[])
+{
+ msg_process_t victim_process = NULL;
+
+ XBT_INFO("Let's create a victim.");
+ victim_process = MSG_process_create("victim", victim, NULL, MSG_host_self());
+ if (MSG_process_sleep(1) != MSG_OK)
+ xbt_die("What's going on??? I failed to sleep!");
+ XBT_INFO("Send a first exception (host failure)");
+ SIMIX_process_throw(victim_process, host_error, 0, "Let's pretend that the host failed");
+
+ if (MSG_process_sleep(3) != MSG_OK)
+ xbt_die("What's going on??? I failed to sleep!");
+ XBT_INFO("Send a second exception (cancellation)");
+ SIMIX_process_throw(victim_process, cancel_error, 0, "Let's pretend this time that someone canceled something");
+
+ XBT_INFO("OK, goodbye now.");
+ return 0;
+}
+
+int main(int argc, char *argv[]) {
+ msg_error_t res = MSG_OK;
+
+ MSG_init(&argc, argv);
+ if (argc < 3) {
+ XBT_CRITICAL("Usage: %s platform_file deployment_file\n", argv[0]);
+ exit(1);
+ }
+
+ MSG_function_register("terrorist", terrorist);
+ MSG_create_environment(argv[1]);
+ MSG_launch_application(argv[2]);
+
+ /*
+ // Simplistic platform with only one host
+ sg_platf_begin();
+ s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+ sg_platf_new_AS_begin(&AS);
+
+ s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+ host.id = "host0";
+ sg_platf_new_host(&host);
+
+ sg_platf_new_AS_end();
+ sg_platf_end();
+
+ // Add one process -- super heavy just to launch an application!
+ SIMIX_init_application();
+ sg_platf_begin();
+
+ s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
+ process.argc=1;
+ process.argv = malloc(sizeof(char*)*2);
+ process.argv[0] = "terrorist";
+ process.argv[1] = NULL;
+ process.host = "host0";
+ process.function = "terrorist";
+ process.start_time = 0;
+ sg_platf_new_process(&process);
+ sg_platf_end();
+*/
+
+ // Launch the simulation
+ res = MSG_main();
+
+ XBT_INFO("Simulation time %g", MSG_get_clock());
+ if (res == MSG_OK)
+ return 0;
+ else
+ return 1;
+}
--- /dev/null
+#! ./tesh
+
+p Testing the remote exception raising feature
+
+! output sort
+$ $SG_TEST_EXENV exception/exception ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/exception/deployment_exception.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
e_surf_process_on_failure_t on_failure;
} s_sg_platf_process_cbarg_t;
-#define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
+#define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
typedef struct s_sg_platf_AS_cbarg {
XBT_PUBLIC(void) simcall_process_kill(smx_process_t process);
XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
+XBT_PUBLIC(void) SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, const char *msg);
+
/* Process handling */
XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process);
/** @brief Exception destructor */
XBT_PUBLIC(void) xbt_ex_free(xbt_ex_t e);
+/** @brief The display made by an exception that is not catched */
+XBT_PUBLIC(void) xbt_ex_display(xbt_ex_t * e);
/** @brief Shows a backtrace of the current location */
XBT_PUBLIC(void) xbt_backtrace_display_current(void);
// adsein: MSG_TASK_CANCELED is assigned when someone kills the process that made the sleep, this is not
// correct. For instance, when the node is turned off, the error should be MSG_HOST_FAILURE, which is by the way
// and according to the JAVA document, the only exception that can be triggered by MSG_Process_sleep call.
- // To avoid possible impacts in the code, I just raised a host_failure execption for the moment in the JAVA code
+ // To avoid possible impacts in the code, I just raised a host_failure exception for the moment in the JAVA code
// and did not change anythings at the C level.
// See comment in the jmsg_process.c file, function JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
status = MSG_TASK_CANCELED;
double process_start_time,
double process_kill_time)
{
- s_sg_platf_process_cbarg_t process;
- memset(&process,0,sizeof(process));
+ s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
smx_host_t host = SIMIX_host_get_by_name(process_host);
if (!host)
process.host = process_host;
process.kill_time = process_kill_time;
process.start_time = process_start_time;
- process.on_failure = SURF_PROCESS_ON_FAILURE_DIE;
- process.properties = NULL;
sg_platf_new_process(&process);
}
#endif
/******************************** Exceptions *********************************/
-
-#define SMX_EXCEPTION(issuer, c, v, m) \
+/** @brief Ask to the provided simix process to raise the provided exception */
+#define SMX_EXCEPTION(issuer, cat, val, msg) \
if (1) { \
- smx_process_t _smx_throw_issuer = (issuer); \
- THROW_PREPARE(_smx_throw_issuer->running_ctx, (c), (v), xbt_strdup(m)); \
+ smx_process_t _smx_throw_issuer = (issuer); /* evaluate only once */\
+ THROW_PREPARE(_smx_throw_issuer->running_ctx, (cat), (val), xbt_strdup(msg)); \
_smx_throw_issuer->doexception = 1; \
} else ((void)0)
process->context->iwannadie = 1;
process->blocked = 0;
process->suspended = 0;
- /* FIXME: set doexception to 0 also? */
+ process->doexception = 0;
/* destroy the blocking action if any */
if (process->waiting_action) {
}
+/** @brief Ask another process to raise the given exception
+ *
+ * @param cat category of exception
+ * @param value value associated to the exception
+ * @param msg string information associated to the exception
+ */
+void SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, const char *msg) {
+ SMX_EXCEPTION(process, cat, value, msg);
+
+ if (process->suspended)
+ SIMIX_process_resume(process,SIMIX_process_self());
+
+ /* cancel the blocking action if any */
+ if (process->waiting_action) {
+
+ switch (process->waiting_action->type) {
+
+ case SIMIX_ACTION_EXECUTE:
+ case SIMIX_ACTION_PARALLEL_EXECUTE:
+ SIMIX_host_execution_cancel(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_COMMUNICATE:
+ xbt_fifo_remove(process->comms, process->waiting_action);
+ SIMIX_comm_cancel(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_SLEEP:
+ SIMIX_process_sleep_destroy(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_JOIN:
+ SIMIX_process_sleep_destroy(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_SYNCHRO:
+ SIMIX_synchro_stop_waiting(process, &process->simcall);
+ break;
+
+ case SIMIX_ACTION_IO:
+ SIMIX_io_destroy(process->waiting_action);
+ break;
+
+ /* **************************************/
+ /* TUTORIAL: New API */
+ case SIMIX_ACTION_NEW_API:
+ SIMIX_new_api_destroy(process->waiting_action);
+ break;
+ /* **************************************/
+
+ }
+ }
+ process->waiting_action = NULL;
+
+ if (!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != SIMIX_process_self())
+ xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
+}
+
void SIMIX_pre_process_killall(smx_simcall_t simcall, int reset_pid) {
SIMIX_process_killall(simcall->issuer, reset_pid);
}
void SIMIX_process_resume(smx_process_t process, smx_process_t issuer)
{
- xbt_assert((process != NULL), "Invalid parameters");
-
XBT_IN("process = %p, issuer = %p", process, issuer);
if(process->context->iwannadie) {
if (self->suspended) {
XBT_DEBUG("Hey! I'm suspended.");
- xbt_assert(!self->doexception, "Gloups! This exception may be lost by subsequent calls.");
+ xbt_assert(!self->doexception, "Gasp! This exception may be lost by subsequent calls.");
self->suspended = 0;
SIMIX_process_suspend(self, self);
}
void xbt_ex_display(xbt_ex_t * e)
{
char *thrower = NULL;
+ if (e->pid != xbt_getpid())
+ thrower = bprintf(" on process %d",e->pid);
fprintf(stderr,
"** SimGrid: UNCAUGHT EXCEPTION received on %s(%d): category: %s; value: %d\n"
/* the externally visible API */
XBT_EXPORT_NO_IMPORT(xbt_running_ctx_fetcher_t) __xbt_running_ctx_fetch = &__xbt_ex_ctx_default;
-XBT_EXPORT_NO_IMPORT(ex_term_cb_t) __xbt_ex_terminate =
- &__xbt_ex_terminate_default;
+XBT_EXPORT_NO_IMPORT(ex_term_cb_t) __xbt_ex_terminate = &__xbt_ex_terminate_default;
void xbt_ex_free(xbt_ex_t e)
#define _XBT_EX_INTERFACE_H_
#include "xbt/ex.h"
-/* The display made by an uncatched exception */
-void xbt_ex_display(xbt_ex_t * e);
/* Change raw libc symbols to file names and line numbers */
void xbt_ex_setup_backtrace(xbt_ex_t * e);