for (int i = 0; i < slavesCount; i++) {
Slave slave = new Slave(hosts[i],i);
slave.start();
- VM vm = new VM(hosts[i],1);
+ VM vm = new VM(hosts[i],hosts[i]+"_"+i,1);
vm.bind(slave);
vms.add(vm);
}
task.send("slave_" + i);
}
}
-}
\ No newline at end of file
+}
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
<platform version="3">
<process host="Jacquelin" function="masterslave.Master">
- <argument value="5"/> <!-- Amount of tasks to dispatch -->
+ <argument value="5000"/> <!-- Amount of tasks to dispatch -->
<argument value="50000"/> <!-- Computation size of each task -->
<argument value="10"/> <!-- Communication size of each one -->
<argument value="7"/> <!-- Amount of slaves waiting for orders -->
*/
protected String name;
+ private double messageSize;
+
+ static private Long idCpt = 0L;
+
+ private Long id;
+
/** Default constructor (all fields to 0 or null) */
public Task() {
create(null, 0, 0);
+ this.messageSize = 0;
+ setId(idCpt);
+ idCpt++;
}
/* * * *
*/
public Task(String name, double computeDuration, double messageSize) {
create(name, computeDuration, messageSize);
+ this.messageSize = messageSize;
+ setId(idCpt);
+ idCpt++;
}
/**
* Construct an new parallel task with the specified processing amount and amount for each host
* methods. This value has to be >= 0.
* @exception IllegalArgumentException if compute duration <0 or message size <0
*/
- final native void create(String name,
+ private final native void create(String name,
double computeDuration,
double messageSize)
throws IllegalArgumentException;
* @param messageSizes An array of doubles
*
*/
- final native void parallelCreate(String name,
+ private final native void parallelCreate(String name,
Host[]hosts,
double[]computeDurations,
double[]messageSizes)
Msg.nativeInit();
nativeInit();
}
+
+ public double getMessageSize() {
+ return this.messageSize;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
}
private long bind = 0;
private int coreAmount;
+
+ private String name;
/**
* @brief Create a new empty VM.
* @bug it is expected that in the future, the coreAmount parameter will be used
* to add extra constraints on the execution, but the argument is ignored for now.
*/
- public VM(Host host, int coreAmount) {
+ public VM(Host host, String name, int coreAmount) {
this.coreAmount = coreAmount;
- start(host,coreAmount);
+ this.name = name;
+ start(host,name,coreAmount);
}
protected void finalize() {
destroy();
* Natively implemented method starting the VM.
* @param coreAmount
*/
- private native void start(Host host, int coreAmount);
+ private native void start(Host host, String name, int coreAmount);
/** @brief Returns whether the given VM is currently suspended
*/
* @brief Reboot the VM, restarting all the processes in it.
*/
public native void reboot();
-
-}
\ No newline at end of file
+
+ public String getName() {
+ return name;
+ }
+}
* @param value
*/
public final static native void hostVariableSet (String host, String variable, double value);
+
+ /**
+ * Declare a new user variable associated to VMs.
+ *
+ * @param variable
+ */
+ public final static native void vmVariableDeclare (String variable);
+
+
+ /**
+ * Set the value of a variable of a VM.
+ *
+ * @param host
+ * @param variable
+ * @param value
+ */
+ public final static native void vmVariableSet (String vm, String variable, double value);
}
}
}
JNIEXPORT void JNICALL
-Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jint jcoreamount) {
+Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jstring jname, jint jcoreamount) {
msg_host_t host = jhost_get_native(env, jhost);
- msg_vm_t vm = MSG_vm_start(host, (int)jcoreamount);
+ const char *name;
+ name = (*env)->GetStringUTFChars(env, jname, 0);
+ name = xbt_strdup(name);
+
+ msg_vm_t vm = MSG_vm_start(host, name, (int)jcoreamount);
jvm_bind(env,jvm,vm);
}
* Signature (I)V
*/
JNIEXPORT void JNICALL
-Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jint jcoreamount);
+Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jstring jname, jint jcoreamount);
/**
* Class org_simgrid_msg_VM
* Method destroy
(*env)->ReleaseStringUTFChars(env, js_host, host);
(*env)->ReleaseStringUTFChars(env, js_state, state);
}
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSub
+ (JNIEnv *env, jclass cls, jstring js_host, jstring js_state, jdouble value)
+{
+ const char *host = (*env)->GetStringUTFChars(env, js_host, 0);
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+ TRACE_host_variable_sub(host, state, value);
+
+ (*env)->ReleaseStringUTFChars(env, js_host, host);
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
+
+
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableDeclare
+ (JNIEnv *env, jclass cls, jstring js_state)
+{
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+ TRACE_vm_variable_declare(state);
+
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableSet
+ (JNIEnv *env, jclass cls, jstring js_vm, jstring js_state, jdouble value)
+{
+ const char *vm = (*env)->GetStringUTFChars(env, js_vm, 0);
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+ TRACE_vm_variable_set(vm, state, value);
+
+ (*env)->ReleaseStringUTFChars(env, js_vm, vm);
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableAdd
+ (JNIEnv *env, jclass cls, jstring js_host, jstring js_state, jdouble value) {
+
+ const char *host = (*env)->GetStringUTFChars(env, js_host, 0);
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+ TRACE_host_variable_set(host, state, value);
+
+ (*env)->ReleaseStringUTFChars(env, js_host, host);
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableDeclare
(JNIEnv *, jclass, jstring);
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: vmVariableDeclare
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableDeclare
+ (JNIEnv *, jclass, jstring);
+
+
/*
* Class: org_simgrid_trace_Trace
* Method: hostVariableDeclareWithColor
JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSet
(JNIEnv *, jclass, jstring, jstring, jdouble);
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: vmVariableSet
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableSet
+ (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+
/*
* Class: org_simgrid_trace_Trace
* Method: hostVariableAdd
jclass class_thread = (*global_env)->FindClass(global_env, "java/lang/Thread");
xbt_assert((class_thread != NULL), "Can't find java.lang.Thread class");
+
jclass class_coroutine_support = (*global_env)->FindClass(global_env, "java/dyn/CoroutineSupport");
xbt_assert((class_coroutine_support != NULL), "Can't find java.dyn.CoroutineSupport class");
jmethodID thread_get_current = (*global_env)->GetStaticMethodID(global_env, class_thread, "currentThread", "()Ljava/lang/Thread;");
{
cojava_processes = SIMIX_process_get_runnable();
smx_process_t process;
- process = xbt_dynar_get_as(cojava_processes, 0, smx_process_t);
- cojava_process_index = 1;
- /* Execute the first process */
- smx_ctx_cojava_resume(SIMIX_process_get_context(process));
+ if (xbt_dynar_length(cojava_processes) > 0) {
+ process = xbt_dynar_get_as(cojava_processes, 0, smx_process_t);
+ cojava_process_index = 1;
+ /* Execute the first process */
+ smx_ctx_cojava_resume(SIMIX_process_get_context(process));
+ }
}
static void smx_ctx_cojava_create_coroutine(smx_ctx_cojava_t context) {