XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
XBT_PUBLIC(const char*) SIMIX_host_get_name(smx_host_t host); /* FIXME: make private: only the name of SIMIX_host_self() should be public without request */
XBT_PUBLIC(void) SIMIX_host_on(smx_host_t host);
-XBT_PUBLIC(void) SIMIX_host_off(smx_host_t host);
+XBT_PUBLIC(void) SIMIX_host_off(smx_host_t host, smx_process_t issuer);
XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
return jhost;
}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Host_on(JNIEnv *env, jobject jhost) {
+ msg_host_t host = jhost_get_native(env, jhost);
+ MSG_host_on(host);
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Host_off(JNIEnv *env, jobject jhost) {
+ msg_host_t host = jhost_get_native(env, jhost);
+ MSG_host_off(host);
+}
+
JNIEXPORT jint JNICALL
Java_org_simgrid_msg_Host_getCount(JNIEnv * env, jclass cls) {
xbt_dynar_t hosts = MSG_hosts_as_dynar();
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName
(JNIEnv *, jclass, jstring);
+/**
+ * This function start the host if it is off
+ *
+ * @param jhost The host to test the validity.
+ * @param env The environment of the current thread
+ *
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_on(JNIEnv *env, jobject jhost);
+
+/**
+ * This function stop the host if it is on
+ *
+ * @param jhost The host to test the validity.
+ * @param env The environment of the current thread
+ *
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_off(JNIEnv *env, jobject jhost);
+
/*
* Class org_simgrid_msg_Host
* Method currentHost
public String getName() {
return name;
}
+
/**
* Sets the data of the host.
* @param data
return null != this.data;
}
+ /**
+ * This method start the host if it is off
+ */
+ public native void on();
+
+ /**
+ * This method stop the host if it is on
+ */
+ public native void off();
+
+
/**
* This method returns the number of tasks currently running on a host.
* The external load is not taken in account.
* \brief Stop the host if it is on
*/
void MSG_host_off(msg_host_t host)
-{
+{
simcall_host_off(host);
}
smx_process_arg_t arg = NULL;
smx_process_t process_created = NULL;
+ arg = xbt_new0(s_smx_process_arg_t, 1);
+ arg->code = parse_code;
+ arg->data = NULL;
+ arg->hostname = sg_host_name(host);
+ arg->argc = process->argc;
+ arg->argv = xbt_new(char *,process->argc);
+ int i;
+ for (i=0; i<process->argc; i++)
+ arg->argv[i] = xbt_strdup(process->argv[i]);
+ arg->name = (char*)(arg->argv)[0];
+ arg->kill_time = kill_time;
+ arg->properties = current_property_set;
+ if (!SIMIX_host_priv(host)->boot_processes) {
+ SIMIX_host_priv(host)->boot_processes = xbt_dynar_new(sizeof(smx_process_arg_t), _SIMIX_host_free_process_arg);
+ }
+ xbt_dynar_push_as(SIMIX_host_priv(host)->boot_processes,smx_process_arg_t,arg);
+
if (start_time > SIMIX_get_clock()) {
arg = xbt_new0(s_smx_process_arg_t, 1);
arg->name = (char*)(process->argv)[0];
else
simcall_process_create(&process_created, (char*)(process->argv)[0], parse_code, NULL, sg_host_name(host), kill_time, process->argc,
(char**)process->argv, 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) {
return;
*/
void SIMIX_host_on(smx_host_t h)
{
- smx_host_priv_t host = (smx_host_priv_t) h;
+ smx_host_priv_t host = SIMIX_host_priv(h);
xbt_assert((host != NULL), "Invalid parameters");
-
- surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
- ws_model->extension.workstation.set_state(host, SURF_RESOURCE_ON);
- SIMIX_host_restart_processes(h);
+ surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
+ if (ws_model->extension.workstation.get_state(h)==SURF_RESOURCE_OFF) {
+ ws_model->extension.workstation.set_state(h, SURF_RESOURCE_ON);
+ unsigned int cpt;
+ smx_process_arg_t arg;
+ xbt_dynar_foreach(host->boot_processes,cpt,arg) {
+ smx_process_t process;
+
+ XBT_DEBUG("Booting Process %s(%s) right now", arg->argv[0], arg->hostname);
+ if (simix_global->create_process_function) {
+ simix_global->create_process_function(&process,
+ arg->argv[0],
+ arg->code,
+ NULL,
+ arg->hostname,
+ arg->kill_time,
+ arg->argc,
+ arg->argv,
+ arg->properties,
+ arg->auto_restart);
+ }
+ else {
+ simcall_process_create(&process,
+ arg->argv[0],
+ arg->code,
+ NULL,
+ arg->hostname,
+ arg->kill_time,
+ arg->argc,
+ arg->argv,
+ arg->properties,
+ arg->auto_restart);
+ }
+ }
+ }
}
void SIMIX_pre_host_off(smx_simcall_t simcall, smx_host_t h)
{
- SIMIX_host_off(h);
+ SIMIX_host_off(h, simcall->issuer);
}
/**
* \brief Stop the host if it is on
*
*/
-void SIMIX_host_off(smx_host_t h)
+void SIMIX_host_off(smx_host_t h, smx_process_t issuer)
{
- smx_host_priv_t host = (smx_host_priv_t) h;
+ smx_host_priv_t host = SIMIX_host_priv(h);
xbt_assert((host != NULL), "Invalid parameters");
-
- /* Clean Simulator data */
- if (xbt_swag_size(host->process_list) != 0) {
- char *msg = xbt_strdup("Shutting down host, but it's not empty:");
- char *tmp;
- smx_process_t process = NULL;
-
- xbt_swag_foreach(process, host->process_list) {
- tmp = bprintf("%s\n\t%s", msg, process->name);
- free(msg);
- msg = tmp;
+
+ surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
+ if (ws_model->extension.workstation.get_state(h)==SURF_RESOURCE_ON) {
+ ws_model->extension.workstation.set_state(h, SURF_RESOURCE_OFF);
+
+ /* Clean Simulator data */
+ if (xbt_swag_size(host->process_list) != 0) {
+ smx_process_t process = NULL;
+ xbt_swag_foreach(process, host->process_list) {
+ SIMIX_process_kill(process, issuer);
+ XBT_DEBUG("Killing %s on %s by %s", process->name, sg_host_name(process->smx_host), issuer->name);
+ }
}
- SIMIX_display_process_status();
- THROWF(arg_error, 0, "%s", msg);
}
- xbt_swag_free(host->process_list);
-
- surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
- ws_model->extension.workstation.set_state(host, SURF_RESOURCE_OFF);
}
/**
THROWF(arg_error, 0, "%s", msg);
}
xbt_dynar_free(&host->auto_restart_processes);
+ xbt_dynar_free(&host->boot_processes);
xbt_swag_free(host->process_list);
/* Clean host structure */
return SIMIX_host_priv(host)->data;
}
-void _SIMIX_host_free_process_arg(void *);
+
void _SIMIX_host_free_process_arg(void *data)
{
smx_process_arg_t arg = *(void**)data;
typedef struct s_smx_host_priv {
xbt_swag_t process_list;
xbt_dynar_t auto_restart_processes;
+ xbt_dynar_t boot_processes;
void *data; /**< @brief user data */
} s_smx_host_priv_t;
return xbt_lib_get_level(host, SIMIX_HOST_LEVEL);
}
+void _SIMIX_host_free_process_arg(void *);
smx_host_t SIMIX_host_create(const char *name, void *workstation, void *data);
void SIMIX_host_destroy(void *host);
double SIMIX_host_get_available_speed(smx_host_t host);
int SIMIX_host_get_state(smx_host_t host);
void SIMIX_host_on(smx_host_t host);
-void SIMIX_host_off(smx_host_t host);
+void SIMIX_host_off(smx_host_t host, smx_process_t issuer);
smx_action_t SIMIX_host_execute(const char *name,
smx_host_t host, double computation_amount, double priority, double bound);
smx_action_t SIMIX_host_parallel_execute(const char *name,
{
XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));
simcall->mc_value = value;
+ if (simcall->issuer->context->iwannadie && simcall->call != SIMCALL_PROCESS_CLEANUP)
+ return;
switch (simcall->call) {
SIMCALL_LIST(SIMCALL_CASE, SIMCALL_SEP_NOTHING)
case NUM_SIMCALLS:;