From: Gabriel Corona Date: Fri, 20 May 2016 11:50:17 +0000 (+0200) Subject: [simix] Create a (fake) simcall for creating a process directly from a simgrid::simix... X-Git-Tag: v3_14~1184 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a511865336e83ac3654632265ed00b8f0bf0eccc [simix] Create a (fake) simcall for creating a process directly from a simgrid::simix::args --- diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 9f73275352..cf51596aed 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -308,4 +308,13 @@ typedef smx_process_t (*smx_creation_func_t) ( extern "C" XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function); +XBT_PUBLIC(smx_process_t) simcall_process_create(const char *name, + xbt_main_func_t code, + void *data, + const char *hostname, + double kill_time, + simgrid::simix::args args, + xbt_dict_t properties, + int auto_restart); + #endif diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index 0e976d82ad..0d004f739b 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -189,4 +189,10 @@ XBT_PRIVATE void TRACE_msg_vm_restore(msg_vm_t vm); XBT_PRIVATE void TRACE_msg_vm_end(msg_vm_t vm); SG_END_DECL() + +XBT_PUBLIC(msg_process_t) MSG_process_create_with_environment( + const char *name, xbt_main_func_t code, void *data, + msg_host_t host, simgrid::simix::args args, + xbt_dict_t properties); + #endif diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index e871197f87..6ca8e3a127 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -126,7 +126,20 @@ msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_ * \return The new corresponding object. */ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host, - int argc, char **argv, xbt_dict_t properties) + int argc, char **argv, xbt_dict_t properties) +{ + msg_process_t res = MSG_process_create_with_environment(name, code, data, host, + simgrid::simix::args(argc, argv), properties); + for (int i = 0; i != argc; ++i) + xbt_free(argv[i]); + xbt_free(argv); + return res; +} + +msg_process_t MSG_process_create_with_environment( + const char *name, xbt_main_func_t code, void *data, + msg_host_t host, simgrid::simix::args args, + xbt_dict_t properties) { xbt_assert(code != NULL && host != NULL, "Invalid parameters: host and code params must not be NULL"); simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1); @@ -141,7 +154,8 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun /* Let's create the process: SIMIX may decide to start it right now, * even before returning the flow control to us */ - process = simcall_process_create(name, code, simdata, sg_host_get_name(host), -1, argc, argv, properties,0); + process = simcall_process_create( + name, code, simdata, sg_host_get_name(host), -1, std::move(args), properties, 0); if (!process) { /* Undo everything we have just changed */ diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 32a9a3f188..d4684dd72f 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -67,7 +67,7 @@ void SIMIX_host_on(sg_host_t h) NULL, arg->hostname, arg->kill_time, - arg->args.argc(), arg->args.to_argv(), + arg->args, arg->properties, arg->auto_restart); } @@ -226,7 +226,7 @@ void SIMIX_host_autorestart(sg_host_t host) NULL, arg->hostname, arg->kill_time, - arg->args.argc(), arg->args.to_argv(), + arg->args, arg->properties, arg->auto_restart); } diff --git a/src/simix/smx_process.cpp b/src/simix/smx_process.cpp index b6c816f9d7..f77724d82e 100644 --- a/src/simix/smx_process.cpp +++ b/src/simix/smx_process.cpp @@ -1019,10 +1019,29 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) return simcall_process_create( arg.name.c_str(), arg.code, arg.data, arg.hostname, arg.kill_time, - arg.args.argc(), arg.args.to_argv(), + arg.args, arg.properties, arg.auto_restart); } void SIMIX_segment_index_set(smx_process_t proc, int index){ proc->segment_index = index; } + +smx_process_t simcall_process_create(const char *name, + xbt_main_func_t code, + void *data, + const char *hostname, + double kill_time, + simgrid::simix::args args, + xbt_dict_t properties, + int auto_restart) +{ + if (name == nullptr) + name = ""; + smx_process_t self = SIMIX_process_self(); + return simgrid::simix::kernel([&] { + return SIMIX_process_create(name, code, data, hostname, + kill_time, std::move(args), properties, auto_restart, + self); + }); +} \ No newline at end of file diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index e1259d7a24..35cd58ed2c 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -631,7 +631,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process) else process_created = simcall_process_create( arg->name.c_str(), parse_code, NULL, sg_host_get_name(host), kill_time, - arg->args.argc(), arg->args.to_argv(), current_property_set,auto_restart); + arg->args, current_property_set,auto_restart); /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */ if (!process_created) {