double finish; /**< finish time : this is modified during the run
* and fluctuates until the task is completed */
void *data; /**< for your convenience */
- int using;
+ int refcount ;
surf_model_t model_type;
} s_surf_action_t;
SIMIX_jprocess_create(process->name,
process->simdata->m_host->simdata->smx_host,
/*data*/ (void*)process,
- jprocess,env,
+ jprocess,
+ env,
&process->simdata->s_process);
CHECK_HOST();
simdata = task->simdata;
- xbt_assert0((!simdata->compute) && (task->simdata->using == 1),"This task is executed somewhere else. Go fix your code!");
+ xbt_assert0((!simdata->compute) && (task->simdata->refcount == 1),"This task is executed somewhere else. Go fix your code!");
DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
- simdata->using++;
+ simdata->refcount ++;
SIMIX_mutex_lock(simdata->mutex);
simdata->compute = SIMIX_action_execute(SIMIX_host_self(), task->name, simdata->computation_amount);
SIMIX_action_set_priority(simdata->compute, simdata->priority);
self->simdata->waiting_task = NULL;
SIMIX_mutex_unlock(simdata->mutex);
- simdata->using--;
+ simdata->refcount --;
if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE)
{
simdata->compute = NULL;
simdata->comm = NULL;
simdata->rate = -1.0;
- simdata->using = 1;
+ simdata->refcount = 1;
simdata->sender = NULL;
simdata->receiver = NULL;
simdata->source = NULL;
simdata = task->simdata;
- xbt_assert0((!simdata->compute) && (task->simdata->using == 1),"This task is executed somewhere else. Go fix your code!");
+ xbt_assert0((!simdata->compute) && (task->simdata->refcount == 1),"This task is executed somewhere else. Go fix your code!");
xbt_assert0(simdata->host_nb,"This is not a parallel task. Go to hell.");
DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
- simdata->using++;
+ simdata->refcount ++;
SIMIX_mutex_lock(simdata->mutex);
simdata->compute =
SIMIX_mutex_unlock(simdata->mutex);
- simdata->using--;
+ simdata->refcount --;
if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE)
{
*
* \return The newly created mailbox.
*/
-msg_mailbox_t MSG_mailbox_new(const char *alias);
+XBT_PUBLIC(msg_mailbox_t)
+MSG_mailbox_new(const char *alias);
/*! \brief MSG_mailbox_create - create a new mailbox.
*
*
* \return The newly created mailbox.
*/
-msg_mailbox_t MSG_mailbox_create(const char *alias);
+msg_mailbox_t
+MSG_mailbox_create(const char *alias);
/* \brief MSG_mailbox_free - release a mailbox from the memory.
*
*
* \see MSG_mailbox_destroy.
*/
-void MSG_mailbox_free(void *mailbox);
+void
+MSG_mailbox_free(void *mailbox);
/* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
*
* \return The mailbox associated with the alias specified as parameter
* or a new mailbox if the key does not match.
*/
-msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias);
+XBT_PUBLIC(msg_mailbox_t)
+MSG_mailbox_get_by_alias(const char *alias);
/* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
*
* specified as parameter.
*
*/
-msg_mailbox_t
+XBT_PUBLIC(msg_mailbox_t)
MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
/*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.
*
* \return The alias of the mailbox specified by the parameter mailbox.
*/
-const char *MSG_mailbox_get_alias(msg_mailbox_t mailbox);
+XBT_PUBLIC(const char *)
+MSG_mailbox_get_alias(msg_mailbox_t mailbox);
/*! \brief MSG_mailbox_get_cond - get the simix condition of a mailbox.
*
*
* \return The simix condition of the mailbox specified by the parameter mailbox.
*/
-smx_cond_t MSG_mailbox_get_cond(msg_mailbox_t mailbox);
+XBT_PUBLIC(smx_cond_t)
+MSG_mailbox_get_cond(msg_mailbox_t mailbox);
/*! \brief MSG_mailbox_set_cond - set the simix condition of a mailbox.
*
* \param cond The new simix condition of the mailbox.
*
*/
-void MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond);
+XBT_PUBLIC(void)
+MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond);
/*! \brief MSG_mailbox_get_hostname - get the name of the host owned a mailbox.
*
*
* \return The name of the host owned the mailbox specified by the parameter mailbox.
*/
-const char *MSG_mailbox_get_hostname(msg_mailbox_t mailbox);
+XBT_PUBLIC(const char *)
+MSG_mailbox_get_hostname(msg_mailbox_t mailbox);
/*! \brief MSG_mailbox_set_hostname - set the name of the host owned a mailbox.
*
* \param hostname The name of the owner of the mailbox.
*
*/
-void MSG_mailbox_set_hostname(msg_mailbox_t mailbox, const char *hostname);
+XBT_PUBLIC(void)
+MSG_mailbox_set_hostname(msg_mailbox_t mailbox, const char *hostname);
/*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
* \return The function returns 1 if the mailbox is empty. Otherwise the function
* returns 0.
*/
-int MSG_mailbox_is_empty(msg_mailbox_t mailbox);
+XBT_PUBLIC(int)
+MSG_mailbox_is_empty(msg_mailbox_t mailbox);
/*! \brief MSG_mailbox_put - put a task in a mailbox.
*
* \param mailbox The mailbox where put the task.
* \param task The task to put in the mailbox.
*/
-void MSG_mailbox_put(msg_mailbox_t mailbox, m_task_t task);
+XBT_PUBLIC(void)
+MSG_mailbox_put(msg_mailbox_t mailbox, m_task_t task);
/*! \brief MSG_mailbox_remove - remove a task from a mailbox.
*
* \param mailbox The mailbox concerned by this operation.
* \param task The task to remove from the mailbox.
*/
-void MSG_mailbox_remove(msg_mailbox_t mailbox, m_task_t task);
+XBT_PUBLIC(void)
+MSG_mailbox_remove(msg_mailbox_t mailbox, m_task_t task);
/*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
*
*
* \return The task at the head of the mailbox.
*/
-m_task_t MSG_mailbox_get_head(msg_mailbox_t mailbox);
+XBT_PUBLIC(m_task_t)
+MSG_mailbox_get_head(msg_mailbox_t mailbox);
/*! \brief MSG_mailbox_pop_head - get the task at the head of a mailbox
* and remove it from it.
*
* \return The task at the head of the mailbox.
*/
-m_task_t MSG_mailbox_pop_head(msg_mailbox_t mailbox);
+XBT_PUBLIC(m_task_t)
+MSG_mailbox_pop_head(msg_mailbox_t mailbox);
/*! \brief MSG_mailbox_get_first_host_task - get the first msg task
* of a specified mailbox, sended by a process of a specified host.
* parameter mailbox and sended by a process located
* on the host specified by the parameter host.
*/
-m_task_t
+XBT_PUBLIC(m_task_t)
MSG_mailbox_get_first_host_task(msg_mailbox_t mailbox, m_host_t host);
/*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks
* parameter mailbox and sended by all the processes located
* on the host specified by the parameter host.
*/
-int
+XBT_PUBLIC(int)
MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
m_host_t host);
if (SIMIX_action_get_state(t_simdata->comm) == SURF_ACTION_DONE) {
SIMIX_action_destroy(t_simdata->comm);
t_simdata->comm = NULL;
- t_simdata->using--;
+ t_simdata->refcount --;
MSG_RETURN(MSG_OK);
} else if (SIMIX_host_get_state(h_simdata->smx_host) == 0) {
SIMIX_action_destroy(t_simdata->comm);
t_simdata->comm = NULL;
- t_simdata->using--;
+ t_simdata->refcount --;
MSG_RETURN(MSG_HOST_FAILURE);
} else {
SIMIX_action_destroy(t_simdata->comm);
t_simdata->comm = NULL;
- t_simdata->using--;
+ t_simdata->refcount --;
MSG_RETURN(MSG_TRANSFER_FAILURE);
}
}
task_simdata->sender = process;
task_simdata->source = MSG_process_get_host(process);
- xbt_assert0(task_simdata->using == 1,
+ xbt_assert0(task_simdata->refcount == 1,
"This task is still being used somewhere else. You cannot send it now. Go fix your code!");
task_simdata->comm = NULL;
- task_simdata->using++;
+ task_simdata->refcount ++;
local_host = ((simdata_process_t) process->simdata)->m_host;
/* get the host name containing the mailbox */
#include "xbt/context.h"
#include "xbt/config.h"
+SG_BEGIN_DECL()
+
/**************** datatypes **********************************/
/* this structure represents a mailbox */
m_host_t source;
double priority;
double rate;
- int using;
+ int refcount ;
/******* Parallel Tasks Only !!!! *******/
int host_nb;
smx_host_t *host_list;
int session;
} s_MSG_Global_t, *MSG_Global_t;
-extern MSG_Global_t msg_global;
+/*extern MSG_Global_t msg_global;*/
+XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
+
/*************************************************************/
char * hostname, int argc, char **argv, xbt_dict_t properties);
void _MSG_process_kill_from_SIMIX(void *p);
-
+SG_END_DECL()
#endif
simdata->message_size = message_size;
simdata->rate = -1.0;
simdata->priority = 1.0;
- simdata->using = 1;
+ simdata->refcount = 1;
simdata->sender = NULL;
simdata->receiver = NULL;
simdata->cond = SIMIX_cond_init();
xbt_assert0((task != NULL), "Invalid parameter");
/* why? if somebody is using, then you can't free! ok... but will return MSG_OK? when this task will be destroyed? isn't the user code wrong? */
- task->simdata->using--;
- if (task->simdata->using > 0)
+ task->simdata->refcount --;
+ if (task->simdata->refcount > 0)
return MSG_OK;
if (task->name)
-/* $Id: private.h 5071 2007-11-27 15:41:57Z mquinson $ */
+/* $Id$ */
/* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
All rights reserved. */
/* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
xbt_swag_t sleeping; /* list of sleeping process */
- int using;
+ int refcount ;
/* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
} s_smx_mutex_t;
smx_mutex_t m = xbt_new0(s_smx_mutex_t, 1);
s_smx_process_t p; /* useful to initialize sleeping swag */
/* structures initialization */
- m->using = 0;
+ m->refcount = 0;
m->sleeping = xbt_swag_new(xbt_swag_offset(p, synchro_hookup));
return m;
}
xbt_assert0((mutex != NULL), "Invalid parameters");
- if (mutex->using) {
+ if (mutex->refcount ) {
/* somebody using the mutex, block */
xbt_swag_insert(self, mutex->sleeping);
self->simdata->mutex = mutex;
xbt_context_yield();
}
- mutex->using = 1;
+ mutex->refcount = 1;
} else {
/* mutex free */
- mutex->using = 1;
+ mutex->refcount = 1;
}
return;
}
{
xbt_assert0((mutex != NULL), "Invalid parameters");
- if (mutex->using)
+ if (mutex->refcount )
return 0;
else {
- mutex->using = 1;
+ mutex->refcount = 1;
return 1;
}
}
if (xbt_swag_size(mutex->sleeping) > 0) {
p = xbt_swag_extract(mutex->sleeping);
- mutex->using = 0;
+ mutex->refcount = 0;
xbt_swag_insert(p, simix_global->process_to_run);
} else {
/* nobody to wake up */
- mutex->using = 0;
+ mutex->refcount = 0;
}
return;
}
static int action_free(surf_action_t action)
{
- action->using--;
- if (!action->using) {
+ action->refcount --;
+ if (!action->refcount ) {
xbt_swag_remove(action, action->state_set);
if (((surf_action_cpu_Cas01_t) action)->variable)
lmm_variable_free(cpu_maxmin_system,
static void action_use(surf_action_t action)
{
- action->using++;
+ action->refcount ++;
}
static void action_cancel(surf_action_t action)
XBT_IN2("(%s,%g)", CPU->name, size);
action = xbt_new0(s_surf_action_cpu_Cas01_t, 1);
- action->generic_action.using = 1;
+ action->generic_action.refcount = 1;
action->generic_action.cost = size;
action->generic_action.remains = size;
action->generic_action.priority = 1.0;
static int action_free(surf_action_t action)
{
- action->using--;
- if (!action->using) {
+ action->refcount --;
+ if (!action->refcount ) {
xbt_swag_remove(action, action->state_set);
if (((surf_action_network_CM02_t) action)->variable)
lmm_variable_free(network_maxmin_system,
static void action_use(surf_action_t action)
{
- action->using++;
+ action->refcount ++;
}
static void action_cancel(surf_action_t action)
action = xbt_new0(s_surf_action_network_CM02_t, 1);
- action->generic_action.using = 1;
+ action->generic_action.refcount = 1;
action->generic_action.cost = size;
action->generic_action.remains = size;
action->generic_action.max_duration = NO_MAX_DURATION;
static int action_free(surf_action_t action)
{
- action->using--;
- if (!action->using) {
+ action->refcount --;
+ if (!action->refcount ) {
xbt_swag_remove(action, action->state_set);
free(action);
return 1;
static void action_use(surf_action_t action)
{
- action->using++;
+ action->refcount ++;
}
static void action_cancel(surf_action_t action)
action = xbt_new0(s_surf_action_network_Constant_t, 1);
- action->generic_action.using = 1;
+ action->generic_action.refcount = 1;
action->generic_action.cost = size;
action->generic_action.remains = size;
action->generic_action.max_duration = NO_MAX_DURATION;
static void action_use(surf_action_t action)
{
- action->using++;
+ action->refcount ++;
return;
}
static int action_free(surf_action_t action)
{
- action->using--;
+ action->refcount --;
- if (!action->using) {
+ if (!action->refcount ) {
xbt_swag_remove(action, action->state_set);
if (((surf_action_workstation_L07_t) action)->variable)
lmm_variable_free(ptask_maxmin_system,
action = xbt_new0(s_surf_action_workstation_L07_t, 1);
DEBUG3("Creating a parallel task (%p) with %d cpus and %d links.",
action, workstation_nb, nb_link);
- action->generic_action.using = 1;
+ action->generic_action.refcount = 1;
action->generic_action.cost = amount;
action->generic_action.remains = amount;
action->generic_action.max_duration = NO_MAX_DURATION;
/* KEEP IT IN SYNC WITH src/simix/private.h::struct s_smx_mutex */
xbt_swag_t sleeping; /* list of sleeping process */
- int using;
+ int refcount ;
/* KEEP IT IN SYNC WITH src/simix/private.h::struct s_smx_mutex */
};