* @ingroup msg_synchro
* @hideinitializer
*/
+
+#define MSG_BARRIER_SERIAL_PROCESS -1
typedef struct s_xbt_bar *msg_bar_t;
XBT_PUBLIC(msg_bar_t) MSG_barrier_init( unsigned int count);
XBT_PUBLIC(void) MSG_barrier_destroy(msg_bar_t bar);
-XBT_PUBLIC(void) MSG_barrier_wait(msg_bar_t bar);
+XBT_PUBLIC(int) MSG_barrier_wait(msg_bar_t bar);
/** @brief Opaque type describing a Virtual Machine.
* @ingroup msg_VMs
XBT_PUBLIC(void) xbt_cond_destroy(xbt_cond_t cond);
+#define XBT_BARRIER_SERIAL_PROCESS -1
typedef struct s_xbt_bar_ *xbt_bar_t;
XBT_PUBLIC(xbt_bar_t) xbt_barrier_init( unsigned int count);
XBT_PUBLIC(void) xbt_barrier_destroy(xbt_bar_t bar);
-XBT_PUBLIC(void) xbt_barrier_wait(xbt_bar_t bar);
+XBT_PUBLIC(int) xbt_barrier_wait(xbt_bar_t bar);
/** @} */
}
/** @brief Performs a barrier already initialized */
-void MSG_barrier_wait(msg_bar_t bar) {
- xbt_barrier_wait((xbt_bar_t)bar);
+int MSG_barrier_wait(msg_bar_t bar) {
+ if(xbt_barrier_wait((xbt_bar_t)bar) == XBT_BARRIER_SERIAL_PROCESS)
+ return MSG_BARRIER_SERIAL_PROCESS;
+ else
+ return 0;
}
/**@}*/
}
-void xbt_barrier_wait(xbt_bar_t bar)
+int xbt_barrier_wait(xbt_bar_t bar)
{
+ int ret=0;
xbt_mutex_acquire(bar->mutex);
if (++bar->arrived_processes == bar->expected_processes) {
xbt_cond_broadcast(bar->cond);
xbt_mutex_release(bar->mutex);
+ ret=XBT_BARRIER_SERIAL_PROCESS;
+ bar->arrived_processes = 0;
} else {
xbt_cond_wait(bar->cond, bar->mutex);
xbt_mutex_release(bar->mutex);
}
+
+ return ret;
}
void xbt_barrier_destroy(xbt_bar_t bar)