xbt/xbt_sg_stubs.c
if CONTEXT_THREADS
- SURF_SRC += xbt/xbt_os_thread.c xbt/xbt_context_thread.c
-else
- SURF_SRC += xbt/xbt_context_sysv.c
+ SURF_SRC += xbt/xbt_os_thread.c
endif
GTNETS_SRC= \
# Separated because src/gras/rl_stubs also define the function xbt_context_mod_init() and xbt_context_mod_exit()
# so there is an implementation of these functions in the simgrid library and an implementatin in the gras library
-CTX_SRC= xbt/xbt_context.c
+CTX_SRC= simix/xbt_context.c
SIMIX_SRC= \
simix/smx_global.c \
simix/smx_process.c \
simix/smx_action.c \
simix/smx_synchro.c
+
+if CONTEXT_THREADS
+ SURF_SRC += simix/xbt_context_thread.c
+else
+ SURF_SRC += simix/xbt_context_sysv.c
+endif
SMPI_SRC= \
smpi/smpi_base.c \
msg/msg_actions.c
JMSG_C_SRC = \
- xbt/xbt_context_java.c \
+ simix/xbt_context_java.c \
java/jxbt_utilities.c java/jxbt_utilities.h \
java/jmsg.c java/jmsg.h \
java/jmsg_channel.c java/jmsg_channel.h \
const char *gras_os_myname(void)
{
smx_process_t process = SIMIX_process_self();
- if ((process != NULL) && (process->simdata))
+ if (process != NULL)
return SIMIX_host_get_name(SIMIX_host_self());
else
return "";
{
const char *res = NULL;
smx_process_t process = SIMIX_process_self();
- if ((process != NULL) && (process->simdata))
+ if (process != NULL)
res = SIMIX_process_get_name(process);
if (res)
return res;
int gras_os_getpid(void)
{
-
+ gras_procdata_t *data;
smx_process_t process = SIMIX_process_self();
-
- if ((process != NULL) && (process->data))
- return ((gras_procdata_t *) process->data)->pid;
- else
- return 0;
+
+ if (process != NULL){
+ data = (gras_procdata_t *)SIMIX_process_get_data(process);
+ return data->pid;
+ }
+
+ return 0;
}
-
/** @brief retrieve the value of a given host property (or NULL if not defined) */
const char *gras_os_host_property_value(const char *name)
{
-#ifndef XBT_CONTEXT_H\r
-#define XBT_CONTEXT_H\r
-\r
-#include "xbt/misc.h" /* XBT_PUBLIC(), SG_BEGIN_DECL() and SG_END_DECL() definitions */\r
-#include "xbt/function_types.h" /* function pointer types declarations */ \r
-#include "xbt_modinter.h" /* xbt_context_init() and xbt_context_exit() declarations */\r
- \rSG_BEGIN_DECL() \r \rtypedef struct s_xbt_context *xbt_context_t;
-\r\r\rXBT_PUBLIC(xbt_context_t) \r
-xbt_context_new(const char *name, xbt_main_func_t code,
- \rvoid_f_pvoid_t startup_func, void *startup_arg,
- \rvoid_f_pvoid_t cleanup_func, void *cleanup_arg, int argc,
- \rchar *argv[]);
-\r\r\rXBT_PUBLIC(void) \r xbt_context_kill(xbt_context_t context);
-\r\r\rXBT_PUBLIC(void) \r xbt_context_start(xbt_context_t context);
-\r\r\rXBT_PUBLIC(void) \r xbt_context_yield(void);
-\r\r\rXBT_PUBLIC(void) \r xbt_context_schedule(xbt_context_t context);
- \r\r\rvoid \rxbt_context_empty_trash(void);
- \r\r\rvoid \rxbt_context_stop(int exit_code);
- \r\r\rvoid \rxbt_context_free(xbt_context_t context);
-\r\r\r\rSG_END_DECL() \r \r
-#endif /* !XBT_CONTEXT_H */\r
+#ifndef XBT_CONTEXT_H
+#define XBT_CONTEXT_H
+
+#include "xbt/misc.h" /* XBT_PUBLIC(), SG_BEGIN_DECL() and SG_END_DECL() definitions */
+#include "xbt/function_types.h" /* function pointer types declarations */
+#include "xbt_modinter.h" /* xbt_context_init() and xbt_context_exit() declarations */
+
+SG_BEGIN_DECL()
+
+typedef struct s_xbt_context *xbt_context_t;
+
+XBT_PUBLIC(xbt_context_t) xbt_context_new(const char *name, xbt_main_func_t code,
+ void_f_pvoid_t startup_func, void *startup_arg,
+ void_f_pvoid_t cleanup_func, void *cleanup_arg, int argc, char *argv[]);
+
+XBT_PUBLIC(void) xbt_context_kill(xbt_context_t context);
+
+XBT_PUBLIC(void) xbt_context_start(xbt_context_t context);
+
+XBT_PUBLIC(void) xbt_context_yield(void);
+
+XBT_PUBLIC(void) xbt_context_schedule(xbt_context_t context);
+
+void xbt_context_empty_trash(void);
+
+void xbt_context_stop(int exit_code);
+
+void xbt_context_free(xbt_context_t context);
+
+SG_END_DECL()
+
+#endif /* !XBT_CONTEXT_H */
SG_BEGIN_DECL()
/* ******************************** Host ************************************ */
-/** @defgroup m_datatypes_management_details Details on SIMIX datatypes
- @ingroup m_datatypes_management*/
- typedef struct s_smx_simdata_host *smx_simdata_host_t;
-/** @brief Host datatype
- @ingroup m_datatypes_management_details */
- typedef struct s_smx_host {
- char *name; /**< @brief host name if any */
- smx_simdata_host_t simdata;
- /**< @brief simulator data */
- void *data; /**< @brief user data */
- } s_smx_host_t;
+/** @defgroup m_datatypes_management_details Details on SIMIX datatypes */
/** @brief Host datatype
@ingroup m_datatypes_management
/* ****************************** Process *********************************** */
- typedef struct s_smx_simdata_process *smx_simdata_process_t;
-/** @brief Process datatype
- @ingroup m_datatypes_management_details @{ */
- typedef struct s_smx_process {
-
- char *name; /**< @brief process name if any */
- smx_simdata_process_t simdata; /**< @brief simulator data */
- s_xbt_swag_hookup_t process_hookup;
- s_xbt_swag_hookup_t synchro_hookup;
- s_xbt_swag_hookup_t host_proc_hookup;
- void *data; /**< @brief user data */
- } s_smx_process_t;
-/** @} */
/** @brief Agent datatype
@ingroup m_datatypes_management
XBT_PUBLIC(void) SIMIX_process_suspend(smx_process_t process);
XBT_PUBLIC(void) SIMIX_process_resume(smx_process_t process);
XBT_PUBLIC(int) SIMIX_process_is_suspended(smx_process_t process);
+XBT_PUBLIC(int) SIMIX_process_is_blocked(smx_process_t process);
/*property handlers*/
XBT_PUBLIC(xbt_dict_t) SIMIX_process_get_properties(smx_process_t host);
m_host_t MSG_get_host_by_name(const char *name)
{
smx_host_t simix_h = NULL;
-
simix_h = SIMIX_host_get_by_name(name);
- if (simix_h == NULL) {
+
+ if (simix_h == NULL)
return NULL;
- } else
- return (m_host_t) simix_h->data;
+
+ return (m_host_t)SIMIX_host_get_data(simix_h);
}
/** \ingroup msg_easier_life
#include "xbt/dynar.h"
#include "xbt/swag.h"
#include "xbt/dict.h"
-#include "xbt/context.h"
#include "xbt/config.h"
SG_BEGIN_DECL()
#include "xbt/fifo.h"
#include "xbt/swag.h"
#include "xbt/dict.h"
-#include "xbt/context.h"
+#include "simix/context.h"
+#include "xbt/config.h"
#include "xbt/function_types.h"
/******************************* Datatypes **********************************/
/********************************** Host ************************************/
-typedef struct s_smx_simdata_host {
- void *host; /* SURF modeling */
+/** @brief Host datatype
+ @ingroup m_datatypes_management_details */
+typedef struct s_smx_host {
+ char *name; /**< @brief host name if any */
+ void *host; /* SURF modeling */
xbt_swag_t process_list;
-} s_smx_simdata_host_t;
+ void *data; /**< @brief user data */
+} s_smx_host_t;
/********************************* Simix Global ******************************/
/******************************* Process *************************************/
-typedef struct s_smx_simdata_process {
- smx_host_t smx_host; /* the host on which the process is running */
- xbt_context_t context; /* the context that executes the scheduler fonction */
- int blocked;
- int suspended;
- smx_mutex_t mutex; /* mutex on which the process is blocked */
- smx_cond_t cond; /* cond on which the process is blocked */
- int argc; /* arguments number if any */
- char **argv; /* arguments table if any */
- xbt_dict_t properties;
-} s_smx_simdata_process_t;
+/** @brief Process datatype
+ @ingroup m_datatypes_management_details @{ */
+ typedef struct s_smx_process {
+ s_xbt_swag_hookup_t process_hookup;
+ s_xbt_swag_hookup_t synchro_hookup;
+ s_xbt_swag_hookup_t host_proc_hookup;
+
+ char *name; /**< @brief process name if any */
+ smx_host_t smx_host; /* the host on which the process is running */
+ xbt_context_t context; /* the context that executes the scheduler function */
+ int argc; /* arguments number if any */
+ char **argv; /* arguments table if any */
+ int blocked : 1;
+ int suspended : 1;
+ int iwannadie : 1;
+ smx_mutex_t mutex; /* mutex on which the process is blocked */
+ smx_cond_t cond; /* cond on which the process is blocked */
+ xbt_dict_t properties;
+ void *data; /* kept for compatibility, it should be replaced with moddata */
+
+ } s_smx_process_t;
+/** @} */
typedef struct s_smx_process_arg {
const char *name;
#define SIMIX_CHECK_HOST() xbt_assert0(surf_workstation_model->extension.workstation. \
- get_state(SIMIX_host_self()->simdata->host)==SURF_RESOURCE_ON,\
+ get_state(SIMIX_host_self()->host)==SURF_RESOURCE_ON,\
"Host failed, you cannot call this function.")
smx_host_t __SIMIX_host_create(const char *name, void *workstation,
/* check if the host is active */
if (surf_workstation_model->extension.
- workstation.get_state(sender->simdata->host) != SURF_RESOURCE_ON) {
+ workstation.get_state(sender->host) != SURF_RESOURCE_ON) {
THROW1(network_error, 0, "Host %s failed, you cannot call this function",
sender->name);
}
if (surf_workstation_model->extension.
- workstation.get_state(receiver->simdata->host) != SURF_RESOURCE_ON) {
+ workstation.get_state(receiver->host) != SURF_RESOURCE_ON) {
THROW1(network_error, 0, "Host %s failed, you cannot call this function",
receiver->name);
}
simdata->surf_action =
surf_workstation_model->extension.workstation.
- communicate(sender->simdata->host, receiver->simdata->host, size, rate);
+ communicate(sender->host, receiver->host, size, rate);
surf_workstation_model->action_data_set(simdata->surf_action, act);
DEBUG1("Create communicate action %p", act);
/* check if the host is active */
if (surf_workstation_model->extension.
- workstation.get_state(host->simdata->host) != SURF_RESOURCE_ON) {
+ workstation.get_state(host->>host) != SURF_RESOURCE_ON) {
THROW1(host_error, 0, "Host %s failed, you cannot call this function",
host->name);
}
/* set communication */
simdata->surf_action =
- surf_workstation_model->extension.workstation.execute(host->simdata->host,
+ surf_workstation_model->extension.workstation.execute(host->host,
amount);
surf_workstation_model->action_data_set(simdata->surf_action, act);
/* check if the host is active */
if (surf_workstation_model->extension.
- workstation.get_state(host->simdata->host) != SURF_RESOURCE_ON) {
+ workstation.get_state(host->host) != SURF_RESOURCE_ON) {
THROW1(host_error, 0, "Host %s failed, you cannot call this function",
host->name);
}
act->name = xbt_strdup(name);
simdata->surf_action =
- surf_workstation_model->extension.workstation.sleep(host->simdata->host,
+ surf_workstation_model->extension.workstation.sleep(host->host,
duration);
surf_workstation_model->action_data_set(simdata->surf_action, act);
workstation_list = xbt_new0(void *, host_nb);
for (i = 0; i < host_nb; i++)
- workstation_list[i] = host_list[i]->simdata->host;
+ workstation_list[i] = host_list[i]->host;
simdata->surf_action =
surf_workstation_model->extension.
INFO0
("Legend of the following listing: \"<process> on <host>: <status>.\"");
xbt_swag_foreach(process, simix_global->process_list) {
- smx_simdata_process_t p_simdata =
- (smx_simdata_process_t) process->simdata;
- // simdata_host_t h_simdata=(simdata_host_t)p_simdata->host->simdata;
char *who, *who2;
asprintf(&who, "%s on %s: %s",
process->name,
- p_simdata->smx_host->name,
- (process->simdata->blocked) ? "[BLOCKED] "
- : ((process->simdata->suspended) ? "[SUSPENDED] " : ""));
+ process->smx_host->name,
+ (process->blocked) ? "[BLOCKED] "
+ : ((process->suspended) ? "[SUSPENDED] " : ""));
- if (p_simdata->mutex) {
+ if (process->mutex) {
who2 =
bprintf("%s Blocked on mutex %p", who,
(XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
- p_simdata->mutex : (void *) 0xdead);
+ process->mutex : (void *) 0xdead);
free(who);
who = who2;
- } else if (p_simdata->cond) {
+ } else if (process->cond) {
who2 =
bprintf
("%s Blocked on condition %p; Waiting for the following actions:",
who,
(XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
- p_simdata->cond : (void *) 0xdead);
+ process->cond : (void *) 0xdead);
free(who);
who = who2;
- xbt_fifo_foreach(p_simdata->cond->actions, item, act, smx_action_t) {
+ xbt_fifo_foreach(process->cond->actions, item, act, smx_action_t) {
who2 =
bprintf("%s '%s'(%p)", who, act->name,
(XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose))
xbt_fifo_foreach(smx_action->cond_list, _cursor, cond, smx_cond_t) {
xbt_swag_foreach(process, cond->sleeping) {
DEBUG2("\t preparing to wake up %s on %s",
- process->name, process->simdata->smx_host->name);
+ process->name, process->smx_host->name);
}
SIMIX_cond_broadcast(cond);
/* remove conditional from action */
xbt_fifo_foreach(smx_action->cond_list, _cursor, cond, smx_cond_t) {
xbt_swag_foreach(process, cond->sleeping) {
DEBUG2("\t preparing to wake up %s on %s",
- process->name, process->simdata->smx_host->name);
+ process->name, process->smx_host->name);
}
SIMIX_cond_broadcast(cond);
/* remove conditional from action */
while ((process = xbt_swag_extract(simix_global->process_to_run))) {
DEBUG2("Scheduling %s on %s",
- process->name, process->simdata->smx_host->name);
+ process->name, process->smx_host->name);
simix_global->current_process = process;
- xbt_context_schedule(process->simdata->context);
+ xbt_context_schedule(process->context);
/* fflush(NULL); */
simix_global->current_process = NULL;
}
if (fun == SIMIX_process_kill) {
process = arg;
DEBUG2("Killing %s on %s", process->name,
- process->simdata->smx_host->name);
+ process->smx_host->name);
SIMIX_process_kill(process);
}
}
smx_host_t __SIMIX_host_create(const char *name,
void *workstation, void *data)
{
- smx_simdata_host_t simdata = xbt_new0(s_smx_simdata_host_t, 1);
- smx_host_t host = xbt_new0(s_smx_host_t, 1);
+ smx_host_t smx_host = xbt_new0(s_smx_host_t, 1);
s_smx_process_t proc;
/* Host structure */
- host->name = xbt_strdup(name);
- host->simdata = simdata;
- host->data = data;
-
- simdata->host = workstation;
+ smx_host->name = xbt_strdup(name);
+ smx_host->data = data;
+ smx_host->host = workstation;
+ smx_host->process_list = xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
- simdata->process_list =
- xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
/* Update global variables */
+ xbt_dict_set(simix_global->host, smx_host->name, smx_host, &__SIMIX_host_destroy);
- xbt_dict_set(simix_global->host, host->name, host, &__SIMIX_host_destroy);
-
- return host;
+ return smx_host;
}
/**
xbt_assert0((host != NULL), "Invalid parameters");
/* Return data */
- return (host->data);
+ return host->data;
}
/**
const char *SIMIX_host_get_name(smx_host_t host)
{
- xbt_assert0((host != NULL)
- && (host->simdata != NULL), "Invalid parameters");
+ xbt_assert0((host != NULL), "Invalid parameters");
/* Return data */
- return (host->name);
+ return host->name;
}
/**
void __SIMIX_host_destroy(void *h)
{
smx_host_t host = (smx_host_t) h;
- smx_simdata_host_t simdata = NULL;
xbt_assert0((host != NULL), "Invalid parameters");
-
/* Clean Simulator data */
- simdata = host->simdata;
-
- if (xbt_swag_size(simdata->process_list) != 0) {
- char *msg =
- bprintf("Shutting down host %s, but it's not empty:", host->name);
+ if (xbt_swag_size(host->process_list) != 0) {
+ char *msg = bprintf("Shutting down host %s, but it's not empty:", host->name);
char *tmp;
smx_process_t process = NULL;
- xbt_swag_foreach(process, simdata->process_list) {
+ xbt_swag_foreach(process, host->process_list) {
tmp = bprintf("%s\n\t%s", msg, process->name);
free(msg);
msg = tmp;
THROW1(arg_error, 0, "%s", msg);
}
- xbt_swag_free(simdata->process_list);
-
- free(simdata);
+ xbt_swag_free(host->process_list);
/* Clean host structure */
free(host->name);
xbt_assert0((host != NULL), "Invalid parameters");
return (surf_workstation_model->extension.workstation.
- get_speed(host->simdata->host, 1.0));
+ get_speed(host->host, 1.0));
}
/**
xbt_assert0((host != NULL), "Invalid parameters");
return (surf_workstation_model->extension.workstation.
- get_available_speed(host->simdata->host));
+ get_available_speed(host->host));
}
/**
{
xbt_assert0((host != NULL), "Invalid parameters");
- return surf_workstation_model->extension.workstation.get_properties(host->simdata->host);
-
+ return surf_workstation_model->extension.workstation.get_properties(host->host);
}
xbt_assert0((host != NULL), "Invalid parameters");
return (surf_workstation_model->extension.workstation.
- get_state(host->simdata->host));
-
+ get_state(host->host));
}
{
xbt_swag_remove(arg, simix_global->process_list);
xbt_swag_remove(arg, simix_global->process_to_run);
- xbt_swag_remove(arg,
- ((smx_process_t) arg)->simdata->smx_host->
- simdata->process_list);
+ xbt_swag_remove(arg,((smx_process_t) arg)->smx_host->process_list);
free(((smx_process_t) arg)->name);
((smx_process_t) arg)->name = NULL;
- free(((smx_process_t) arg)->simdata);
- ((smx_process_t) arg)->simdata = NULL;
free(arg);
}
const char *hostname, int argc,
char **argv, xbt_dict_t properties)
{
- smx_simdata_process_t simdata = NULL;
smx_process_t process = NULL;
smx_process_t self = NULL;
smx_host_t host = SIMIX_host_get_by_name(hostname);
WARN2("Cannot launch process '%s' on failed host '%s'", name, hostname);
return NULL;
}
- simdata = xbt_new0(s_smx_simdata_process_t, 1);
process = xbt_new0(s_smx_process_t, 1);
/*char alias[MAX_ALIAS_NAME + 1] = {0};
msg_mailbox_t mailbox; */
xbt_assert0(((code != NULL) && (host != NULL)), "Invalid parameters");
- /* Simulator Data */
-
- simdata->smx_host = host;
- simdata->mutex = NULL;
- simdata->cond = NULL;
- simdata->argc = argc;
- simdata->argv = argv;
- simdata->context = xbt_context_new(name, code, NULL, NULL,
- simix_global->cleanup_process_function,
- process, simdata->argc, simdata->argv);
- /* Process structure */
+ /* Process data */
process->name = xbt_strdup(name);
- process->simdata = simdata;
+ process->smx_host = host;
+ process->argc = argc;
+ process->argv = argv;
+ process->mutex = NULL;
+ process->cond = NULL;
+ process->context = xbt_context_new(name, code, NULL, NULL,
+ simix_global->cleanup_process_function,
+ process, process->argc, process->argv);
process->data = data;
/* Add properties */
- simdata->properties = properties;
+ process->properties = properties;
- xbt_swag_insert(process, host->simdata->process_list);
+ /* Add the process to it's host process list */
+ xbt_swag_insert(process, host->process_list);
/* fix current_process, about which xbt_context_start mocks around */
self = simix_global->current_process;
- xbt_context_start(process->simdata->context);
+ xbt_context_start(process->context);
simix_global->current_process = self;
+ /* Now insert it in the global process list */
xbt_swag_insert(process, simix_global->process_list);
DEBUG2("Inserting %s(%s) in the to_run list", process->name, host->name);
xbt_swag_insert(process, simix_global->process_to_run);
void *data,
void *jprocess, void *jenv, smx_process_t * res)
{
- smx_simdata_process_t simdata = xbt_new0(s_smx_simdata_process_t, 1);
smx_process_t process = xbt_new0(s_smx_process_t, 1);
smx_process_t self = NULL;
*/
*res = process;
-
-
DEBUG5("jprocess_create(name=%s,host=%p,data=%p,jproc=%p,jenv=%p)",
name, host, data, jprocess, jenv);
xbt_assert0(host, "Invalid parameters");
- /* Simulator Data */
- simdata->smx_host = host;
- simdata->mutex = NULL;
- simdata->cond = NULL;
- simdata->argc = 0;
- simdata->argv = NULL;
-
-
- simdata->context = xbt_context_new(name, NULL, NULL, jprocess,
- simix_global->cleanup_process_function,
- process,
- /* argc/argv */ 0, NULL);
- /* Process structure */
+ /* Process data */
process->name = xbt_strdup(name);
- process->simdata = simdata;
+ process->smx_host = host;
+ process->argc = 0;
+ process->argv = NULL;
+ process->mutex = NULL;
+ process->cond = NULL;
+ process->context = xbt_context_new(name, NULL, NULL, jprocess,
+ simix_global->cleanup_process_function,
+ process, 0, NULL);
process->data = data;
- xbt_swag_insert(process, host->simdata->process_list);
+ /* Add the process to it's host process list */
+ xbt_swag_insert(process, host->process_list);
/* fix current_process, about which xbt_context_start mocks around */
self = simix_global->current_process;
-
- xbt_context_start(process->simdata->context);
-
+ xbt_context_start(process->context);
simix_global->current_process = self;
xbt_swag_insert(process, simix_global->process_list);
DEBUG2("Inserting %s(%s) in the to_run list", process->name, host->name);
xbt_swag_insert(process, simix_global->process_to_run);
-
}
-
/** \brief Kill a SIMIX process
*
* This function simply kills a \a process... scarry isn't it ? :).
*/
void SIMIX_process_kill(smx_process_t process)
{
- smx_simdata_process_t p_simdata = process->simdata;
-
DEBUG2("Killing process %s on %s", process->name,
- p_simdata->smx_host->name);
+ process->smx_host->name);
/* Cleanup if we were waiting for something */
- if (p_simdata->mutex)
- xbt_swag_remove(process, p_simdata->mutex->sleeping);
+ if (process->mutex)
+ xbt_swag_remove(process, process->mutex->sleeping);
- if (p_simdata->cond)
- xbt_swag_remove(process, p_simdata->cond->sleeping);
+ if (process->cond)
+ xbt_swag_remove(process, process->cond->sleeping);
xbt_swag_remove(process, simix_global->process_to_run);
xbt_swag_remove(process, simix_global->process_list);
DEBUG2("%p here! killing %p", simix_global->current_process, process);
- xbt_context_kill(process->simdata->context);
+ xbt_context_kill(process->context);
if (process == SIMIX_process_self()) {
/* I just killed myself */
void SIMIX_process_set_data(smx_process_t process, void *data)
{
xbt_assert0((process != NULL), "Invalid parameters");
- //xbt_assert0((process->data == NULL), "Data already set");
process->data = data;
-
return;
}
*/
smx_host_t SIMIX_process_get_host(smx_process_t process)
{
- xbt_assert0(((process != NULL)
- && (process->simdata)), "Invalid parameters");
-
- return (process->simdata->smx_host);
+ xbt_assert0((process != NULL), "Invalid parameters");
+ return (process->smx_host);
}
/**
*/
const char *SIMIX_process_get_name(smx_process_t process)
{
- xbt_assert0(((process != NULL)
- && (process->simdata)), "Invalid parameters");
-
+ xbt_assert0((process != NULL), "Invalid parameters");
return (process->name);
}
*/
void SIMIX_process_set_name(smx_process_t process, char *name)
{
- xbt_assert0(((process != NULL)
- && (process->simdata)), "Invalid parameters");
-
+ xbt_assert0((process != NULL), "Invalid parameters");
process->name = name;
}
*/
xbt_dict_t SIMIX_process_get_properties(smx_process_t process)
{
- return process->simdata->properties;
+ return process->properties;
}
/**
*/
void SIMIX_process_suspend(smx_process_t process)
{
- smx_simdata_process_t simdata = NULL;
-
- xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
+ xbt_assert0(process, "Invalid parameters");
if (process != SIMIX_process_self()) {
- simdata = process->simdata;
- if (simdata->mutex) {
+ if (process->mutex) {
/* process blocked on a mutex, only set suspend=1 */
- simdata->suspended = 1;
- } else if (simdata->cond) {
+ process->suspended = 1;
+ } else if (process->cond) {
/* process blocked cond, suspend all actions */
/* temporaries variables */
xbt_fifo_item_t i;
smx_action_t act;
- simdata->suspended = 1;
- c = simdata->cond;
+ process->suspended = 1;
+ c = process->cond;
xbt_fifo_foreach(c->actions, i, act, smx_action_t) {
- surf_workstation_model->suspend(act->simdata->surf_action);
+ surf_workstation_model->suspend(act->surf_action);
}
} else {
- simdata->suspended = 1;
+ process->suspended = 1;
}
} else {
/* process executing, I can create an action and suspend it */
smx_action_t dummy;
smx_cond_t cond;
char name[] = "dummy";
- process->simdata->suspended = 1;
+ process->suspended = 1;
cond = SIMIX_cond_init();
dummy = SIMIX_action_execute(SIMIX_process_get_host(process), name, 0);
*/
void SIMIX_process_resume(smx_process_t process)
{
- smx_simdata_process_t simdata = NULL;
-
- xbt_assert0(((process != NULL)
- && (process->simdata)), "Invalid parameters");
+ xbt_assert0((process != NULL), "Invalid parameters");
SIMIX_CHECK_HOST();
- if (process == SIMIX_process_self()) {
+ if (process == SIMIX_process_self())
return;
- }
- simdata = process->simdata;
- if (simdata->mutex) {
+ if (process->mutex) {
DEBUG0("Resume process blocked on a mutex");
- simdata->suspended = 0; /* It'll wake up by itself when mutex releases */
+ process->suspended = 0; /* It'll wake up by itself when mutex releases */
return;
- } else if (simdata->cond) {
+ } else if (process->cond) {
/* temporaries variables */
smx_cond_t c;
xbt_fifo_item_t i;
smx_action_t act;
DEBUG0("Resume process blocked on a conditional");
- simdata->suspended = 0;
- c = simdata->cond;
+ process->suspended = 0;
+ c = process->cond;
xbt_fifo_foreach(c->actions, i, act, smx_action_t) {
surf_workstation_model->resume(act->simdata->surf_action);
}
SIMIX_cond_signal(c);
return;
} else {
- simdata->suspended = 0;
+ process->suspended = 0;
xbt_swag_insert(process, simix_global->process_to_run);
}
-
}
/**
*
* This function changes the value of the host on which \a process is running.
*/
-void SIMIX_process_change_host(smx_process_t process, char *source,
- char *dest)
+void SIMIX_process_change_host(smx_process_t process, char *source, char *dest)
{
- smx_simdata_process_t p_simdata = process->simdata;
+ xbt_assert0((process != NULL), "Invalid parameters");
smx_host_t h1 = SIMIX_host_get_by_name(source);
smx_host_t h2 = SIMIX_host_get_by_name(dest);
- p_simdata->smx_host = h2;
- xbt_swag_remove(process, h1->simdata->process_list);
- xbt_swag_insert(process, h2->simdata->process_list);
+ process->smx_host = h2;
+ xbt_swag_remove(process, h1->process_list);
+ xbt_swag_insert(process, h2->process_list);
}
/**
*/
int SIMIX_process_is_suspended(smx_process_t process)
{
- xbt_assert0(((process != NULL)
- && (process->simdata)), "Invalid parameters");
+ xbt_assert0(((process != NULL), "Invalid parameters");
- return (process->simdata->suspended);
+ return (process->suspended);
}
/**
if (mutex->refcount) {
/* somebody using the mutex, block */
xbt_swag_insert(self, mutex->sleeping);
- self->simdata->mutex = mutex;
+ self->mutex = mutex;
/* wait for some process make the unlock and wake up me from mutex->sleeping */
xbt_context_yield();
- self->simdata->mutex = NULL;
+ self->mutex = NULL;
/* verify if the process was suspended */
- while (self->simdata->suspended) {
+ while (self->suspended) {
xbt_context_yield();
}
/**
* \brief Signalizes a condition.
*
- * Signalizes a condition and wakes up a sleping process. If there are no process sleeping, no action is done.
+ * Signalizes a condition and wakes up a sleeping process. If there are no process sleeping, no action is done.
* \param cond A condition
*/
void SIMIX_cond_signal(smx_cond_t cond)
/* process status */
- self->simdata->cond = cond;
+ self->cond = cond;
xbt_swag_insert(self, cond->sleeping);
xbt_context_yield();
- self->simdata->cond = NULL;
- while (self->simdata->suspended) {
+ self->cond = NULL;
+ while (self->suspended) {
xbt_context_yield();
}
return;
INFO0("Blocked process on this condition:");
xbt_swag_foreach(process, cond->sleeping) {
INFO2("\t %s running on host %s", process->name,
- process->simdata->smx_host->name);
+ process->smx_host->name);
}
}
}
/* the context associated with the maestro */
xbt_context_t maestro_context = NULL;
-
/* this list contains the contexts to destroy */
xbt_swag_t context_to_destroy = NULL;
const char *name)
{
if (!strcmp(name, "java"))
+#ifdef HAVE_JAVA
xbt_ctx_java_factory_init(factory);
-#ifdef CONTEXT_THREADS
+#else
+ THROW0(not_found_error, 0, "Factory 'Java' does not exist: Java support was not compiled in the SimGrid library");
+#endif /* HAVE_JAVA */
+
else if (!strcmp(name, "thread"))
+#ifdef CONTEXT_THREADS
xbt_ctx_thread_factory_init(factory);
-#elif !defined(WIN32)
+#else
+ THROW0(not_found_error, 0, "Factory 'thread' does not exist: thread support was not compiled in the SimGrid library");
+#endif /* CONTEXT_THREADS */
+
else if (!strcmp(name, "sysv"))
+#ifndef WIN32
xbt_ctx_sysv_factory_init(factory);
+#else
+ THROW0(not_found_error, 0, "Factory 'sysv' does not exist: no System V thread support under Windows");
#endif
+
else
THROW1(not_found_error, 0, "Factory '%s' does not exist", name);
+
}
/** Garbage collection
#define _XBT_CONTEXT_PRIVATE_H
#include "xbt/sysdep.h"
-#include "xbt/context.h"
+#include "simix/context.h"
#include "xbt/swag.h"
SG_BEGIN_DECL()
/* *********************** */
/* Context type definition */
/* *********************** */
-/* the following function pointers describe the interface that all context concepts must implement */
- typedef void (*xbt_pfn_context_free_t) (xbt_context_t); /* pointer type to the function used to destroy the specified context */
+/* the following function pointers types describe the interface that all context
+ concepts must implement */
- typedef void (*xbt_pfn_context_kill_t) (xbt_context_t); /* pointer type to the function used to kill the specified context */
+typedef void (*xbt_pfn_context_free_t) (xbt_context_t); /* function used to destroy the specified context */
- typedef void (*xbt_pfn_context_schedule_t) (xbt_context_t); /* pointer type to the function used to resume the specified context */
+typedef void (*xbt_pfn_context_kill_t) (xbt_context_t); /* function used to kill the specified context */
- typedef void (*xbt_pfn_context_yield_t) (void); /* pointer type to the function used to yield the specified context */
+typedef void (*xbt_pfn_context_schedule_t) (xbt_context_t); /* function used to resume the specified context */
- typedef void (*xbt_pfn_context_start_t) (xbt_context_t); /* pointer type to the function used to start the specified context */
+typedef void (*xbt_pfn_context_yield_t) (void); /* function used to yield the specified context */
- typedef void (*xbt_pfn_context_stop_t) (int); /* pointer type to the function used to stop the current context */
+typedef void (*xbt_pfn_context_start_t) (xbt_context_t); /* function used to start the specified context */
+
+typedef void (*xbt_pfn_context_stop_t) (int); /* function used to stop the current context */
/* each context type must contain this macro at its begining -- OOP in C :/ */
#define XBT_CTX_BASE_T \
xbt_pfn_context_stop_t stop
/* all other context types derive from this structure */
- typedef struct s_xbt_context {
- XBT_CTX_BASE_T;
- } s_xbt_context_t;
+typedef struct s_xbt_context {
+ XBT_CTX_BASE_T;
+} s_xbt_context_t;
/* ****************** */
/* Globals definition */
/* ****************** */
/* Important guys */
- extern xbt_context_t current_context;
-
- extern xbt_context_t maestro_context;
+extern xbt_context_t current_context;
+extern xbt_context_t maestro_context;
/* All dudes lists */
- extern xbt_swag_t context_living;
-
- extern xbt_swag_t context_to_destroy;
+extern xbt_swag_t context_living;
+extern xbt_swag_t context_to_destroy;
/* *********************** */
/* factory type definition */
/* *********************** */
- typedef struct s_xbt_context_factory *xbt_context_factory_t;
-
-/* this function describes the interface that all context factory must implement */
- typedef xbt_context_t(*xbt_pfn_context_factory_create_context_t) (const
- char *,
- xbt_main_func_t,
- void_f_pvoid_t,
- void *,
- void_f_pvoid_t,
- void *,
- int,
- char
- **);
- typedef
- int (*xbt_pfn_context_factory_create_maestro_context_t) (xbt_context_t
- *);
-
-/* this function finalize the specified context factory */
- typedef int (*xbt_pfn_context_factory_finalize_t) (xbt_context_factory_t
- *);
-
-/* this interface is used by the xbt context module to create the appropriate concept */
- typedef struct s_xbt_context_factory {
- xbt_pfn_context_factory_create_maestro_context_t create_maestro_context; /* create the context of the maestro */
- xbt_pfn_context_factory_create_context_t create_context; /* create a new context */
- xbt_pfn_context_factory_finalize_t finalize; /* finalize the context factory */
- const char *name; /* the name of the context factory */
-
- } s_xbt_context_factory_t;
-
-/**
- * This function select a context factory associated with the name specified by
- * the parameter name.
- * If successful the function returns 0. Otherwise the function returns the error
- * code.
- */
- int
- xbt_context_select_factory(const char *name);
-
-/**
- * This function initialize a context factory from the name specified by the parameter
- * name.
- * If the factory cannot be found, an exception is raised.
- */
- void
-
+typedef struct s_xbt_context_factory *xbt_context_factory_t;
+/* The following function pointer types describe the interface that any context
+ factory should implement */
+/* function used to create a new context */
+typedef xbt_context_t (*xbt_pfn_context_factory_create_context_t)
+ (const char *, xbt_main_func_t, void_f_pvoid_t, void *, void_f_pvoid_t, void *, int, char **);
+/* function used to create the context for the maestro process */
+typedef int (*xbt_pfn_context_factory_create_maestro_context_t) (xbt_context_t*);
+/* this function finalize the specified context factory */
+typedef int (*xbt_pfn_context_factory_finalize_t) (xbt_context_factory_t*);
+
+/* interface of the context factories */
+typedef struct s_xbt_context_factory {
+ xbt_pfn_context_factory_create_maestro_context_t create_maestro_context;
+ xbt_pfn_context_factory_create_context_t create_context;
+ xbt_pfn_context_factory_finalize_t finalize;
+ const char *name;
+} s_xbt_context_factory_t;
+
+/* Selects a context factory associated with the name specified by the parameter name.
+ * If successful the function returns 0. Otherwise the function returns the error code.
+ */
+int xbt_context_select_factory(const char *name);
-
- xbt_context_init_factory_by_name(xbt_context_factory_t * factory,
- const char *name);
-
+/* Initializes a context factory from the name specified by the parameter name.
+ * If the factory cannot be found, an exception is raised.
+ */
+void xbt_context_init_factory_by_name(xbt_context_factory_t * factory, const char *name);
/* All factories init */
- void xbt_ctx_thread_factory_init(xbt_context_factory_t * factory);
-
- void xbt_ctx_sysv_factory_init(xbt_context_factory_t * factory);
-
- void xbt_ctx_java_factory_init(xbt_context_factory_t * factory);
-
-
+void xbt_ctx_thread_factory_init(xbt_context_factory_t * factory);
+void xbt_ctx_sysv_factory_init(xbt_context_factory_t * factory);
+void xbt_ctx_java_factory_init(xbt_context_factory_t * factory);
SG_END_DECL()
-#endif /* !_XBT_CONTEXT_PRIVATE_H */
+#endif /* !_XBT_CONTEXT_PRIVATE_H */
\ No newline at end of file
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/ex_interface.h"
-#include "xbt/xbt_context_private.h"
+#include "xbt_context_private.h"
#include "context_sysv_config.h" /* loads context system definitions */
#include "portable.h"
#endif
-#ifndef HAVE_JAVA
+/*#ifndef HAVE_JAVA
#include "xbt/xbt_context_private.h"
void xbt_ctx_java_factory_init(xbt_context_factory_t * factory)
{
}
-#endif
+#endif*/
gras_datadesc_datadesc_usage_SOURCES= gras/datadesc/datadesc_usage.c gras/datadesc/datadesc_structs.c
gras_datadesc_datadesc_usage_LDADD= $(LDADD_RL)
-gras/datadesc/datadesc_structs.c: gras/datadesc/mk_datadesc_structs.pl
+gras/datadesc/datadesc_structs.c: gras/datadesc/mk_datadesc_structs.pl; \
perl $(top_srcdir)/teshsuite/gras/datadesc/mk_datadesc_structs.pl > $@
## Ensures the gras_msg_handle semantic ##
##########################################
EXTRA_DIST += gras/msg_handle/msg_handle.xml \
gras/msg_handle/test_rl \
- gras/msg_handle/test_sg_32 gras/msg_handle/test_sg_64
+ gras/msg_handle/test_sg_32 gras/msg_handle/test_sg_64
noinst_PROGRAMS+=\
gras/msg_handle/msg_handle_client \
gras/msg_handle/msg_handle_server \
gras_msg_handle_msg_handle_client_LDADD= $(LDADD_RL)
gras_msg_handle_msg_handle_server_LDADD= $(LDADD_RL)
-gras/msg_handle/_msg_handle_simulator.c gras/msg_handle/_msg_handle_client.c gras/msg_handle/_msg_handle_server.c : gras/msg_handle/msg_handle.c gras/msg_handle/msg_handle.xml $(top_builddir)/tools/gras/gras_stub_generator@EXEEXT@
+gras/msg_handle/_msg_handle_simulator.c gras/msg_handle/_msg_handle_client.c gras/msg_handle/_msg_handle_server.c : gras/msg_handle/msg_handle.c gras/msg_handle/msg_handle.xml $(top_builddir)/tools/gras/gras_stub_generator@EXEEXT@; \
mkdir -p gras/msg_handle; \
cd gras/msg_handle;\
$(abs_top_builddir)/tools/gras/gras_stub_generator@EXEEXT@ msg_handle $(abs_top_srcdir)/teshsuite/gras/msg_handle/msg_handle.xml
gras_empty_main_empty_main_simulator_LDADD= $(LDADD_SG)
gras_empty_main_empty_main_function_LDADD= $(LDADD_RL)
-gras/empty_main/_empty_main_simulator.c gras/empty_main/_empty_main_function.c : gras/empty_main/empty_main.c gras/empty_main/empty_main.xml $(top_builddir)/tools/gras/gras_stub_generator@EXEEXT@
+gras/empty_main/_empty_main_simulator.c gras/empty_main/_empty_main_function.c : gras/empty_main/empty_main.c gras/empty_main/empty_main.xml $(top_builddir)/tools/gras/gras_stub_generator@EXEEXT@ ; \
mkdir -p gras/empty_main; \
cd gras/empty_main;\
$(abs_top_builddir)/tools/gras/gras_stub_generator@EXEEXT@ empty_main $(abs_top_srcdir)/teshsuite/gras/empty_main/empty_main.xml
gras_small_sleep_small_sleep_simulator_LDADD= $(LDADD_SG)
gras_small_sleep_small_sleep_function_LDADD= $(LDADD_RL)
-gras/small_sleep/_small_sleep_simulator.c gras/small_sleep/_small_sleep_function.c : gras/small_sleep/small_sleep.c gras/small_sleep/small_sleep.xml $(top_builddir)/tools/gras/gras_stub_generator@EXEEXT@
+gras/small_sleep/_small_sleep_simulator.c gras/small_sleep/_small_sleep_function.c : gras/small_sleep/small_sleep.c gras/small_sleep/small_sleep.xml $(top_builddir)/tools/gras/gras_stub_generator@EXEEXT@; \
mkdir -p gras/small_sleep; \
cd gras/small_sleep;\
$(abs_top_builddir)/tools/gras/gras_stub_generator@EXEEXT@ small_sleep $(abs_top_srcdir)/teshsuite/gras/small_sleep/small_sleep.xml