xbt/set.c \
xbt/xbt_matrix.c \
\
- xbt/queue.c \
+ xbt/xbt_queue.c \
\
xbt/xbt_peer.c \
\
xbt_log_layout_simple.lo xbt_log_layout_format.lo \
mallocator.lo dynar.lo dict.lo dict_elm.lo dict_cursor.lo \
dict_multi.lo heap.lo fifo.lo swag.lo graph.lo set.lo \
- xbt_matrix.lo queue.lo xbt_peer.lo xbt_main.lo config.lo \
+ xbt_matrix.lo xbt_queue.lo xbt_peer.lo xbt_main.lo config.lo \
cunit.lo graphxml_parse.lo
am__objects_2 = gras.lo transport.lo gras_msg_mod.lo gras_msg_types.lo \
gras_msg_exchange.lo rpc.lo timer.lo process.lo gras_module.lo \
xbt/xbt_log_layout_format.c xbt/mallocator.c xbt/dynar.c \
xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c xbt/dict_multi.c \
xbt/heap.c xbt/fifo.c xbt/swag.c xbt/graph.c xbt/set.c \
- xbt/xbt_matrix.c xbt/queue.c xbt/xbt_peer.c xbt/xbt_main.c \
+ xbt/xbt_matrix.c xbt/xbt_queue.c xbt/xbt_peer.c xbt/xbt_main.c \
xbt/config.c xbt/cunit.c xbt/graphxml_parse.c surf/maxmin.c \
surf/lagrange.c surf/trace_mgr.c surf/surf.c \
surf/surfxml_parse.c surf/cpu.c surf/network.c \
xbt/xbt_log_layout_format.c xbt/mallocator.c xbt/dynar.c \
xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c xbt/dict_multi.c \
xbt/heap.c xbt/fifo.c xbt/swag.c xbt/graph.c xbt/set.c \
- xbt/xbt_matrix.c xbt/queue.c xbt/xbt_peer.c xbt/xbt_main.c \
+ xbt/xbt_matrix.c xbt/xbt_queue.c xbt/xbt_peer.c xbt/xbt_main.c \
xbt/config.c xbt/cunit.c xbt/graphxml_parse.c surf/maxmin.c \
surf/lagrange.c surf/trace_mgr.c surf/surf.c \
surf/surfxml_parse.c surf/cpu.c surf/network.c \
xbt/set.c \
xbt/xbt_matrix.c \
\
- xbt/queue.c \
+ xbt/xbt_queue.c \
\
xbt/xbt_peer.c \
\
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network_gtnets.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peermanagement.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queue.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rl_dns.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rl_emul.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rl_msg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_os_thread.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_os_time.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_peer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_queue.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_rl_synchro.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_sg_synchro.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_str.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbt_matrix.lo `test -f 'xbt/xbt_matrix.c' || echo '$(srcdir)/'`xbt/xbt_matrix.c
-queue.lo: xbt/queue.c
-@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT queue.lo -MD -MP -MF $(DEPDIR)/queue.Tpo -c -o queue.lo `test -f 'xbt/queue.c' || echo '$(srcdir)/'`xbt/queue.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/queue.Tpo $(DEPDIR)/queue.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbt/queue.c' object='queue.lo' libtool=yes @AMDEPBACKSLASH@
+xbt_queue.lo: xbt/xbt_queue.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbt_queue.lo -MD -MP -MF $(DEPDIR)/xbt_queue.Tpo -c -o xbt_queue.lo `test -f 'xbt/xbt_queue.c' || echo '$(srcdir)/'`xbt/xbt_queue.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbt_queue.Tpo $(DEPDIR)/xbt_queue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbt/xbt_queue.c' object='xbt_queue.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o queue.lo `test -f 'xbt/queue.c' || echo '$(srcdir)/'`xbt/queue.c
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbt_queue.lo `test -f 'xbt/xbt_queue.c' || echo '$(srcdir)/'`xbt/xbt_queue.c
xbt_peer.lo: xbt/xbt_peer.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbt_peer.lo -MD -MP -MF $(DEPDIR)/xbt_peer.Tpo -c -o xbt_peer.lo `test -f 'xbt/xbt_peer.c' || echo '$(srcdir)/'`xbt/xbt_peer.c
XBT_PUBLIC(xbt_os_cond_t) xbt_os_cond_init(void);
XBT_PUBLIC(void) xbt_os_cond_wait(xbt_os_cond_t cond,
xbt_os_mutex_t mutex);
+ XBT_PUBLIC(void) xbt_os_cond_timedwait(xbt_os_cond_t cond,
+ xbt_os_mutex_t mutex,
+ double delay);
XBT_PUBLIC(void) xbt_os_cond_signal(xbt_os_cond_t cond);
XBT_PUBLIC(void) xbt_os_cond_broadcast(xbt_os_cond_t cond);
XBT_PUBLIC(void) xbt_os_cond_destroy(xbt_os_cond_t cond);
#include "xbt/sysdep.h"
#include "xbt/ex.h"
#include "portable.h"
+#include "xbt/xbt_os_time.h" /* Portable time facilities */
#include "xbt/xbt_os_thread.h" /* This module */
#include "xbt_modinter.h" /* Initialization/finalization of this module */
cond,mutex, strerror(errcode));
}
+#include <time.h>
+#include <math.h>
+void xbt_os_cond_timedwait(xbt_os_cond_t cond, xbt_os_mutex_t mutex, double delay) {
+ int errcode;
+ struct timespec ts_end;
+ double end = delay + xbt_os_time();
+ ts_end.tv_sec = (time_t) floor(end);
+ ts_end.tv_nsec = (long) ( ( end - ts_end.tv_sec) * 1000000000);
+ switch ( (errcode=pthread_cond_timedwait(&(cond->c),&(mutex->m), &ts_end)) ) {
+ case ETIMEDOUT:
+ THROW3(timeout_error,errcode,"condition %p (mutex %p) wasn't signaled before timeout (%f)",
+ cond,mutex, delay);
+ default:
+ THROW4(system_error,errcode,"pthread_cond_timedwait(%p,%p,%f) failed: %s",
+ cond,mutex, delay, strerror(errcode));
+ }
+}
+
void xbt_os_cond_signal(xbt_os_cond_t cond) {
int errcode;
if ((errcode=pthread_cond_signal(&(cond->c))))
/* relock the mutex associated with the condition in accordance with the posix thread specification */
EnterCriticalSection (& mutex->lock);
}
+void xbt_os_cond_timedwait(xbt_os_cond_t cond, xbt_os_mutex_t mutex, double delay) {
+ THROW_UNIMPLEMENTED;
+}
void xbt_os_cond_signal(xbt_os_cond_t cond) {
int have_waiters;
xbt_dynar_shift(queue->data,dst);
xbt_cond_signal(queue->not_full);
}
+
+
+
+
+/** @brief Push something to the message exchange queue, with a timeout.
+ *
+ * @seealso #xbt_queue_push
+ */
+void xbt_queue_push_timed(xbt_queue_t queue, const void *src,double delay) {
+ xbt_mutex_lock(queue->mutex);
+ while (queue->capacity != 0 && queue->capacity == xbt_dynar_length(queue->data)) {
+ DEBUG2("Capacity of %p exceded (=%d). Waiting",queue,queue->capacity);
+ xbt_cond_timedwait(queue->not_full,queue->mutex, delay);
+ }
+ xbt_dynar_push(queue->data,src);
+ xbt_cond_signal(queue->not_empty);
+}
+
+
+/** @brief Pop something from the message exchange queue, with a timeout.
+ *
+ * @seealso #xbt_queue_pop
+ *
+ */
+void xbt_queue_pop_timed(xbt_queue_t queue, void* const dst,double delay) {
+ xbt_mutex_lock(queue->mutex);
+ while (xbt_dynar_length(queue->data) == 0) {
+ DEBUG1("Queue %p empty. Waiting",queue);
+ xbt_cond_timedwait(queue->not_empty,queue->mutex,delay);
+ }
+ xbt_dynar_pop(queue->data,dst);
+ xbt_cond_signal(queue->not_full);
+}
+
+/** @brief Unshift something to the message exchange queue, with a timeout.
+ *
+ * @seealso #xbt_queue_unshift
+ */
+void xbt_queue_unshift_timed(xbt_queue_t queue, const void *src,double delay) {
+ xbt_mutex_lock(queue->mutex);
+ while (queue->capacity != 0 && queue->capacity == xbt_dynar_length(queue->data)) {
+ DEBUG2("Capacity of %p exceded (=%d). Waiting",queue,queue->capacity);
+ xbt_cond_timedwait(queue->not_full,queue->mutex,delay);
+ }
+ xbt_dynar_unshift(queue->data,src);
+ xbt_cond_signal(queue->not_empty);
+}
+
+
+/** @brief Shift something from the message exchange queue, with a timeout.
+ *
+ * @seealso #xbt_queue_shift
+ *
+ */
+void xbt_queue_shift_timed(xbt_queue_t queue, void* const dst,double delay) {
+ xbt_mutex_lock(queue->mutex);
+ while (xbt_dynar_length(queue->data) == 0) {
+ DEBUG1("Queue %p empty. Waiting",queue);
+ xbt_cond_timedwait(queue->not_empty,queue->mutex,delay);
+ }
+ xbt_dynar_shift(queue->data,dst);
+ xbt_cond_signal(queue->not_full);
+}
xbt_os_cond_wait( (xbt_os_cond_t)cond, (xbt_os_mutex_t)mutex );
}
+void xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay) {
+ xbt_os_cond_timedwait( (xbt_os_cond_t)cond, (xbt_os_mutex_t)mutex, delay );
+}
+
void xbt_cond_signal(xbt_cond_t cond) {
xbt_os_cond_signal( (xbt_os_cond_t)cond );
}
SIMIX_cond_wait( (smx_cond_t)cond , (smx_mutex_t)mutex );
}
+void xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay) {
+ SIMIX_cond_wait_timeout( (smx_cond_t)cond , (smx_mutex_t)mutex, delay );
+}
+
void xbt_cond_signal(xbt_cond_t cond) {
SIMIX_cond_signal( (smx_cond_t)cond );
}