src/msg/msg_vm.c
)
-#* ****************************************************************************************** *#
-#* TUTORIAL: New API *#
-
-set(MSG_SRC
- ${MSG_SRC}
- src/msg/msg_new_api.c
- )
-set(EXTRA_DIST
- ${EXTRA_DIST}
- src/simix/smx_new_api_private.h
- )
-set(SIMIX_SRC
- ${SIMIX_SRC}
- src/simix/smx_new_api.c
-)
-#* ****************************************************************************************** *#
-
set(SIMDAG_SRC
src/simdag/instr_sd_task.c
src/simdag/sd_daxloader.c
\tableofcontents
-\section simgrid_dev_guide_api How to add a new MSG function?
-Search for expression \"TUTORIAL: New API\".
-\verbatim
-user@caraja:~/workspace/simgrid/src$ cg "TUTORIAL: New API"
- 0 msg/msg_new_api.c 15 /* TUTORIAL: New API*/
- 1 simix/smx_smurf.c 582 /* TUTORIAL: New API*/
- 2 simix/smx_smurf.c 616 /* TUTORIAL: New API*/
- 3 simix/smx_smurf_private.h 102 /* TUTORIAL: New API*/
- 4 simix/smx_smurf_private.h 629 /* TUTORIAL: New API*/
- 5 simix/smx_private.h 28 /* TUTORIAL: New API*/
- 6 simix/smx_private.h 101 /* TUTORIAL: New API*/
- 7 simix/smx_private.h 182 /* TUTORIAL: New API*/
- 8 simix/smx_global.c 454 /* TUTORIAL: New API*/
- 9 simix/smx_new_api.c 8 /* TUTORIAL: New API*/
-10 simix/smx_user.c 1684 /* TUTORIAL: New API*/
-11 simix/smx_new_api_private.h 8 /* TUTORIAL: New API*/
-12 simix/smx_process.c 338 /* TUTORIAL: New API*/
-\endverbatim
-
\section simgrid_dev_guide_model How to add a new model in surf?
The figure below show the architecture of the SURF layer. This layer is composed
of different kind of models representing the differents systems we want to
/* Used only by the bindings -- unclean pimple, please ignore if you're not writing a binding */
XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(msg_process_t process);
-/* ****************************************************************************************** */
-/* TUTORIAL: New API */
-/* Declare all functions for the API */
-/* ****************************************************************************************** */
-XBT_PUBLIC(int) MSG_new_API_fct(const char* param1, double param2);
-
SG_END_DECL()
#endif
XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2);
XBT_PUBLIC(int) simcall_mc_random(int min, int max);
-/************************** New API simcalls **********************************/
-/* TUTORIAL: New API */
-/******************************************************************************/
-XBT_PUBLIC(int) simcall_new_api_fct(const char* param1, double param2);
-
SG_END_DECL()
#endif /* _SIMIX_SIMIX_H */
+++ /dev/null
-/* Copyright (c) 2004-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_private.h"
-#include "xbt/log.h"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_new_API, msg,
- "Logging specific to MSG (new_API)");
-
-
-/* ****************************************************************************************** */
-/* TUTORIAL: New API */
-/* All functions for the API */
-/* ****************************************************************************************** */
-int MSG_new_API_fct(const char* param1, double param2)
-{
- int result = simcall_new_api_fct(param1, param2);
- return result;
-}
handle(fd, Simcall.enum, simcalls, simcalls_dict)
fd.write("""
-SIMCALL_NEW_API_INIT,
NUM_SIMCALLS
} e_smx_simcall_t;
""")
fd.write(' );\n');
fd.write(' break;\n');
fd.write('\n');
- fd.write(' /* ****************************************************************************************** */\n');
- fd.write(' /* TUTORIAL: New API */\n');
- fd.write(' /* ****************************************************************************************** */\n');
- fd.write(' case SIMCALL_NEW_API_INIT:\n');
- fd.write(' SIMIX_pre_new_api_fct(simcall);\n');
- fd.write(' break;\n');
fd.write(' }\n');
fd.write('}\n');
case SIMIX_ACTION_IO:
action_description = "I/O";
- break;
- /* **************************************/
- /* TUTORIAL: New API */
- case SIMIX_ACTION_NEW_API:
- action_description = "NEW API";
- /* **************************************/
-
break;
}
XBT_INFO("Process %lu (%s@%s): waiting for %s action %p (%s) in state %d to finish",
+++ /dev/null
-/* Copyright (c) 2007-2010, 2012-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. */
-
-/* ****************************************************************************************** */
-/* TUTORIAL: New API */
-/* ****************************************************************************************** */
-#include "smx_private.h"
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "xbt/dict.h"
-#include "mc/mc.h"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_new_api, simix,
- "Logging specific to SIMIX (new_api)");
-
-
-//SIMIX NEW MODEL INIT
-void SIMIX_pre_new_api_fct(smx_simcall_t simcall)
-{
- smx_action_t action = SIMIX_new_api_fct(simcall->issuer,
- simcall->new_api.param1,
- simcall->new_api.param2);
- xbt_fifo_push(action->simcalls, simcall);
- simcall->issuer->waiting_action = action;
-}
-
-void SIMIX_post_new_api(smx_action_t action)
-{
- xbt_fifo_item_t i;
- smx_simcall_t simcall;
-
- xbt_fifo_foreach(action->simcalls,i,simcall,smx_simcall_t) {
- switch (simcall->call) {
- case SIMCALL_NEW_API_INIT:
- simcall->new_api.result = 0;
- break;
-
- default:
- break;
- }
- }
-
- switch (surf_action_get_state(action->new_api.surf_new_api)) {
-
- case SURF_ACTION_FAILED:
- action->state = SIMIX_FAILED;
- break;
-
- case SURF_ACTION_DONE:
- action->state = SIMIX_DONE;
- break;
-
- default:
- THROW_IMPOSSIBLE;
- break;
- }
-
- SIMIX_new_api_finish(action);
-}
-
-smx_action_t SIMIX_new_api_fct(smx_process_t process, const char* param1, double param2)
-{
- smx_action_t action;
- smx_host_t host = process->smx_host;
-
- /* check if the host is active */
- if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) {
- THROWF(host_error, 0, "Host %s failed, you cannot call this function",
- sg_host_name(host));
- }
-
- action = xbt_mallocator_get(simix_global->action_mallocator);
- action->type = SIMIX_ACTION_NEW_API;
- action->name = NULL;
-#ifdef HAVE_TRACING
- action->category = NULL;
-#endif
-
- // Called the function from the new model
- //FIXME:CHECK WHAT TO DO action->new_api.surf_new_api = surf_workstation_model->extension.new_model.fct();
-
- surf_action_set_data(action->new_api.surf_new_api, action);
- XBT_DEBUG("Create NEW MODEL action %p", action);
-
- return action;
-}
-
-void SIMIX_new_api_destroy(smx_action_t action)
-{
- XBT_DEBUG("Destroy action %p", action);
- if (action->new_api.surf_new_api)
- surf_action_unref(action->new_api.surf_new_api);
- xbt_mallocator_release(simix_global->action_mallocator, action);
-}
-
-void SIMIX_new_api_finish(smx_action_t action)
-{
- xbt_fifo_item_t item;
- smx_simcall_t simcall;
-
- xbt_fifo_foreach(action->simcalls, item, simcall, smx_simcall_t) {
-
- switch (action->state) {
-
- case SIMIX_DONE:
- /* do nothing, action done */
- break;
-
- case SIMIX_FAILED:
- SMX_EXCEPTION(simcall->issuer, io_error, 0, "IO failed");
- break;
-
- case SIMIX_CANCELED:
- SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled");
- break;
-
- default:
- xbt_die("Internal error in SIMIX_NEW_MODEL_finish: unexpected action state %d",
- (int)action->state);
- }
-
- if (surf_resource_get_state(surf_workstation_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
- simcall->issuer->context->iwannadie = 1;
- }
-
- simcall->issuer->waiting_action = NULL;
- SIMIX_simcall_answer(simcall);
- }
-
- /* We no longer need it */
- SIMIX_new_api_destroy(action);
-}
+++ /dev/null
-/* Copyright (c) 2007-2010, 2012-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. */
-
-/* ****************************************************************************************** */
-/* TUTORIAL: New API */
-/* ****************************************************************************************** */
-#ifndef _SIMIX_NEW_API_PRIVATE_H
-#define _SIMIX_NEW_API_PRIVATE_H
-
-#include "simgrid/simix.h"
-#include "smx_smurf_private.h"
-
-void SIMIX_pre_new_api_fct(smx_simcall_t simcall);
-smx_action_t SIMIX_new_api_fct(smx_process_t process, const char* param1, double param2);
-
-void SIMIX_post_new_api(smx_action_t action);
-void SIMIX_new_api_destroy(smx_action_t action);
-void SIMIX_new_api_finish(smx_action_t action);
-
-#endif
);
break;
- /* ****************************************************************************************** */
- /* TUTORIAL: New API */
- /* ****************************************************************************************** */
- case SIMCALL_NEW_API_INIT:
- SIMIX_pre_new_api_fct(simcall);
- break;
}
}
SIMCALL_MC_RANDOM,
#endif
-SIMCALL_NEW_API_INIT,
NUM_SIMCALLS
} e_smx_simcall_t;
\ No newline at end of file
#include "smx_network_private.h"
#include "smx_smurf_private.h"
#include "smx_synchro_private.h"
-/* ****************************************************************************************** */
-/* TUTORIAL: New API */
-/* ****************************************************************************************** */
-#include "smx_new_api_private.h"
/* Define only for SimGrid benchmarking purposes */
//#define TIME_BENCH_PER_SR /* this aims at measuring the time spent in each scheduling round per each thread. The code is thus run in sequential to bench separately each SSR */
SIMIX_ACTION_SLEEP,
SIMIX_ACTION_SYNCHRO,
SIMIX_ACTION_IO,
- /* ****************************************************************************************** */
- /* TUTORIAL: New API */
- /* ****************************************************************************************** */
- SIMIX_ACTION_NEW_API
} e_smx_action_type_t;
typedef enum {
smx_host_t host;
surf_action_t surf_io;
} io;
-
- /* ****************************************************************************************** */
- /* TUTORIAL: New API */
- /* ****************************************************************************************** */
- struct {
- surf_action_t surf_new_api;
- } new_api;
};
#ifdef HAVE_LATENCY_BOUND_TRACKING
SIMIX_io_destroy(process->waiting_action);
break;
- /* **************************************/
- /* TUTORIAL: New API */
- case SIMIX_ACTION_NEW_API:
- SIMIX_new_api_destroy(process->waiting_action);
- break;
- /* **************************************/
-
}
}
if(!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != issuer) {
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;
case SIMIX_ACTION_IO:
SIMIX_post_io(action);
break;
-
- /* ****************************************************************************************** */
- /* TUTORIAL: New API */
- /* ****************************************************************************************** */
- case SIMIX_ACTION_NEW_API:
- SIMIX_post_new_api(action);
- break;
}
}
#endif
union u_smx_scalar args[11];
union u_smx_scalar result;
- union {
- struct {
- const char* param1;
- double param2;
- int result;
- } new_api;
-
- };
} s_smx_simcall_t, *smx_simcall_t;
#if HAVE_MC
return simcall_BODY_storage_get_content(storage);
}
+
+
#ifdef HAVE_MC
-void *simcall_mc_snapshot(void)
-{
+void *simcall_mc_snapshot(void) {
return simcall_BODY_mc_snapshot();
}
-int simcall_mc_compare_snapshots(void *s1, void *s2){
+int simcall_mc_compare_snapshots(void *s1, void *s2) {
return simcall_BODY_mc_compare_snapshots(s1, s2);
}
-int simcall_mc_random(int min, int max)
-{
+int simcall_mc_random(int min, int max) {
return simcall_BODY_mc_random(min, max);
}
-
#endif /* HAVE_MC */
-/* ****************************************************************************************** */
-/* TUTORIAL: New API */
-/* All functions for simcall */
-/* ****************************************************************************************** */
-int simcall_new_api_fct(const char* param1, double param2){
- smx_simcall_t simcall = SIMIX_simcall_mine();
- simcall->call = SIMCALL_NEW_API_INIT;
- simcall->new_api.param1 = param1;
- simcall->new_api.param2 = param2;
-
- SIMIX_simcall_push(simcall->issuer);
- return simcall->new_api.result;
-}
-
/* ************************************************************************** */
/** @brief returns a printable string representing a simcall */
XBT_LOG_CONNECT(msg_io);
XBT_LOG_CONNECT(msg_kernel);
XBT_LOG_CONNECT(msg_mailbox);
- XBT_LOG_CONNECT(msg_new_API);
XBT_LOG_CONNECT(msg_process);
XBT_LOG_CONNECT(msg_synchro);
XBT_LOG_CONNECT(msg_task);
XBT_LOG_CONNECT(simix_io);
XBT_LOG_CONNECT(simix_kernel);
XBT_LOG_CONNECT(simix_network);
- XBT_LOG_CONNECT(simix_new_api);
XBT_LOG_CONNECT(simix_process);
XBT_LOG_CONNECT(simix_smurf);
XBT_LOG_CONNECT(simix_synchro);