RngStream stream;
snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host));
stream = RngStream_CreateStream(descr);
- MSG_host_set_data(host, stream);
+ MSG_host_set_property_value(host, "stream", (char*)stream, NULL);
}
MSG_function_register("tracker", tracker);
MSG_main();
xbt_dynar_foreach(host_list, i, host) {
- RngStream stream = MSG_host_get_data(host);
+ RngStream stream = (RngStream) MSG_host_get_property_value(host, "stream");
RngStream_DeleteStream(&stream);
}
xbt_dynar_free(&host_list);
{
int i;
- RngStream stream = MSG_host_get_data(MSG_host_self());
-
+ RngStream stream = (RngStream) MSG_host_get_property_value(MSG_host_self(), "stream");
//Checking arguments
xbt_assert(argc == 2, "Wrong number of arguments for the tracker.");
//Retrieving end time
XBT_PUBLIC(void) MSG_as_router_set_property_value(const char* asr, const char *name, char *value,void_f_pvoid_t free_ctn);
/************************** Host handling ***********************************/
-XBT_PUBLIC(msg_error_t) MSG_host_set_data(msg_host_t host, void *data);
-XBT_PUBLIC(void *) MSG_host_get_data(msg_host_t host);
XBT_PUBLIC(const char *) MSG_host_get_name(msg_host_t host);
XBT_PUBLIC(void) MSG_host_on(msg_host_t host);
XBT_PUBLIC(void) MSG_host_off(msg_host_t host);
XBT_PUBLIC(msg_host_t) MSG_host_self(void);
XBT_PUBLIC(int) MSG_get_host_msgload(msg_host_t host);
-/* int MSG_get_msgload(void); This function lacks specification; discard it */
XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h);
XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h);
XBT_PUBLIC(xbt_swag_t) MSG_host_get_process_list(msg_host_t h);
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);
-XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_storage_list(smx_host_t host);
/********************************* Process ************************************/
XBT_PUBLIC(int) SIMIX_process_count(void);
#endif
/* end of eclipse-mandated pimple */
+int JAVA_HOST_LEVEL;
+
static int create_jprocess(int argc, char *argv[]);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
return (jdouble) MSG_get_clock();
}
+static void __JAVA_host_priv_free(void *host)
+{
+}
+
JNIEXPORT void JNICALL
Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
{
MSG_init(&argc, argv);
+ JAVA_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __JAVA_host_priv_free);
+
for (index = 0; index < argc; index++)
free(argv[index]);
/* Cleanup java hosts */
hosts = MSG_hosts_as_dynar();
for (index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
- jhost = (jobject) MSG_host_get_data(xbt_dynar_get_as(hosts,index,msg_host_t));
+ jhost = (jobject) xbt_lib_get_level(xbt_dynar_get_as(hosts,index,msg_host_t), JAVA_HOST_LEVEL);
if (jhost)
jhost_unref(env, jhost);
#include <msg/msg.h>
#include <jni.h>
+extern int JAVA_HOST_LEVEL;
+extern xbt_lib_t host_lib;
+
JavaVM *get_java_VM(void);
JNIEnv *get_current_thread_env(void);
/**
host = xbt_dynar_get_as(table,index,msg_host_t);
- jhost = (jobject) (MSG_host_get_data(host));
+ jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
if (!jhost) {
jname = (*env)->NewStringUTF(env, MSG_host_get_name(host));
static jfieldID jhost_field_Host_bind;
static jfieldID jhost_field_Host_name;
-
jobject jhost_new_instance(JNIEnv * env) {
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
return (*env)->NewObject(env, cls, jhost_method_Host_constructor);
}
(*env)->ReleaseStringUTFChars(env, jname, name);
- if (!MSG_host_get_data(host)) { /* native host not associated yet with java host */
+ if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
/* Instantiate a new java host */
jhost = jhost_new_instance(env);
/* the native host data field is set with the global reference to the
* java host returned by this function
*/
- MSG_host_set_data(host, (void *) jhost);
+ xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
}
/* return the global reference to the java host instance */
- return (jobject) MSG_host_get_data(host);
+ return (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
}
JNIEXPORT jobject JNICALL
msg_host_t host = MSG_host_self();
- if (!MSG_host_get_data(host)) {
+ if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
(*env)->SetObjectField(env, jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
- MSG_host_set_data(host, (void *) jhost);
+ xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
} else {
- jhost = (jobject) MSG_host_get_data(host);
+ jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
}
return jhost;
for (index = 0; index < count; index++) {
host = xbt_dynar_get_as(table,index,msg_host_t);
- jhost = (jobject) (MSG_host_get_data(host));
+ jhost = (jobject) (xbt_lib_get_level(host, JAVA_HOST_LEVEL));
if (!jhost) {
jname = (*env)->NewStringUTF(env, MSG_host_get_name(host));
if (host == NULL) {
return NULL;
}
- if (!MSG_host_get_data(host)) {
+ if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
jxbt_throw_jni(env, "MSG_task_get_source() failed");
return NULL;
}
- return (jobject) MSG_host_get_data(host);
+ return (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
}
JNIEXPORT jdouble JNICALL
/* 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 "jmsg.h"
#include "jmsg_vm.h"
#include "jmsg_host.h"
#include "jmsg_process.h"
msg_vm_t vm = jvm_get_native(env,jvm);
msg_host_t host = MSG_vm_get_pm(vm);
- if (!MSG_host_get_data(host)) {
+ if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
jhost_bind(jhost, host, env);
MSG_host_set_data(host, (void *) jhost);
} else {
- jhost = (jobject) MSG_host_get_data(host);
+ jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
}
return jhost;
return (msg_host_t) xbt_lib_get_elm_or_null(host_lib,name);
}
-/** \ingroup m_host_management
- *
- * \brief Set the user data of a #msg_host_t.
- *
- * This functions checks whether some data has already been associated to \a host
- or not and attach \a data to \a host if it is possible.
- */
-msg_error_t MSG_host_set_data(msg_host_t host, void *data)
-{
- SIMIX_host_set_data(host,data);
-
- return MSG_OK;
-}
-
-/** \ingroup m_host_management
- *
- * \brief Return the user data of a #msg_host_t.
- *
- * This functions checks whether \a host is a valid pointer or not and return
- the user data associated to \a host if it is possible.
- */
-void *MSG_host_get_data(msg_host_t host)
-{
- return SIMIX_host_get_data(host);
-}
-
/** \ingroup m_host_management
*
* \brief Return the name of the #msg_host_t.
host_get_speed True (double) (host, void*, smx_host_t)
host_get_available_speed True (double) (host, void*, smx_host_t)
host_get_state True (int) (host, void*, smx_host_t)
-host_get_data True (void*) (host, void*, smx_host_t)
-host_set_data True (void) (host, void*, smx_host_t) (data, void*)
host_get_current_power_peak True (double) (host, void*, smx_host_t)
host_get_power_peak_at True (double) (host, void*, smx_host_t) (pstate_index, int)
host_get_nb_pstates True (int) (host, void*, smx_host_t)
static inline void simcall_host_get_state__set__host(smx_simcall_t simcall, void* arg){
simcall->args[0].dp = arg;
}
-static inline smx_host_t simcall_host_get_data__get__host(smx_simcall_t simcall){
- return (smx_host_t) simcall->args[0].dp;
-}
-static inline void simcall_host_get_data__set__host(smx_simcall_t simcall, void* arg){
- simcall->args[0].dp = arg;
-}
-static inline smx_host_t simcall_host_set_data__get__host(smx_simcall_t simcall){
- return (smx_host_t) simcall->args[0].dp;
-}
-static inline void simcall_host_set_data__set__host(smx_simcall_t simcall, void* arg){
- simcall->args[0].dp = arg;
-}
-static inline void* simcall_host_set_data__get__data(smx_simcall_t simcall){
- return simcall->args[1].dp;
-}
-static inline void simcall_host_set_data__set__data(smx_simcall_t simcall, void* arg){
- simcall->args[1].dp = arg;
-}
static inline smx_host_t simcall_host_get_current_power_peak__get__host(smx_simcall_t simcall){
return (smx_host_t) simcall->args[0].dp;
}
}
return self->simcall.result.i;
}
- inline static void* simcall_BODY_host_get_data(smx_host_t host) {
- smx_process_t self = SIMIX_process_self();
- self->simcall.call = SIMCALL_HOST_GET_DATA;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) host;
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
- } else {
- SIMIX_simcall_pre(&self->simcall, 0);
- }
- return self->simcall.result.dp;
- }
- inline static void simcall_BODY_host_set_data(smx_host_t host, void* data) {
- smx_process_t self = SIMIX_process_self();
- self->simcall.call = SIMCALL_HOST_SET_DATA;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) host;
- self->simcall.args[1].dp = (void*) data;
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
- } else {
- SIMIX_simcall_pre(&self->simcall, 0);
- }
-
- }
inline static double simcall_BODY_host_get_current_power_peak(smx_host_t host) {
smx_process_t self = SIMIX_process_self();
self->simcall.call = SIMCALL_HOST_GET_CURRENT_POWER_PEAK;
SIMIX_simcall_answer(simcall);
break;
-case SIMCALL_HOST_GET_DATA:
- simcall->result.dp = SIMIX_pre_host_get_data(simcall , (smx_host_t) simcall->args[0].dp);
- SIMIX_simcall_answer(simcall);
- break;
-
-case SIMCALL_HOST_SET_DATA:
- SIMIX_pre_host_set_data(simcall , (smx_host_t) simcall->args[0].dp, simcall->args[1].dp);
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_HOST_GET_CURRENT_POWER_PEAK:
simcall->result.d = SIMIX_pre_host_get_current_power_peak(simcall , (smx_host_t) simcall->args[0].dp);
SIMIX_simcall_answer(simcall);
SIMCALL_HOST_GET_SPEED,
SIMCALL_HOST_GET_AVAILABLE_SPEED,
SIMCALL_HOST_GET_STATE,
-SIMCALL_HOST_GET_DATA,
-SIMCALL_HOST_SET_DATA,
SIMCALL_HOST_GET_CURRENT_POWER_PEAK,
SIMCALL_HOST_GET_POWER_PEAK_AT,
SIMCALL_HOST_GET_NB_PSTATES,
static inline void simcall_host_get_state__set__result(smx_simcall_t simcall, int result){
simcall->result.i = result;
}
-static inline void* simcall_host_get_data__get__result(smx_simcall_t simcall){
- return simcall->result.dp;
-}
-static inline void simcall_host_get_data__set__result(smx_simcall_t simcall, void* result){
- simcall->result.dp = result;
-}
-
-
static inline double simcall_host_get_current_power_peak__get__result(smx_simcall_t simcall){
return simcall->result.d;
}
[SIMCALL_HOST_GET_SPEED] = "SIMCALL_HOST_GET_SPEED",
[SIMCALL_HOST_GET_AVAILABLE_SPEED] = "SIMCALL_HOST_GET_AVAILABLE_SPEED",
[SIMCALL_HOST_GET_STATE] = "SIMCALL_HOST_GET_STATE",
-[SIMCALL_HOST_GET_DATA] = "SIMCALL_HOST_GET_DATA",
-[SIMCALL_HOST_SET_DATA] = "SIMCALL_HOST_SET_DATA",
[SIMCALL_HOST_GET_CURRENT_POWER_PEAK] = "SIMCALL_HOST_GET_CURRENT_POWER_PEAK",
[SIMCALL_HOST_GET_POWER_PEAK_AT] = "SIMCALL_HOST_GET_POWER_PEAK_AT",
[SIMCALL_HOST_GET_NB_PSTATES] = "SIMCALL_HOST_GET_NB_PSTATES",
s_smx_process_t proc;
/* Host structure */
- smx_host->data = data;
smx_host->process_list =
xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
return surf_resource_get_state(surf_workstation_resource_priv(host));
}
-void* SIMIX_pre_host_self_get_data(smx_simcall_t simcall){
- return SIMIX_host_self_get_data();
-}
-void* SIMIX_host_self_get_data(void)
-{
- smx_host_t self = SIMIX_host_self();
- return SIMIX_host_get_data(self);
-}
-
-void SIMIX_host_self_set_data(void *data)
-{
- smx_host_t self = SIMIX_host_self();
- SIMIX_host_set_data(self, data);
-}
-
-void* SIMIX_pre_host_get_data(smx_simcall_t simcall,smx_host_t host){
- return SIMIX_host_get_data(host);
-}
-void* SIMIX_host_get_data(smx_host_t host){
- xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
-
- return SIMIX_host_priv(host)->data;
-}
-
void _SIMIX_host_free_process_arg(void *data)
{
smx_process_arg_t arg = *(void**)data;
xbt_die("No function for simix_global->autorestart");
}
-void SIMIX_pre_host_set_data(smx_simcall_t simcall, smx_host_t host, void *data) {
- SIMIX_host_set_data(host, data);
-}
-void SIMIX_host_set_data(smx_host_t host, void *data){
- xbt_assert((host != NULL), "Invalid parameters");
- xbt_assert((SIMIX_host_priv(host)->data == NULL), "Data already set");
-
- SIMIX_host_priv(host)->data = data;
-}
-
smx_action_t SIMIX_pre_host_execute(smx_simcall_t simcall,const char *name,
smx_host_t host, double computation_amount, double priority, double bound, unsigned long affinity_mask){
return SIMIX_host_execute(name, host, computation_amount, priority, bound, affinity_mask);
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;
static inline smx_host_priv_t SIMIX_host_priv(smx_host_t host){
void SIMIX_pre_host_set_power_peak_at(smx_simcall_t, smx_host_t host, int pstate_index);
double SIMIX_pre_host_get_consumed_energy(smx_simcall_t, smx_host_t);
void* SIMIX_pre_host_self_get_data(smx_simcall_t);
-void* SIMIX_pre_host_get_data(smx_simcall_t, smx_host_t);
-void SIMIX_pre_host_set_data(smx_simcall_t, smx_host_t, void*);
smx_action_t SIMIX_pre_host_execute(smx_simcall_t, const char*, smx_host_t, double, double, double, unsigned long);
smx_action_t SIMIX_pre_host_parallel_execute(smx_simcall_t, const char*, int, smx_host_t*,
double*, double*, double, double);
return simcall_BODY_host_get_state(host);
}
-/**
- * \ingroup simix_host_management
- * \brief Returns the user data associated to a host.
- *
- * \param host SIMIX host
- * \return the user data of this host
- */
-void* simcall_host_get_data(smx_host_t host)
-{
- return simcall_BODY_host_get_data(host);
-}
-
-/**
- * \ingroup simix_host_management
- * \brief Sets the user data associated to a host.
- *
- * The host must not have previous user data associated to it.
- * \param host A SIMIX host
- * \param data The user data to set
- */
-void simcall_host_set_data(smx_host_t host, void *data)
-{
- simcall_host_set_data(host, data);
-}
-
/**
* \ingroup simix_host_management
* \brief Returns the power peak of a host.
}
xbt_dict_t Resource::getProperties() {
+ if (p_properties==NULL)
+ p_properties = xbt_dict_new();
return p_properties;
}