void SIMIX_mutex_unlock(smx_mutex_t mutex)
{
smx_process_t p; /*process to wake up */
-
+
xbt_assert0((mutex != NULL), "Invalid parameters");
-
+
if (xbt_swag_size(mutex->sleeping) > 0) {
p = xbt_swag_extract(mutex->sleeping);
mutex->using = 0;
return;
}
+xbt_fifo_t SIMIX_cond_get_actions(smx_cond_t cond)
+{
+ xbt_assert0((cond != NULL), "Invalid parameters");
+ return cond->actions;
+}
void __SIMIX_cond_wait(smx_cond_t cond)
{
/**
* \brief Waits on a condition with timeout.
*
- * Same behavior of #SIMIX_cond_wait, but waits a maximum time.
+ * Same behavior of #SIMIX_cond_wait, but waits a maximum time and throws an timeout_error if it happens.
* \param cond A condition
* \param mutex A mutex
* \param max_duration Timeout time
act_sleep = SIMIX_action_sleep(SIMIX_host_self(), max_duration);
SIMIX_register_action_to_condition(act_sleep,cond);
SIMIX_register_condition_to_action(act_sleep,cond);
+ __SIMIX_cond_wait(cond);
+ xbt_fifo_remove(act_sleep->cond_list,cond);
+ if ( SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
+ SIMIX_action_destroy(act_sleep);
+ THROW0(timeout_error,0,"Condition timeout");
+ }
+ else {
+ SIMIX_action_destroy(act_sleep);
+ }
+
}
- __SIMIX_cond_wait(cond);
+ else
+ __SIMIX_cond_wait(cond);
/* get the mutex again */
SIMIX_mutex_lock(cond->mutex);