Some stuff had to be done by SIMIX and MSG right after the XML platform parsing. It is now done by callbacks, registered in SURF at initialization. So that stuff is also done when you create a random platform with the generator.
Add some ugly code to avoid the deletion of these registered callbacks before the parsing.
*/
void MSG_create_environment(const char *file)
{
*/
void MSG_create_environment(const char *file)
{
+ SIMIX_create_environment(file);
+}
+
+void MSG_post_create_environment(void) {
xbt_lib_cursor_t cursor;
void **data;
char *name;
xbt_lib_cursor_t cursor;
void **data;
char *name;
- SIMIX_create_environment(file);
-
/* Initialize MSG hosts */
xbt_lib_foreach(host_lib, cursor, name, data) {
if(data[SIMIX_HOST_LEVEL])
/* Initialize MSG hosts */
xbt_lib_foreach(host_lib, cursor, name, data) {
if(data[SIMIX_HOST_LEVEL])
SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
+
+ sg_platf_postparse_add_cb(MSG_post_create_environment);
}
#ifdef HAVE_TRACING
TRACE_start();
}
#ifdef HAVE_TRACING
TRACE_start();
void _MSG_action_init(void);
void _MSG_action_exit(void);
void _MSG_action_init(void);
void _MSG_action_exit(void);
+void MSG_post_create_environment(void);
+
*/
void SIMIX_create_environment(const char *file)
{
*/
void SIMIX_create_environment(const char *file)
{
- xbt_lib_cursor_t cursor = NULL;
- char *name = NULL;
- void **workstation = NULL;
-
double start, end;
start = xbt_os_time();
double start, end;
start = xbt_os_time();
end = xbt_os_time();
XBT_DEBUG("PARSE TIME: %lg", (end - start));
end = xbt_os_time();
XBT_DEBUG("PARSE TIME: %lg", (end - start));
+}
+
+void SIMIX_post_create_environment(void) {
+
+ void **workstation = NULL;
+ xbt_lib_cursor_t cursor = NULL;
+ char *name = NULL;
+
xbt_lib_foreach(host_lib, cursor, name, workstation) {
if(workstation[SURF_WKS_LEVEL])
SIMIX_host_create(name, workstation[SURF_WKS_LEVEL], NULL);
xbt_lib_foreach(host_lib, cursor, name, workstation) {
if(workstation[SURF_WKS_LEVEL])
SIMIX_host_create(name, workstation[SURF_WKS_LEVEL], NULL);
/* Prepare to display some more info when dying on Ctrl-C pressing */
signal(SIGINT, inthandler);
/* Prepare to display some more info when dying on Ctrl-C pressing */
signal(SIGINT, inthandler);
+
+ /* register a function to be called by SURF after the environment creation */
+ sg_platf_init();
+ sg_platf_postparse_add_cb(SIMIX_post_create_environment);
+
}
if (!simix_timers) {
simix_timers = xbt_heap_new(8, &free);
}
if (!simix_timers) {
simix_timers = xbt_heap_new(8, &free);
}
XBT_PUBLIC(int) SIMIX_process_get_maxpid(void);
}
XBT_PUBLIC(int) SIMIX_process_get_maxpid(void);
+
+void SIMIX_post_create_environment(void);
+
nodes = xbt_graph_get_nodes(platform_graph);
nodes = xbt_graph_get_nodes(platform_graph);
sg_platf_begin();
surf_parse_init_callbacks();
routing_register_callbacks();
sg_platf_begin();
surf_parse_init_callbacks();
routing_register_callbacks();
/** Module management function: creates all internal data structures */
void sg_platf_init(void) {
/** Module management function: creates all internal data structures */
void sg_platf_init(void) {
+
+ //FIXME : Ugly, but useful...
+ if(sg_platf_host_cb_list)
+ return; //Already initialized, so do nothing...
+
sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL);
sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL);
sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
- surf_parse_reset_callbacks();
+ surf_parse_init_callbacks();
/* Register classical callbacks */
surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
/* Register classical callbacks */
surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);