typedef int(*smx_process_code_t)(int argc,char *argv[]) ;
/** @} */
-
-/* ***************************** Error handling ***************************** */
-/** @brief Error handling
- @ingroup m_datatypes_management
- @{
-*/
-typedef enum {
- SIMIX_OK = 0, /**< @brief Everything is right. Keep on going this way ! */
- SIMIX_WARNING, /**< @brief Mmmh! Something must be not perfectly clean. But I
- may be a paranoid freak... ! */
- SIMIX_TRANSFER_FAILURE, /**< @brief There has been a problem during you action
- transfer. Either the network is down or the remote host has been
- shutdown. */
- SIMIX_HOST_FAILURE, /**< @brief System shutdown. The host on which you are
- running has just been rebooted. Free your datastructures and
- return now !*/
- SIMIX_ACTION_CANCELLED, /**< @brief Cancelled action. This action has been cancelled
- by somebody!*/
- SIMIX_FATAL /**< @brief You've done something wrong. You'd better look at it... */
-} SIMIX_error_t;
-/** @} */
-
SG_END_DECL()
#endif
XBT_PUBLIC(void) SIMIX_config(const char *name, ...);
XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
XBT_PUBLIC(void) SIMIX_global_init_args(int *argc, char **argv);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_main(void);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_clean(void);
+XBT_PUBLIC(void) SIMIX_main(void);
+XBT_PUBLIC(void) SIMIX_clean(void);
XBT_PUBLIC(void) SIMIX_function_register(const char *name, smx_process_code_t code);
XBT_PUBLIC(smx_process_code_t) SIMIX_get_registered_function(const char *name);
// SIMIX_deploy_application???
/************************** Host handling ***********************************/
//pointer to above layer
-XBT_PUBLIC(SIMIX_error_t) SIMIX_host_set_data(smx_host_t host, void *data);
+XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
XBT_PUBLIC(const char *) SIMIX_host_get_name(smx_host_t host);
XBT_PUBLIC(void) SIMIX_process_kill(smx_process_t process);
XBT_PUBLIC(void) SIMIX_process_killall(void);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_change_host(smx_process_t process, smx_host_t host);
+XBT_PUBLIC(void) SIMIX_process_change_host(smx_process_t process, smx_host_t host);
//above layer
XBT_PUBLIC(void*) SIMIX_process_get_data(smx_process_t process);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_set_data(smx_process_t process, void *data);
+XBT_PUBLIC(void) SIMIX_process_set_data(smx_process_t process, void *data);
XBT_PUBLIC(smx_host_t) SIMIX_process_get_host(smx_process_t process);
XBT_PUBLIC(const char *)SIMIX_process_get_name(smx_process_t process);
XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_suspend(smx_process_t process);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_resume(smx_process_t process);
+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(SIMIX_error_t) SIMIX_process_sleep(double nb_sec);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_get_errno(void);
+XBT_PUBLIC(void) SIMIX_process_sleep(double nb_sec);
+//XBT_PUBLIC(void) SIMIX_get_errno(void);
+
/************************** Synchro handling **********************************/
XBT_PUBLIC(void) SIMIX_mutex_lock(smx_mutex_t mutex);
XBT_PUBLIC(int) SIMIX_mutex_trylock(smx_mutex_t mutex);
XBT_PUBLIC(void) SIMIX_mutex_unlock(smx_mutex_t mutex);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_mutex_destroy(smx_mutex_t mutex);
+XBT_PUBLIC(void) SIMIX_mutex_destroy(smx_mutex_t mutex);
/*****Conditional*****/
XBT_PUBLIC(smx_cond_t) SIMIX_cond_init(void);
XBT_PUBLIC(void) SIMIX_cond_wait(smx_cond_t cond,smx_mutex_t mutex);
XBT_PUBLIC(void) SIMIX_cond_wait_timeout(smx_cond_t cond,smx_mutex_t mutex, double max_duration);
XBT_PUBLIC(void) SIMIX_cond_broadcast(smx_cond_t cond);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_cond_destroy(smx_cond_t cond);
+XBT_PUBLIC(void) SIMIX_cond_destroy(smx_cond_t cond);
/************************** Action handling ************************************/
XBT_PUBLIC(smx_action_t) SIMIX_communicate(smx_host_t sender,smx_host_t receiver, char *name, double size, double rate);
XBT_PUBLIC(smx_action_t) SIMIX_execute(smx_host_t host,char *name, double amount);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_action_cancel(smx_action_t action);
+XBT_PUBLIC(void) SIMIX_action_cancel(smx_action_t action);
XBT_PUBLIC(void) SIMIX_action_set_priority(smx_action_t action, double priority);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_action_destroy(smx_action_t action);
+XBT_PUBLIC(void) SIMIX_action_destroy(smx_action_t action);
XBT_PUBLIC(void) SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond);
XBT_PUBLIC(void) SIMIX_register_condition_to_action(smx_action_t action, smx_cond_t cond);
#include "simix/simix.h"
#include "surf/surf.h"
#include "xbt/fifo.h"
-#include "xbt/dynar.h"
#include "xbt/swag.h"
#include "xbt/dict.h"
#include "xbt/context.h"
smx_action_t block_action; /* action that block the process when it does a mutex_lock or cond_wait */
int argc; /* arguments number if any */
char **argv; /* arguments table if any */
- SIMIX_error_t last_errno; /* the last value returned by a MSG_function */
+// SIMIX_error_t last_errno; /* the last value returned by a MSG_function */
// int paje_state; /* the number of states stacked with Paje */
} s_simdata_process_t;
surf_action_t surf_action; /* SURF modeling of computation */
xbt_fifo_t cond_list; /* conditional variables that must be signaled when the action finish. */
- smx_host_t source;
-/*
- double priority;
- double rate;
-*/
- /*int using;*/
-
- /******* Parallel Tasks Only !!!! *******/
- /*
- int host_nb;
- void * *host_list; *//* SURF modeling */
- /*
- double *comp_amount;
- double *comm_amount;
- */
+ smx_host_t source;
+
+/* control needed when the action blocks a process(__SIMIX_process_block). For each process that is blocked a new action is created, the process is stocked in cond_process variable and the "boolean" action_block is marked to 1 */
+ int action_block; /* simix control variable, system action or not */
+ smx_process_t cond_process; /* system process will wake up */
+ smx_cond_t timeout_cond; /* useful to remove the process from the sleeping list when a timeout occurs */
+
} s_simdata_action_t;
-#define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
-#define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
-#define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
+//#define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
+//#define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
+//#define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
/* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
#define CHECK_HOST() xbt_assert0(surf_workstation_resource->extension_public-> \
void __SIMIX_host_destroy(smx_host_t host);
int __SIMIX_process_block(double max_duration);
-SIMIX_error_t __SIMIX_process_unblock(smx_process_t process);
+void __SIMIX_process_unblock(smx_process_t process);
int __SIMIX_process_isBlocked(smx_process_t process);
void __SIMIX_display_process_status(void);
-SIMIX_error_t __SIMIX_wait_for_action(smx_process_t process, smx_action_t action);
+void __SIMIX_wait_for_action(smx_process_t process, smx_action_t action);
/*
simdata->cond_list = xbt_fifo_new();
/* initialize them */
- act-> name = xbt_strdup(name);
-
+ act->name = xbt_strdup(name);
+ simdata->action_block=0;
+ simdata->cond_process=NULL;
+ simdata->timeout_cond = NULL;
simdata->surf_action = surf_workstation_resource->extension_public->
/* initialize them */
simdata->source = host;
act-> name = xbt_strdup(name);
+ simdata->action_block=0;
+ simdata->cond_process=NULL;
+ simdata->timeout_cond = NULL;
/* set communication */
simdata->surf_action = surf_workstation_resource->extension_public->
return act;
}
-SIMIX_error_t SIMIX_action_cancel(smx_action_t action)
+void SIMIX_action_cancel(smx_action_t action)
{
xbt_assert0((action != NULL), "Invalid parameter");
if(action->simdata->surf_action) {
surf_workstation_resource->common_public->action_cancel(action->simdata->surf_action);
- return SIMIX_OK;
}
- return SIMIX_FATAL;
+ return;
}
void SIMIX_action_set_priority(smx_action_t action, double priority)
return;
}
-SIMIX_error_t SIMIX_action_destroy(smx_action_t action)
+void SIMIX_action_destroy(smx_action_t action)
{
xbt_assert0((action != NULL), "Invalid parameter");
- xbt_assert0((xbt_fifo_size(action->simdata->cond_list)==0),
- "Conditional list not empty. There is a problem. Cannot destroy it now!");
+ xbt_assert1((xbt_fifo_size(action->simdata->cond_list)==0),
+ "Conditional list not empty %d. There is a problem. Cannot destroy it now!", xbt_fifo_size(action->simdata->cond_list));
if(action->name) free(action->name);
if(action->simdata->surf_action)
action->simdata->surf_action->resource_type->common_public->action_free(action->simdata->surf_action);
- return SIMIX_OK;
+ return;
}
void SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond)
xbt_fifo_push(cond->actions,action);
}
-SIMIX_error_t __SIMIX_wait_for_action(smx_process_t process, smx_action_t action)
+void __SIMIX_wait_for_action(smx_process_t process, smx_action_t action)
{
e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
simdata_action_t simdata = action->simdata;
if(state == SURF_ACTION_DONE) {
if(surf_workstation_resource->common_public->action_free(simdata->surf_action))
simdata->surf_action = NULL;
- SIMIX_RETURN(SIMIX_OK);
} else if(surf_workstation_resource->extension_public->
get_state(SIMIX_process_get_host(process)->simdata->host)
== SURF_CPU_OFF) {
if(surf_workstation_resource->common_public->action_free(simdata->surf_action))
simdata->surf_action = NULL;
- SIMIX_RETURN(SIMIX_HOST_FAILURE);
} else {
if(surf_workstation_resource->common_public->action_free(simdata->surf_action))
simdata->surf_action = NULL;
- SIMIX_RETURN(SIMIX_ACTION_CANCELLED);
}
+ return;
}
xbt_context_init();
simix_global->host = xbt_fifo_new();
- simix_global->process_to_run = xbt_swag_new(xbt_swag_offset(proc,process_hookup));
+ simix_global->process_to_run = xbt_swag_new(xbt_swag_offset(proc,synchro_hookup));
simix_global->process_list = xbt_swag_new(xbt_swag_offset(proc,process_hookup));
simix_global->current_process = NULL;
simix_global->registered_functions = xbt_dict_new();
/** \ingroup msg_simulation
* \brief Launch the SIMIX simulation
*/
-SIMIX_error_t SIMIX_main(void)
+void SIMIX_main(void)
{
smx_process_t process = NULL;
smx_cond_t cond = NULL;
xbt_fifo_item_t _cursor;
DEBUG1("** %s failed **",smx_action->name);
- xbt_fifo_foreach(smx_action->simdata->cond_list,_cursor,cond,smx_cond_t) {
- SIMIX_cond_broadcast(cond);
- xbt_swag_foreach(process,cond->sleeping) {
- DEBUG2("\t preparing to wake up %s on %s",
- process->name, process->simdata->host->name);
+ /* put all the process that are waiting in a conditional (dummy action) on the process_to_run list */
+ if ( smx_action->simdata->action_block) {
+ xbt_swag_insert(smx_action->simdata->cond_process,simix_global->process_to_run);
+ }
+ /* else, do the dummy action finish, call the signal broadcast */
+ else {
+ xbt_fifo_foreach(smx_action->simdata->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->host->name);
+ }
+ SIMIX_cond_broadcast(cond);
+ /* remove conditional from action */
+ xbt_fifo_remove(smx_action->simdata->cond_list,cond);
}
}
process=NULL;
xbt_swag_extract(resource->common_public->states.
done_action_set))) {
smx_action = action->data;
+ if (smx_action) {
+ xbt_fifo_item_t _cursor;
+
+ DEBUG1("** %s done **",smx_action->name);
+ /* put all the process that are waiting in a conditional (dummy action) on the process_to_run list */
+ if ( smx_action->simdata->action_block) {
+ if (smx_action->simdata->timeout_cond) {
+ xbt_swag_remove(smx_action->simdata->cond_process,smx_action->simdata->timeout_cond->sleeping);
+ }
+ process = smx_action->simdata->cond_process;
+ xbt_swag_insert(smx_action->simdata->cond_process,simix_global->process_to_run);
+ DEBUG2("\t preparing to wake up %s on %s",
+ process->name, process->simdata->host->name);
+ }
+ /* else, do the dummy action finish, call the signal broadcast */
+ else {
+ xbt_fifo_foreach(smx_action->simdata->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->host->name);
+ }
+ SIMIX_cond_broadcast(cond);
+ /* remove conditional from action */
+ xbt_fifo_remove(smx_action->simdata->cond_list,cond);
+ }
+ }
+ process=NULL;
+ }
+/*
if (smx_action) {
xbt_fifo_item_t _cursor;
}
}
process=NULL;
- }
+ }*/
}
}
if (xbt_swag_size(simix_global->process_list) == 0) {
INFO0("Congratulations ! Simulation terminated : all processes are over");
- return SIMIX_OK;
+ return;
} else {
INFO0("Oops ! Deadlock or code not perfectly clean.");
__SIMIX_display_process_status();
}
INFO0("Return a Warning.");
- return SIMIX_WARNING;
+ return;
}
}
/** \ingroup msg_simulation
* \brief Clean the SIMIX simulation
*/
-SIMIX_error_t SIMIX_clean(void)
+void SIMIX_clean(void)
{
xbt_fifo_item_t i = NULL;
smx_host_t h = NULL;
free(simix_global);
surf_exit();
- return SIMIX_OK;
+ return ;
}
* 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.
*/
-SIMIX_error_t SIMIX_host_set_data(smx_host_t host, void *data)
+void SIMIX_host_set_data(smx_host_t host, void *data)
{
xbt_assert0((host!=NULL), "Invalid parameters");
xbt_assert0((host->data == NULL), "Data already set");
/* Assign data */
host->data = data;
- return SIMIX_OK;
+ return ;
}
/** \ingroup m_host_management
SIMIX_process_cleanup, process,
simdata->argc, simdata->argv);
- simdata->last_errno=SIMIX_OK;
+ //simdata->last_errno=SIMIX_OK;
/* Process structure */
xbt_context_start(process->simdata->context);
simix_global->current_process = self;
- // xbt_swag_insert(process,simix_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);
* This functions checks whether \a process and \a host are valid pointers
and change the value of the #m_host_t on which \a process is running.
*/
-SIMIX_error_t SIMIX_process_change_host(smx_process_t process, smx_host_t host)
+void SIMIX_process_change_host(smx_process_t process, smx_host_t host)
{
simdata_process_t simdata = NULL;
simdata->host = host;
xbt_swag_insert(process,host->simdata->process_list);
- return SIMIX_OK;
+ return ;
}
/** \ingroup m_process_management
* This functions checks whether \a process is a valid pointer or not
and set the user data associated to \a process if it is possible.
*/
-SIMIX_error_t SIMIX_process_set_data(smx_process_t process,void *data)
+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 SIMIX_OK;
+ return ;
}
/** \ingroup m_process_management
{
xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
- return (((simdata_process_t) process->simdata)->host);
+ return (process->simdata->host);
}
/** \ingroup m_process_management
* This functions suspend the process by suspending the task on which
* it was waiting for the completion.
*/
-SIMIX_error_t SIMIX_process_suspend(smx_process_t process)
+void SIMIX_process_suspend(smx_process_t process)
{
simdata_process_t simdata = NULL;
- smx_action_t dummy;
- char name[] = "dummy";
xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
if(process!=SIMIX_process_self()) {
simdata = process->simdata;
- if ( (simdata->mutex == NULL) && (simdata->cond == NULL) ) {
- /* Ops, I don't know what to do yet. */
-
- }
- else if (simdata->mutex) {
+ if (simdata->mutex) {
/* process blocked on a mutex, only set suspend=1 */
simdata->suspended = 1;
}
else if (simdata->cond){
/* process blocked cond, suspend all actions */
-
+
/* temporaries variables */
smx_cond_t c;
xbt_fifo_item_t i;
simdata->suspended = 1;
c = simdata->cond;
xbt_fifo_foreach(c->actions,i,act, smx_action_t) {
- surf_workstation_resource->common_public->suspend(act->simdata->surf_action);
+ surf_workstation_resource->common_public->suspend(act->simdata->surf_action);
}
}
+ else if (simdata->block_action) {
+ simdata->suspended = 1;
+ }
else xbt_assert0(0, "Unknown process status");
}
else {
/* process executing, I can create an action and suspend it */
- dummy = SIMIX_execute(SIMIX_process_get_host(process)->simdata->host, name, 0);
- process->simdata->block_action = dummy;
-
process->simdata->suspended = 1;
- surf_workstation_resource->common_public->suspend(dummy->simdata->surf_action);
- __SIMIX_wait_for_action(process,dummy);
- SIMIX_action_destroy(dummy);
+ __SIMIX_process_block(-1);
process->simdata->suspended = 0;
}
- return SIMIX_OK;
+ return ;
}
/** \ingroup m_process_management
* This functions resume a suspended process by resuming the task on
* which it was waiting for the completion.
*/
-SIMIX_error_t SIMIX_process_resume(smx_process_t process)
+void SIMIX_process_resume(smx_process_t process)
{
simdata_process_t simdata = NULL;
CHECK_HOST();
if(process == SIMIX_process_self()) {
- SIMIX_RETURN(SIMIX_OK);
+ return;
}
simdata = process->simdata;
-
if(simdata->mutex) {
+ DEBUG0("Resume process blocked on a mutex");
simdata->suspended = 0; /* He'll wake up by itself */
- SIMIX_RETURN(SIMIX_OK);
+ return;
}
else if (simdata->cond) {
+ DEBUG0("Resume process blocked on a conditional");
/* temporaries variables */
smx_cond_t c;
xbt_fifo_item_t i;
smx_action_t act;
-
simdata->suspended = 0;
c = simdata->cond;
xbt_fifo_foreach(c->actions,i,act, smx_action_t) {
surf_workstation_resource->common_public->resume(act->simdata->surf_action);
}
- SIMIX_RETURN(SIMIX_OK);
+ return;
}
else if (simdata->block_action){
simdata->suspended = 0;
surf_workstation_resource->common_public->resume(simdata->block_action->simdata->surf_action);
- SIMIX_RETURN(SIMIX_OK);
+ return;
}
- else xbt_assert0(0, "Unknown process status");
+ else xbt_assert0(0, "Unknown status");
}
smx_action_t dummy = NULL;
char name[] = "dummy";
- dummy = SIMIX_execute(SIMIX_process_get_host(process)->simdata->host, name, 0);
- process->simdata->block_action = dummy;
+ dummy = SIMIX_execute(SIMIX_process_get_host(process), name, 0);
+ dummy->simdata->action_block=1;
+
+ /* process which will wake up when this system action finish */
+ dummy->simdata->cond_process = process;
+
+ process->simdata->block_action = dummy;
process->simdata->blocked=1;
surf_workstation_resource->common_public->suspend(dummy->simdata->surf_action);
- if(max_duration>=0)
+
+ if(max_duration>=0) {
surf_workstation_resource->common_public->set_max_duration(dummy->simdata->surf_action,
max_duration);
+ dummy->simdata->timeout_cond = process->simdata->cond;
+ }
__SIMIX_wait_for_action(process,dummy);
SIMIX_action_destroy(dummy);
process->simdata->blocked=0;
DEBUG0("I've been resumed, let's keep going");
}
-/*
- m_task_t dummy = SIMIX_TASK_UNINITIALIZED;
- char blocked_name[512];
- snprintf(blocked_name,512,"blocked [%s] (%s:%s)",
- info, process->name, process->simdata->host->name);
-
- XBT_IN1(": max_duration=%g",max_duration);
-
- dummy = MSG_task_create(blocked_name, 0.0, 0, NULL);
-
- PAJE_PROCESS_PUSH_STATE(process,"B",NULL);
-
- process->simdata->blocked=1;
- __MSG_task_execute(process,dummy);
- surf_workstation_resource->common_public->suspend(dummy->simdata->compute);
- if(max_duration>=0)
- surf_workstation_resource->common_public->set_max_duration(dummy->simdata->compute,
- max_duration);
- __MSG_wait_for_computation(process,dummy);
- MSG_task_destroy(dummy);
- process->simdata->blocked=0;
-
- if(process->simdata->suspended) {
- DEBUG0("I've been suspended in the meantime");
- SIMIX_process_suspend(process);
- DEBUG0("I've been resumed, let's keep going");
- }
-
- PAJE_PROCESS_POP_STATE(process);
-
- XBT_OUT;
- */
return 1;
}
-SIMIX_error_t __SIMIX_process_unblock(smx_process_t process)
+void __SIMIX_process_unblock(smx_process_t process)
{
simdata_process_t simdata = NULL;
simdata_action_t simdata_action = NULL;
xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
- CHECK_HOST();
- simdata = process->simdata;
+ simdata = process->simdata;
+
if(!(simdata->block_action)) {
xbt_assert0(0,"Process is not blocked !");
- return SIMIX_WARNING;
+ return;
}
- simdata_action = simdata->block_action->simdata;
+
+ simdata_action = simdata->block_action->simdata;
xbt_assert0(simdata->blocked,"Process not blocked");
surf_workstation_resource->common_public->resume(simdata_action->surf_action);
- SIMIX_RETURN(SIMIX_OK);
+ return ;
/*
simdata_process_t simdata = NULL;
return;
}
-SIMIX_error_t SIMIX_mutex_destroy(smx_mutex_t mutex)
+void SIMIX_mutex_destroy(smx_mutex_t mutex)
{
if ( mutex == NULL )
- return SIMIX_WARNING;
+ return ;
else {
xbt_swag_free(mutex->sleeping);
xbt_free(mutex);
- return SIMIX_OK;
+ return ;
}
}
/* process status */
self->simdata->cond = cond;
- xbt_swag_insert(self, cond->sleeping);
cond->mutex = mutex;
SIMIX_mutex_unlock(mutex);
- /* if the max_duration < 0, blocks forever */
+ xbt_swag_insert(self, cond->sleeping);
+ /* creates a new action to be the timeout */
if (max_duration >=0) {
__SIMIX_process_block(max_duration);
self->simdata->cond = NULL;
}
/* get the mutex again */
SIMIX_mutex_lock(cond->mutex);
+
return;
}
return;
}
-SIMIX_error_t SIMIX_cond_destroy(smx_cond_t cond)
+void SIMIX_cond_destroy(smx_cond_t cond)
{
if ( cond == NULL )
- return SIMIX_WARNING;
+ return ;
else {
- xbt_assert0( (xbt_swag_size(cond->sleeping) > 0) &&
- (xbt_fifo_size(cond->actions) > 0), "Cannot destroy conditional");
+ xbt_assert0( xbt_swag_size(cond->sleeping) == 0 , "Cannot destroy conditional");
xbt_swag_free(cond->sleeping);
xbt_fifo_free(cond->actions);
xbt_free(cond);
- return SIMIX_OK;
+ return;
}
}