int console_close(lua_State *L) {
sg_platf_end();
sg_platf_exit();
-
- xbt_lib_cursor_t cursor;
- void **data;
- char *name;
-
- /* Initialize MSG and WKS hosts */
- XBT_DEBUG("Initialize MSG and WKS hosts");
- xbt_lib_foreach(host_lib, cursor, name, data) {
- if(data[SURF_HOST_LEVEL]){
- XBT_DEBUG("\tSee surf host %s",name);
- SIMIX_host_create(name);
- // THIS IS BRAINDEAD. There is no sg_host_t in that level, but a smx_host_priv. So commenting out for now.
- // Lua is broken anyway. Christian will fix it
- // __MSG_host_create((sg_host_t)data[SIMIX_HOST_LEVEL]);
- }
- }
-
return 0;
}
void **data;
char *name;
- /* Initialize MSG hosts */
- xbt_lib_foreach(host_lib, cursor, name, data) {
- __MSG_host_create(xbt_dict_cursor_get_elm(cursor));
- }
-
/* Initialize MSG storages */
xbt_lib_foreach(storage_lib, cursor, name, data) {
if(data[SIMIX_STORAGE_LEVEL])
#include "xbt/ex.h" /* ex_backtrace_display */
#include "xbt/replay.h"
#include "simgrid/sg_config.h" /* Configuration mechanism of SimGrid */
-
+#include "src/surf/callbacks.h"
XBT_LOG_NEW_CATEGORY(msg, "All MSG categories");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg,
msg_global->debug_multiple_use = xbt_cfg_get_boolean(_sg_cfg_set, name);
}
+static void MSG_host_create_(sg_host_t host)
+{
+ __MSG_host_create(host);
+}
+
/**
* \ingroup msg_simulation
* \brief Initialize MSG with less verifications
SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
sg_platf_postparse_add_cb(MSG_post_create_environment);
+ surf_host_created_callback(MSG_host_create_);
}
if(MC_is_active()){
return (smx_host_priv_t) xbt_lib_get_level(host, SIMIX_HOST_LEVEL);
}
void sg_host_simix_set(sg_host_t host, smx_host_priv_t smx_host) {
- xbt_lib_set(host_lib,host->key,SIMIX_HOST_LEVEL,smx_host);
+ xbt_assert(xbt_lib_get_or_null(host_lib,host->key,SIMIX_HOST_LEVEL) == NULL);
+ xbt_lib_set(host_lib,host->key,SIMIX_HOST_LEVEL,smx_host);
}
void sg_host_simix_destroy(sg_host_t host) {
xbt_lib_unset(host_lib,host->key,SIMIX_HOST_LEVEL,1);
}
-void SIMIX_post_create_environment(void) {
-
- void **host = NULL;
+void SIMIX_post_create_environment(void)
+{
void **storage = NULL;
xbt_lib_cursor_t cursor = NULL;
char *name = NULL;
- /* Create host at SIMIX level */
- xbt_lib_foreach(host_lib, cursor, name, host) {
- if(host[SURF_HOST_LEVEL])
- SIMIX_host_create(name);
- }
-
/* Create storage at SIMIX level */
xbt_lib_foreach(storage_lib, cursor, name, storage) {
if(storage[SURF_STORAGE_LEVEL])
#include "src/mc/mc_replay.h"
#include "simgrid/sg_config.h"
+#include "src/surf/callbacks.h"
+
#ifdef HAVE_MC
#include "src/mc/mc_private.h"
#include "src/mc/mc_protocol.h"
/* register a function to be called by SURF after the environment creation */
sg_platf_init();
sg_platf_postparse_add_cb(SIMIX_post_create_environment);
+ surf_host_created_callback(SIMIX_host_create);
}
if (!simix_timers) {
* \brief Internal function to create a SIMIX host.
* \param name name of the host to create
*/
-void SIMIX_host_create(const char *name) // FIXME: braindead prototype. Take sg_host as parameter
+void SIMIX_host_create(sg_host_t host) // FIXME: braindead prototype. Take sg_host as parameter
{
- sg_host_t host = xbt_lib_get_elm_or_null(host_lib, name);
smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
s_smx_process_t proc;
} s_smx_host_priv_t;
XBT_PRIVATE void _SIMIX_host_free_process_arg(void *);
-XBT_PRIVATE void SIMIX_host_create(const char *name);
+XBT_PRIVATE void SIMIX_host_create(sg_host_t host);
XBT_PRIVATE void SIMIX_host_destroy(void *host);
XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host,
{
/* Create surf associated resource */
surf_vm_model_create(name, ind_phys_host);
-
- SIMIX_host_create(name);
+ sg_host_t host = sg_host_by_name(name);
+ SIMIX_host_create(host);
/* We will be able to register the VM to its physical host, so that we can promptly
* retrieve the list VMs on the physical host. */
- return sg_host_by_name(name);
+ return host;
}
--- /dev/null
+/* Copyright (c) 2015. 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/asserts.h>
+
+#include "src/surf/callbacks.h"
+#include "src/surf/surf_interface.hpp"
+#include "src/surf/host_interface.hpp"
+
+void surf_host_created_callback(void (*callback)(sg_host_t))
+{
+ hostCreatedCallbacks.connect([callback](Host* host) {
+ const char* id = host->getName();
+ sg_host_t h = sg_host_by_name(id);
+ xbt_assert(h != NULL, "Host not found for name %s", id);
+ callback(h);
+ });
+}
--- /dev/null
+/* Copyright (c) 2015. 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. */
+
+#ifndef SIMGRID_SURF_CALLBACKS_H
+#define SIMGRID_SURF_CALLBACKS_H
+
+/** \file callbacks.h
+ *
+ * C interface for the C++ SURF callbacks.
+ */
+
+#include <xbt/base.h>
+#include "simgrid/host.h"
+
+SG_BEGIN_DECL();
+
+XBT_PRIVATE void surf_host_created_callback(void (*callback)(sg_host_t));
+
+SG_END_DECL();
+
+#endif
)
set(SURF_SRC
+ src/surf/callbacks.h
+ src/surf/callbacks.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp