include/surf/surfxml_parse_private.h \
\
include/xbt/xbt_portability.h \
- include/xbt/xbt_thread.h \
+ include/xbt/xbt_os_thread.h \
include/xbt/context.h \
\
msg/private.h \
# Separated because we don't want it in libsimgrid4java
CTX_SRC= xbt/context.c
-JCTX_SRC= java/jxbt_context.c java/jxbt_context.h xbt/xbt_thread.c
+JCTX_SRC= java/jxbt_context.c java/jxbt_context.h xbt/xbt_os_thread.c
SIMIX_SRC= \
simix/smx_global.c \
gras/DataDesc/ddt_parse.c gras/DataDesc/ddt_parse.yy.c gras/DataDesc/ddt_parse.yy.h
GRAS_RL_SRC= \
- gras/rl_stubs.c xbt/xbt_thread.c \
+ gras/rl_stubs.c xbt/xbt_os_thread.c \
\
gras/Transport/rl_transport.c \
gras/Transport/transport_plugin_file.c gras/Transport/transport_plugin_tcp.c \
gras/Virtu/sg_process.c gras/Virtu/sg_time.c \
gras/Virtu/sg_dns.c\
\
- gras/sg_stubs.c \
gras/Msg/sg_msg.c
AMOK_SRC= \
am__objects_2 = gras.lo transport.lo msg.lo rpc.lo timer.lo process.lo \
gras_module.lo ddt_create.lo ddt_convert.lo ddt_exchange.lo \
cbps.lo datadesc.lo ddt_parse.lo ddt_parse.yy.lo
-am__objects_3 = rl_stubs.lo xbt_thread.lo rl_transport.lo \
+am__objects_3 = rl_stubs.lo xbt_os_thread.lo rl_transport.lo \
transport_plugin_file.lo transport_plugin_tcp.lo rl_emul.lo \
rl_process.lo rl_time.lo rl_dns.lo rl_msg.lo
am__objects_4 = amok_base.lo bandwidth.lo saturate.lo \
gras/Transport/sg_transport.c \
gras/Transport/transport_plugin_sg.c gras/Virtu/sg_emul.c \
gras/Virtu/sg_process.c gras/Virtu/sg_time.c \
- gras/Virtu/sg_dns.c gras/sg_stubs.c gras/Msg/sg_msg.c \
- amok/amok_base.c amok/Bandwidth/bandwidth.c \
- amok/Bandwidth/saturate.c amok/PeerManagement/peermanagement.c
+ gras/Virtu/sg_dns.c gras/Msg/sg_msg.c amok/amok_base.c \
+ amok/Bandwidth/bandwidth.c amok/Bandwidth/saturate.c \
+ amok/PeerManagement/peermanagement.c
am__objects_5 = maxmin.lo lagrange.lo trace_mgr.lo surf.lo \
surfxml_parse.lo cpu.lo network.lo workstation.lo \
surf_timer.lo network_dassf.lo workstation_KCCFLN05.lo
global.lo environment.lo deployment.lo
am__objects_12 = sd_global.lo sd_link.lo sd_task.lo sd_workstation.lo
am__objects_13 = sg_transport.lo transport_plugin_sg.lo sg_emul.lo \
- sg_process.lo sg_time.lo sg_dns.lo sg_stubs.lo sg_msg.lo
+ sg_process.lo sg_time.lo sg_dns.lo sg_msg.lo
am_libsimgrid_la_OBJECTS = $(am__objects_1) $(am__objects_5) \
$(am__objects_7) $(am__objects_8) $(am__objects_9) \
$(am__objects_10) $(am__objects_11) $(am__objects_12) \
surf/sdp.c simix/smx_global.c simix/smx_deployment.c \
simix/smx_config.c simix/smx_environment.c simix/smx_host.c \
simix/smx_process.c simix/smx_action.c simix/smx_synchro.c \
- java/jxbt_context.c java/jxbt_context.h xbt/xbt_thread.c \
+ java/jxbt_context.c java/jxbt_context.h xbt/xbt_os_thread.c \
java/jxbt_utilities.c java/jxbt_utilities.h java/jmsg.c \
java/jmsg.h java/jmsg_channel.c java/jmsg_channel.h \
java/jmsg_host.c java/jmsg_host.h java/jmsg_parallel_task.c \
gras/Transport/sg_transport.c \
gras/Transport/transport_plugin_sg.c gras/Virtu/sg_emul.c \
gras/Virtu/sg_process.c gras/Virtu/sg_time.c \
- gras/Virtu/sg_dns.c gras/sg_stubs.c gras/Msg/sg_msg.c \
- amok/amok_base.c amok/Bandwidth/bandwidth.c \
- amok/Bandwidth/saturate.c amok/PeerManagement/peermanagement.c
-am__objects_14 = jxbt_context.lo xbt_thread.lo
+ gras/Virtu/sg_dns.c gras/Msg/sg_msg.c amok/amok_base.c \
+ amok/Bandwidth/bandwidth.c amok/Bandwidth/saturate.c \
+ amok/PeerManagement/peermanagement.c
+am__objects_14 = jxbt_context.lo xbt_os_thread.lo
am__objects_15 = jxbt_utilities.lo jmsg.lo jmsg_channel.lo \
jmsg_host.lo jmsg_parallel_task.lo jmsg_process.lo \
jmsg_task.lo
surf/workstation_KCCFLN05_private.h include/surf/maxmin.h \
include/surf/trace_mgr.h include/surf/surf.h \
include/surf/surfxml_parse_private.h \
- include/xbt/xbt_portability.h include/xbt/xbt_thread.h \
+ include/xbt/xbt_portability.h include/xbt/xbt_os_thread.h \
include/xbt/context.h msg/private.h simdag/private.h \
amok/Bandwidth/bandwidth_private.h amok/amok_modinter.h \
$(am__append_1) $(am__append_2) $(am__append_4) \
# Separated because we don't want it in libsimgrid4java
CTX_SRC = xbt/context.c
-JCTX_SRC = java/jxbt_context.c java/jxbt_context.h xbt/xbt_thread.c
+JCTX_SRC = java/jxbt_context.c java/jxbt_context.h xbt/xbt_os_thread.c
SIMIX_SRC = \
simix/smx_global.c \
simix/smx_deployment.c \
gras/DataDesc/ddt_parse.c gras/DataDesc/ddt_parse.yy.c gras/DataDesc/ddt_parse.yy.h
GRAS_RL_SRC = \
- gras/rl_stubs.c xbt/xbt_thread.c \
+ gras/rl_stubs.c xbt/xbt_os_thread.c \
\
gras/Transport/rl_transport.c \
gras/Transport/transport_plugin_file.c gras/Transport/transport_plugin_tcp.c \
gras/Virtu/sg_process.c gras/Virtu/sg_time.c \
gras/Virtu/sg_dns.c\
\
- gras/sg_stubs.c \
gras/Msg/sg_msg.c
AMOK_SRC = \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_emul.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_msg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_process.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_stubs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_time.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sg_transport.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simgrid_units_main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_log_layout_simple.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_main.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_matrix.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_os_thread.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_peer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_str.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_str_unit.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_thread.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_virtu.Plo@am__quote@
.c.o:
@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 rl_stubs.lo `test -f 'gras/rl_stubs.c' || echo '$(srcdir)/'`gras/rl_stubs.c
-xbt_thread.lo: xbt/xbt_thread.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_thread.lo -MD -MP -MF $(DEPDIR)/xbt_thread.Tpo -c -o xbt_thread.lo `test -f 'xbt/xbt_thread.c' || echo '$(srcdir)/'`xbt/xbt_thread.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbt_thread.Tpo $(DEPDIR)/xbt_thread.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbt/xbt_thread.c' object='xbt_thread.lo' libtool=yes @AMDEPBACKSLASH@
+xbt_os_thread.lo: xbt/xbt_os_thread.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_os_thread.lo -MD -MP -MF $(DEPDIR)/xbt_os_thread.Tpo -c -o xbt_os_thread.lo `test -f 'xbt/xbt_os_thread.c' || echo '$(srcdir)/'`xbt/xbt_os_thread.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbt_os_thread.Tpo $(DEPDIR)/xbt_os_thread.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbt/xbt_os_thread.c' object='xbt_os_thread.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 xbt_thread.lo `test -f 'xbt/xbt_thread.c' || echo '$(srcdir)/'`xbt/xbt_thread.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_os_thread.lo `test -f 'xbt/xbt_os_thread.c' || echo '$(srcdir)/'`xbt/xbt_os_thread.c
rl_transport.lo: gras/Transport/rl_transport.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rl_transport.lo -MD -MP -MF $(DEPDIR)/rl_transport.Tpo -c -o rl_transport.lo `test -f 'gras/Transport/rl_transport.c' || echo '$(srcdir)/'`gras/Transport/rl_transport.c
@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 sg_dns.lo `test -f 'gras/Virtu/sg_dns.c' || echo '$(srcdir)/'`gras/Virtu/sg_dns.c
-sg_stubs.lo: gras/sg_stubs.c
-@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_stubs.lo -MD -MP -MF $(DEPDIR)/sg_stubs.Tpo -c -o sg_stubs.lo `test -f 'gras/sg_stubs.c' || echo '$(srcdir)/'`gras/sg_stubs.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sg_stubs.Tpo $(DEPDIR)/sg_stubs.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gras/sg_stubs.c' object='sg_stubs.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 sg_stubs.lo `test -f 'gras/sg_stubs.c' || echo '$(srcdir)/'`gras/sg_stubs.c
-
sg_msg.lo: gras/Msg/sg_msg.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sg_msg.lo -MD -MP -MF $(DEPDIR)/sg_msg.Tpo -c -o sg_msg.lo `test -f 'gras/Msg/sg_msg.c' || echo '$(srcdir)/'`gras/Msg/sg_msg.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sg_msg.Tpo $(DEPDIR)/sg_msg.Plo
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define to 1 if you have the <jni.h> header file. */
+#undef HAVE_JNI_H
+
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
--- /dev/null
+/* $Id$ */
+
+/* xbt/xbt_thread.h -- Thread portability layer */
+
+/* Copyright (c) 2007 Martin Quinson. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+
+#ifndef _XBT_OS_THREAD_H
+#define _XBT_OS_THREAD_H
+
+#include "xbt/misc.h" /* SG_BEGIN_DECL */
+#include "xbt/function_types.h"
+
+SG_BEGIN_DECL()
+
+/** @addtogroup XBT_thread
+ * @brief Thread portability layer
+ *
+ * This section describes the thread portability layer. It defines types and
+ * functions very close to the pthread API, but it's portable to windows too.
+ *
+ * @{
+ */
+
+ /** \brief Thread data type (opaque structure) */
+ typedef struct xbt_os_thread_ *xbt_os_thread_t;
+
+ XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_create(pvoid_f_pvoid_t start_routine,void* param);
+ XBT_PUBLIC(void) xbt_os_thread_exit(int *retcode);
+ XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_self(void);
+ /* xbt_os_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
+ XBT_PUBLIC(void) xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return);
+ XBT_PUBLIC(void) xbt_os_thread_yield(void);
+
+
+ /** \brief Thread mutex data type (opaque structure) */
+ typedef struct xbt_os_mutex_ *xbt_os_mutex_t;
+
+ XBT_PUBLIC(xbt_os_mutex_t) xbt_os_mutex_init(void);
+ XBT_PUBLIC(void) xbt_os_mutex_lock(xbt_os_mutex_t mutex);
+ XBT_PUBLIC(void) xbt_os_mutex_unlock(xbt_os_mutex_t mutex);
+ XBT_PUBLIC(void) xbt_os_mutex_destroy(xbt_os_mutex_t mutex);
+
+
+ /** \brief Thread condition data type (opaque structure) */
+ typedef struct xbt_os_cond_ *xbt_os_cond_t;
+
+ 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_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);
+
+/** @} */
+
+SG_END_DECL()
+
+#endif /* _XBT_OS_THREAD_H */
+++ /dev/null
-/* $Id$ */
-
-/* xbt/xbt_thread.h -- Thread portability layer */
-
-/* Copyright (c) 2007 Martin Quinson. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-
-#ifndef _XBT_THREAD_H
-#define _XBT_THREAD_H
-
-#include "xbt/misc.h" /* SG_BEGIN_DECL */
-#include "xbt/function_types.h"
-
-SG_BEGIN_DECL()
-
-/** @addtogroup XBT_thread
- * @brief Thread portability layer
- *
- * This section describes the thread portability layer. It defines types and
- * functions very close to the pthread API, but it's portable to windows too.
- *
- * @{
- */
-
- /** \brief Thread data type (opaque structure) */
- typedef struct xbt_thread_ *xbt_thread_t;
-
- XBT_PUBLIC(xbt_thread_t) xbt_thread_create(pvoid_f_pvoid_t start_routine,void* param);
- XBT_PUBLIC(void) xbt_thread_exit(int *retcode);
- XBT_PUBLIC(xbt_thread_t) xbt_thread_self(void);
- /* xbt_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
- XBT_PUBLIC(void) xbt_thread_join(xbt_thread_t thread,void ** thread_return);
- XBT_PUBLIC(void) xbt_thread_yield(void);
-
-
- /** \brief Thread mutex data type (opaque structure) */
- typedef struct xbt_mutex_ *xbt_mutex_t;
-
- XBT_PUBLIC(xbt_mutex_t) xbt_mutex_init(void);
- XBT_PUBLIC(void) xbt_mutex_lock(xbt_mutex_t mutex);
- XBT_PUBLIC(void) xbt_mutex_unlock(xbt_mutex_t mutex);
- XBT_PUBLIC(void) xbt_mutex_destroy(xbt_mutex_t mutex);
-
-
- /** \brief Thread condition data type (opaque structure) */
- typedef struct xbt_thcond_ *xbt_thcond_t;
-
- XBT_PUBLIC(xbt_thcond_t) xbt_thcond_init(void);
- XBT_PUBLIC(void) xbt_thcond_wait(xbt_thcond_t cond,
- xbt_mutex_t mutex);
- XBT_PUBLIC(void) xbt_thcond_signal(xbt_thcond_t cond);
- XBT_PUBLIC(void) xbt_thcond_broadcast(xbt_thcond_t cond);
- XBT_PUBLIC(void) xbt_thcond_destroy(xbt_thcond_t cond);
-
-/** @} */
-
-SG_END_DECL()
-
-#endif /* _XBT_DICT_H */
m_process_t m_process = jprocess_to_native_process(jprocess,env);
smx_process_t s_process;
- xbt_mutex_t ctx_mutex, creation_mutex;
- xbt_thcond_t ctx_cond, creation_cond;
+ xbt_os_mutex_t ctx_mutex, creation_mutex;
+ xbt_os_cond_t ctx_cond, creation_cond;
DEBUG3("Msg_waitSignal(m_process=%p %s/%s)",
m_process,m_process->name,m_process->simdata->m_host->name);
creation_mutex = xbt_creation_mutex_get();
creation_cond = xbt_creation_cond_get();
- xbt_mutex_lock(creation_mutex);
- xbt_mutex_lock(ctx_mutex);
- xbt_thcond_signal( creation_cond );
- xbt_mutex_unlock( creation_mutex );
- xbt_thcond_wait(ctx_cond, ctx_mutex);
- xbt_mutex_unlock(ctx_mutex);
+ xbt_os_mutex_lock(creation_mutex);
+ xbt_os_mutex_lock(ctx_mutex);
+ xbt_os_cond_signal( creation_cond );
+ xbt_os_mutex_unlock( creation_mutex );
+ xbt_os_cond_wait(ctx_cond, ctx_mutex);
+ xbt_os_mutex_unlock(ctx_mutex);
}
JNIEXPORT void JNICALL
#include "portable.h"
#include "xbt/log.h"
#include "xbt/dynar.h"
-#include "xbt/xbt_thread.h"
+#include "xbt/xbt_os_thread.h"
#include "java/jxbt_context.h"
#include "java/jmsg.h"
#include "java/jmsg_process.h"
static xbt_context_t init_context = NULL; /* the initial context */
static xbt_swag_t context_to_destroy = NULL; /* the list of the contexs to destroy */
static xbt_swag_t context_living = NULL; /* the list of the contexts in use */
-static xbt_mutex_t creation_mutex; /* For syncronization during process creation */
-static xbt_thcond_t creation_cond; /* For syncronization during process creation */
-static xbt_mutex_t master_mutex; /* For syncronization during process scheduling*/
-static xbt_thcond_t master_cond; /* For syncronization during process scheduling*/
+static xbt_os_mutex_t creation_mutex; /* For syncronization during process creation */
+static xbt_os_cond_t creation_cond; /* For syncronization during process creation */
+static xbt_os_mutex_t master_mutex; /* For syncronization during process scheduling*/
+static xbt_os_cond_t master_cond; /* For syncronization during process scheduling*/
static void
__xbt_context_yield(xbt_context_t context);
* - restore thr current contex
*/
- xbt_mutex_lock(master_mutex);
- xbt_mutex_lock(context->mutex);
+ xbt_os_mutex_lock(master_mutex);
+ xbt_os_mutex_lock(context->mutex);
/* update the current context */
current_context = context;
- xbt_thcond_signal(context->cond);
- xbt_mutex_unlock(context->mutex);
- xbt_thcond_wait(master_cond, master_mutex);
- xbt_mutex_unlock(master_mutex);
+ xbt_os_cond_signal(context->cond);
+ xbt_os_mutex_unlock(context->mutex);
+ xbt_os_cond_wait(master_cond, master_mutex);
+ xbt_os_mutex_unlock(master_mutex);
/* retore the current context */
current_context = self;
* - restore thr current contex
*/
- xbt_mutex_lock(master_mutex);
- xbt_mutex_lock(context->mutex);
+ xbt_os_mutex_lock(master_mutex);
+ xbt_os_mutex_lock(context->mutex);
/* update the current context */
current_context = context;
- xbt_thcond_signal(master_cond);
- xbt_mutex_unlock(master_mutex);
- xbt_thcond_wait(context->cond, context->mutex);
- xbt_mutex_unlock(context->mutex);
+ xbt_os_cond_signal(master_cond);
+ xbt_os_mutex_unlock(master_mutex);
+ xbt_os_cond_wait(context->cond, context->mutex);
+ xbt_os_mutex_unlock(context->mutex);
/* retore the current context */
current_context = self;
}
}
/* destroy the mutex of the process */
- xbt_mutex_destroy(context->mutex);
+ xbt_os_mutex_destroy(context->mutex);
/* destroy the condition of the process */
- xbt_thcond_destroy(context->cond);
+ xbt_os_cond_destroy(context->cond);
context->mutex = NULL;
context->cond = NULL;
/*
* signal the condition of the java process
*/
- xbt_mutex_lock(master_mutex);
- xbt_mutex_lock(context->mutex);
- xbt_thcond_signal(context->cond);
- xbt_mutex_unlock(context->mutex);
+ xbt_os_mutex_lock(master_mutex);
+ xbt_os_mutex_lock(context->mutex);
+ xbt_os_cond_signal(context->cond);
+ xbt_os_mutex_unlock(context->mutex);
if (context->jprocess) {
/* if the java process is alive, stop it */
/*
* signal the condition of the main thread.
*/
- xbt_mutex_lock(master_mutex);
- xbt_mutex_lock(context->mutex);
- xbt_thcond_signal(master_cond);
- xbt_mutex_unlock(master_mutex);
+ xbt_os_mutex_lock(master_mutex);
+ xbt_os_mutex_lock(context->mutex);
+ xbt_os_cond_signal(master_cond);
+ xbt_os_mutex_unlock(master_mutex);
/* the global reference to the java process instance is deleted */
xbt_swag_insert(init_context, context_living);
/* this mutex is used to synchronize the creation of the java process */
- creation_mutex = xbt_mutex_init();
+ creation_mutex = xbt_os_mutex_init();
/* this mutex is used to synchronize the creation of the java process */
- creation_cond = xbt_thcond_init();
+ creation_cond = xbt_os_cond_init();
/* this mutex is used to synchronize the scheduling of the java process */
- master_mutex = xbt_mutex_init();
+ master_mutex = xbt_os_mutex_init();
/* this mutex is used to synchronize the scheduling of the java process */
- master_cond = xbt_thcond_init();
+ master_cond = xbt_os_cond_init();
}
}
context, context->jprocess, context->jenv);
/* the main thread locks the mutex used to create all the process */
- xbt_mutex_lock(creation_mutex);
+ xbt_os_mutex_lock(creation_mutex);
/* the main thread starts the java process */
jprocess_start(context->jprocess,context->jenv);
/* the main thread waits the startup of the java process */
- xbt_thcond_wait(creation_cond, creation_mutex);
+ xbt_os_cond_wait(creation_cond, creation_mutex);
/* the java process is started, the main thread unlocks the mutex
* used during the creation of the java process
*/
- xbt_mutex_unlock(creation_mutex);
+ xbt_os_mutex_unlock(creation_mutex);
}
context->code = code;
- context->mutex = xbt_mutex_init();
- context->cond = xbt_thcond_init();
+ context->mutex = xbt_os_mutex_init();
+ context->cond = xbt_os_cond_init();
context->argc = argc;
xbt_swag_free(context_to_destroy);
xbt_swag_free(context_living);
- xbt_mutex_destroy(creation_mutex);
- xbt_thcond_destroy(creation_cond);
- xbt_mutex_destroy(master_mutex);
- xbt_thcond_destroy(master_cond);
+ xbt_os_mutex_destroy(creation_mutex);
+ xbt_os_cond_destroy(creation_cond);
+ xbt_os_mutex_destroy(master_mutex);
+ xbt_os_cond_destroy(master_cond);
}
/**
__xbt_context_yield(context);
}
-xbt_thcond_t
+xbt_os_cond_t
xbt_creation_cond_get(void) {
return creation_cond;
}
-xbt_mutex_t
+xbt_os_mutex_t
xbt_creation_mutex_get(void) {
return creation_mutex;
}
#include "portable.h" /* loads context system definitions */
#include "xbt/context.h"
#include "xbt/ex.h"
-#include "xbt/xbt_thread.h"
+#include "xbt/xbt_os_thread.h"
#include <jni.h>
SG_BEGIN_DECL()
void jcontext_exit(xbt_context_t context ,int value,JNIEnv* env);
/** Returns the condition used to synchronise the creation of a java process. */
-xbt_thcond_t xbt_creation_cond_get(void);
+xbt_os_cond_t xbt_creation_cond_get(void);
/** Returns the mutex used to synchronise the creation of a java process */
-xbt_mutex_t xbt_creation_mutex_get(void);
+xbt_os_mutex_t xbt_creation_mutex_get(void);
SG_END_DECL()
#include "context_private.h"
#include "xbt/log.h"
#include "xbt/dynar.h"
-#include "xbt/xbt_thread.h"
-/*#include <pthread.h>*/ /* I need pthread_join that is not yet available in xbt_thread.*/
+#include "xbt/xbt_os_thread.h"
#ifdef CONTEXT_THREADS
/* This file (context.c) is only loaded in libsimgrid, not libgras.
- * xbt_thread is only loaded in libgras explicitly, and we need it in
+ * xbt_os_thread is only loaded in libgras explicitly, and we need it in
* libsimgrid, but only when it is the backend used to implement the
* xbt_context. So, do load it on need.
*/
-#include "xbt/xbt_thread.c"
+#include "xbt/xbt_os_thread.c"
+#else
+/* if not, load stubs so that all symbols get resolved anyway */
+#include "xbt/xbt_os_thread_stubs.c"
#endif
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_ctx, xbt, "Context");
static xbt_swag_t context_to_destroy = NULL;
static xbt_swag_t context_living = NULL;
#ifdef CONTEXT_THREADS
-static xbt_mutex_t creation_mutex;
-static xbt_thcond_t creation_cond;
+static xbt_os_mutex_t creation_mutex;
+static xbt_os_cond_t creation_cond;
#endif
static void __context_exit(xbt_context_t context ,int value);
if (context){
xbt_context_t self = current_context;
DEBUG2("[%p] **** Locking ctx %p ****", self, context);
- xbt_mutex_lock(context->mutex);
+ xbt_os_mutex_lock(context->mutex);
DEBUG1("[%p] **** Updating current_context ****", self);
current_context = context;
DEBUG1("[%p] **** Releasing the prisonner ****", self);
- xbt_thcond_signal(context->cond);
+ xbt_os_cond_signal(context->cond);
DEBUG3("[%p] **** Going to jail on individual %p/%p ****", self,context->cond, context->mutex);
- xbt_thcond_wait(context->cond, context->mutex);
+ xbt_os_cond_wait(context->cond, context->mutex);
DEBUG2("[%p] **** Unlocking individual %p ****", self,context->mutex);
- xbt_mutex_unlock(context->mutex);
+ xbt_os_mutex_unlock(context->mutex);
DEBUG1("[%p] **** Updating current_context ****", self);
current_context = self;
}
/*DEBUG1("\t joining %p",(void *)context->thread->t);*/
DEBUG1("\t joining %p",(void *)context->thread);
- xbt_thread_join(context->thread,NULL);
+ xbt_os_thread_join(context->thread,NULL);
DEBUG1("\t mutex_destroy %p",(void *)context->mutex);
- xbt_mutex_destroy(context->mutex);
+ xbt_os_mutex_destroy(context->mutex);
DEBUG1("\t cond_destroy %p",(void *)context->cond);
- xbt_thcond_destroy(context->cond);
+ xbt_os_cond_destroy(context->cond);
context->thread = NULL;
context->mutex = NULL;
#ifdef CONTEXT_THREADS
DEBUG2("[%p] **** Locking %p ****", context, context->mutex);
- xbt_mutex_lock(context->mutex);
+ xbt_os_mutex_lock(context->mutex);
/* DEBUG1("[%p] **** Updating current_context ****"); */
/* current_context = context; */
DEBUG1("[%p] **** Releasing the prisonner ****", context);
- xbt_thcond_signal(context->cond);
+ xbt_os_cond_signal(context->cond);
DEBUG2("[%p] **** Unlocking individual %p ****", context, context->mutex);
- xbt_mutex_unlock(context->mutex);
+ xbt_os_mutex_unlock(context->mutex);
DEBUG1("[%p] **** Exiting ****", context);
- xbt_thread_exit(NULL); // We should provide return value in case other wants it
+ xbt_os_thread_exit(NULL); // We should provide return value in case other wants it
#else
__xbt_context_yield(context);
#endif
#ifdef CONTEXT_THREADS
context = (xbt_context_t)c;
- context->thread = xbt_thread_self();
+ context->thread = xbt_os_thread_self();
- DEBUG3("**[ctx:%p;self:%p]** Lock creation_mutex %p ****",context,(void*)xbt_thread_self(), creation_mutex);
- xbt_mutex_lock(creation_mutex);
- xbt_mutex_lock(context->mutex);
+ DEBUG3("**[ctx:%p;self:%p]** Lock creation_mutex %p ****",context,(void*)xbt_os_thread_self(), creation_mutex);
+ xbt_os_mutex_lock(creation_mutex);
+ xbt_os_mutex_lock(context->mutex);
DEBUG4("**[ctx:%p;self:%p]** Releasing the creator (creation_cond %p,%p) ****",
- context,(void*)xbt_thread_self(),creation_cond,creation_mutex);
- xbt_thcond_signal(creation_cond);
- xbt_mutex_unlock(creation_mutex);
+ context,(void*)xbt_os_thread_self(),creation_cond,creation_mutex);
+ xbt_os_cond_signal(creation_cond);
+ xbt_os_mutex_unlock(creation_mutex);
DEBUG4("**[ctx:%p;self:%p]** Going to Jail on lock %p and cond %p ****",
- context,(void*)xbt_thread_self(),context->mutex,context->cond);
- xbt_thcond_wait(context->cond, context->mutex);
+ context,(void*)xbt_os_thread_self(),context->mutex,context->cond);
+ xbt_os_cond_wait(context->cond, context->mutex);
DEBUG3("**[ctx:%p;self:%p]** Unlocking individual %p ****",
- context,(void*)xbt_thread_self(),context->mutex);
- xbt_mutex_unlock(context->mutex);
+ context,(void*)xbt_os_thread_self(),context->mutex);
+ xbt_os_mutex_unlock(context->mutex);
#endif
context_living = xbt_swag_new(xbt_swag_offset(*current_context,hookup));
xbt_swag_insert(init_context, context_living);
#ifdef CONTEXT_THREADS
- creation_mutex = xbt_mutex_init();
- creation_cond = xbt_thcond_init();
+ creation_mutex = xbt_os_mutex_init();
+ creation_cond = xbt_os_cond_init();
#endif
}
}
{
#ifdef CONTEXT_THREADS
/* Launch the thread */
- DEBUG3("**[ctx:%p;self:%p]** Locking creation_mutex %p ****",context,xbt_thread_self(),creation_mutex);
- xbt_mutex_lock(creation_mutex);
+ DEBUG3("**[ctx:%p;self:%p]** Locking creation_mutex %p ****",context,xbt_os_thread_self(),creation_mutex);
+ xbt_os_mutex_lock(creation_mutex);
- DEBUG2("**[ctx:%p;self:%p]** Thread create ****",context,xbt_thread_self());
- context->thread = xbt_thread_create(__context_wrapper, context);
- DEBUG3("**[ctx:%p;self:%p]** Thread created : %p ****",context,xbt_thread_self(),context->thread);
+ DEBUG2("**[ctx:%p;self:%p]** Thread create ****",context,xbt_os_thread_self());
+ context->thread = xbt_os_thread_create(__context_wrapper, context);
+ DEBUG3("**[ctx:%p;self:%p]** Thread created : %p ****",context,xbt_os_thread_self(),context->thread);
DEBUG4("**[ctx:%p;self:%p]** Going to jail on creation_cond/mutex (%p,%p) ****",
- context,xbt_thread_self(),creation_cond, creation_mutex);
- xbt_thcond_wait(creation_cond, creation_mutex);
- DEBUG3("**[ctx:%p;self:%p]** Unlocking creation %p ****",context, xbt_thread_self(),creation_mutex);
- xbt_mutex_unlock(creation_mutex);
+ context,xbt_os_thread_self(),creation_cond, creation_mutex);
+ xbt_os_cond_wait(creation_cond, creation_mutex);
+ DEBUG3("**[ctx:%p;self:%p]** Unlocking creation %p ****",context, xbt_os_thread_self(),creation_mutex);
+ xbt_os_mutex_unlock(creation_mutex);
#else
makecontext (&(context->uc), (void (*) (void)) __context_wrapper,1, context);
#endif
res->code = code;
#ifdef CONTEXT_THREADS
- res->mutex = xbt_mutex_init();
- res->cond = xbt_thcond_init();
+ res->mutex = xbt_os_mutex_init();
+ res->cond = xbt_os_cond_init();
#else
xbt_assert2(getcontext(&(res->uc))==0,"Error in context saving: %d (%s)", errno, strerror(errno));
xbt_swag_free(context_living);
#ifdef CONTEXT_THREADS
- xbt_mutex_destroy(creation_mutex);
- xbt_thcond_destroy(creation_cond);
+ xbt_os_mutex_destroy(creation_mutex);
+ xbt_os_cond_destroy(creation_cond);
#endif
}
#include "xbt/ex.h"
#ifdef CONTEXT_THREADS
-# include "xbt/xbt_thread.h"
+# include "xbt/xbt_os_thread.h"
#else
# include <ucontext.h>
# define STACK_SIZE 128*1024 /* Lower this if you want to reduce the memory consumption */
JNIEnv* jenv; /* jni interface pointer for this thread */
#else
# ifdef CONTEXT_THREADS
- xbt_thread_t thread; /* a plain dumb thread (portable to posix or windows) */
+ xbt_os_thread_t thread; /* a plain dumb thread (portable to posix or windows) */
# else
ucontext_t uc; /* the thread that execute the code */
char stack[STACK_SIZE];
/* What we need to synchronize the process */
#if defined(JAVA_SIMGRID) || defined(CONTEXT_THREADS)
- xbt_thcond_t cond; /* the condition used to synchronize the process */
- xbt_mutex_t mutex; /* the mutex used to synchronize the process */
+ xbt_os_cond_t cond; /* the condition used to synchronize the process */
+ xbt_os_mutex_t mutex; /* the mutex used to synchronize the process */
#endif
/* What to run */
VERB0("Initialize XBT");
xbt_log_init(argc,argv);
- xbt_thread_mod_init();
+ xbt_os_thread_mod_init();
xbt_context_init();
}
xbt_fifo_exit();
xbt_dict_exit();
xbt_context_exit();
- xbt_thread_mod_exit();
+ xbt_os_thread_mod_exit();
xbt_log_exit();
}
/* $Id$ */
-/* xbt_thread -- portability layer over the pthread API */
+/* xbt_os_thread -- portability layer over the pthread API */
+/* Used in RL to get win/lin portability, and in SG when CONTEXT_THREAD */
+/* in SG, when using CONTEXT_UCONTEXT, xbt_os_thread_stub is used instead */
/* Copyright 2006,2007 Malek Cherier, Martin Quinson
* All right reserved. */
#include "xbt/sysdep.h"
#include "xbt/ex.h"
#include "portable.h"
-#include "xbt/xbt_thread.h" /* This module */
+#include "xbt/xbt_os_thread.h" /* This module */
#include "xbt_modinter.h" /* Initialization/finalization of this module */
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
-typedef struct xbt_thread_ {
+typedef struct xbt_os_thread_ {
pthread_t t;
void *param;
pvoid_f_pvoid_t *start_routine;
-} s_xbt_thread_t ;
+} s_xbt_os_thread_t ;
-/* thread-specific data containing the xbt_thread_t structure */
+/* thread-specific data containing the xbt_os_thread_t structure */
static pthread_key_t xbt_self_thread_key;
-/* frees the xbt_thread_t corresponding to the current thread */
-static void xbt_thread_free_thread_data(void*d){
+/* frees the xbt_os_thread_t corresponding to the current thread */
+static void xbt_os_thread_free_thread_data(void*d){
free(d);
}
-void xbt_thread_mod_init(void) {
+void xbt_os_thread_mod_init(void) {
int errcode;
if ((errcode=pthread_key_create(&xbt_self_thread_key, NULL)))
THROW0(system_error,errcode,"pthread_key_create failed for xbt_self_thread_key");
}
-void xbt_thread_mod_exit(void) {
+void xbt_os_thread_mod_exit(void) {
/* FIXME: don't try to free our key on shutdown. Valgrind detects no leak if we don't, and whine if we try to */
// int errcode;
}
static void * wrapper_start_routine(void *s) {
- xbt_thread_t t = s;
+ xbt_os_thread_t t = s;
int errcode;
if ((errcode=pthread_setspecific(xbt_self_thread_key,t)))
return t->start_routine(t->param);
}
-xbt_thread_t xbt_thread_create(pvoid_f_pvoid_t start_routine,
- void* param) {
+xbt_os_thread_t xbt_os_thread_create(pvoid_f_pvoid_t start_routine,
+ void* param) {
int errcode;
- xbt_thread_t res_thread=xbt_new(s_xbt_thread_t,1);
+ xbt_os_thread_t res_thread=xbt_new(s_xbt_os_thread_t,1);
res_thread->start_routine = start_routine;
res_thread->param = param;
}
void
-xbt_thread_join(xbt_thread_t thread,void ** thread_return) {
+xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return) {
int errcode;
free(thread);
}
-void xbt_thread_exit(int *retval) {
+void xbt_os_thread_exit(int *retval) {
pthread_exit(retval);
}
-xbt_thread_t xbt_thread_self(void) {
+xbt_os_thread_t xbt_os_thread_self(void) {
return pthread_getspecific(xbt_self_thread_key);
}
#include <sched.h>
-void xbt_thread_yield(void) {
+void xbt_os_thread_yield(void) {
sched_yield();
}
/****** mutex related functions ******/
-typedef struct xbt_mutex_ {
+typedef struct xbt_os_mutex_ {
pthread_mutex_t m;
-} s_xbt_mutex_t;
+} s_xbt_os_mutex_t;
-xbt_mutex_t xbt_mutex_init(void) {
- xbt_mutex_t res = xbt_new(s_xbt_mutex_t,1);
+xbt_os_mutex_t xbt_os_mutex_init(void) {
+ xbt_os_mutex_t res = xbt_new(s_xbt_os_mutex_t,1);
int errcode;
if ((errcode = pthread_mutex_init(&(res->m),NULL)))
return res;
}
-void xbt_mutex_lock(xbt_mutex_t mutex) {
+void xbt_os_mutex_lock(xbt_os_mutex_t mutex) {
int errcode;
if ((errcode=pthread_mutex_lock(&(mutex->m))))
mutex, strerror(errcode));
}
-void xbt_mutex_unlock(xbt_mutex_t mutex) {
+void xbt_os_mutex_unlock(xbt_os_mutex_t mutex) {
int errcode;
if ((errcode=pthread_mutex_unlock(&(mutex->m))))
mutex, strerror(errcode));
}
-void xbt_mutex_destroy(xbt_mutex_t mutex) {
+void xbt_os_mutex_destroy(xbt_os_mutex_t mutex) {
int errcode;
if (!mutex) return;
}
/***** condition related functions *****/
-typedef struct xbt_thcond_ {
+typedef struct xbt_os_cond_ {
pthread_cond_t c;
-} s_xbt_thcond_t;
+} s_xbt_os_cond_t;
-xbt_thcond_t xbt_thcond_init(void) {
- xbt_thcond_t res = xbt_new(s_xbt_thcond_t,1);
+xbt_os_cond_t xbt_os_cond_init(void) {
+ xbt_os_cond_t res = xbt_new(s_xbt_os_cond_t,1);
int errcode;
if ((errcode=pthread_cond_init(&(res->c),NULL)))
THROW1(system_error,errcode,"pthread_cond_init() failed: %s",
return res;
}
-void xbt_thcond_wait(xbt_thcond_t cond, xbt_mutex_t mutex) {
+void xbt_os_cond_wait(xbt_os_cond_t cond, xbt_os_mutex_t mutex) {
int errcode;
if ((errcode=pthread_cond_wait(&(cond->c),&(mutex->m))))
THROW3(system_error,errcode,"pthread_cond_wait(%p,%p) failed: %s",
cond,mutex, strerror(errcode));
}
-void xbt_thcond_signal(xbt_thcond_t cond) {
+void xbt_os_cond_signal(xbt_os_cond_t cond) {
int errcode;
if ((errcode=pthread_cond_signal(&(cond->c))))
THROW2(system_error,errcode,"pthread_cond_signal(%p) failed: %s",
cond, strerror(errcode));
}
-void xbt_thcond_broadcast(xbt_thcond_t cond){
+void xbt_os_cond_broadcast(xbt_os_cond_t cond){
int errcode;
if ((errcode=pthread_cond_broadcast(&(cond->c))))
THROW2(system_error,errcode,"pthread_cond_broadcast(%p) failed: %s",
cond, strerror(errcode));
}
-void xbt_thcond_destroy(xbt_thcond_t cond){
+void xbt_os_cond_destroy(xbt_os_cond_t cond){
int errcode;
if (!cond) return;
#elif defined(WIN32)
-typedef struct xbt_thread_ {
+typedef struct xbt_os_thread_ {
HANDLE handle; /* the win thread handle */
unsigned long id; /* the win thread id */
pvoid_f_pvoid_t *start_routine;
void* param;
-} s_xbt_thread_t ;
+} s_xbt_os_thread_t ;
-/* key to the TLS containing the xbt_thread_t structure */
+/* key to the TLS containing the xbt_os_thread_t structure */
static unsigned long xbt_self_thread_key;
-void xbt_thread_mod_init(void) {
+void xbt_os_thread_mod_init(void) {
xbt_self_thread_key = TlsAlloc();
}
-void xbt_thread_mod_exit(void) {
+void xbt_os_thread_mod_exit(void) {
if (!TlsFree(xbt_self_thread_key))
THROW0(system_error,(int)GetLastError(),"TlsFree() failed to cleanup the thread submodule");
}
static DWORD WINAPI wrapper_start_routine(void *s) {
- xbt_thread_t t = (xbt_thread_t)s;
+ xbt_os_thread_t t = (xbt_os_thread_t)s;
if(!TlsSetValue(xbt_self_thread_key,t))
THROW0(system_error,(int)GetLastError(),"TlsSetValue of data describing the created thread failed");
}
-xbt_thread_t xbt_thread_create(pvoid_f_pvoid_t start_routine,
+xbt_os_thread_t xbt_os_thread_create(pvoid_f_pvoid_t start_routine,
void* param) {
- xbt_thread_t t = xbt_new(s_xbt_thread_t,1);
+ xbt_os_thread_t t = xbt_new(s_xbt_os_thread_t,1);
t->start_routine = start_routine ;
t->param = param;
}
void
-xbt_thread_join(xbt_thread_t thread,void ** thread_return) {
+xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return) {
if(WAIT_OBJECT_0 != WaitForSingleObject(thread->handle,INFINITE))
THROW0(system_error,(int)GetLastError(), "WaitForSingleObject failed");
free(thread);
}
-void xbt_thread_exit(int *retval) {
+void xbt_os_thread_exit(int *retval) {
if(retval)
ExitThread(*retval);
else
ExitThread(0);
}
-xbt_thread_t xbt_thread_self(void) {
+xbt_os_thread_t xbt_os_thread_self(void) {
return TlsGetValue(xbt_self_thread_key);
}
-void xbt_thread_yield(void) {
+void xbt_os_thread_yield(void) {
Sleep(0);
}
/****** mutex related functions ******/
-typedef struct xbt_mutex_ {
+typedef struct xbt_os_mutex_ {
CRITICAL_SECTION lock;
-} s_xbt_mutex_t;
+} s_xbt_os_mutex_t;
-xbt_mutex_t xbt_mutex_init(void) {
- xbt_mutex_t res = xbt_new(s_xbt_mutex_t,1);
+xbt_os_mutex_t xbt_os_mutex_init(void) {
+ xbt_os_mutex_t res = xbt_new(s_xbt_os_mutex_t,1);
/* initialize the critical section object */
InitializeCriticalSection(&(res->lock));
return res;
}
-void xbt_mutex_lock(xbt_mutex_t mutex) {
+void xbt_os_mutex_lock(xbt_os_mutex_t mutex) {
EnterCriticalSection(& mutex->lock);
}
-void xbt_mutex_unlock(xbt_mutex_t mutex) {
+void xbt_os_mutex_unlock(xbt_os_mutex_t mutex) {
LeaveCriticalSection (& mutex->lock);
}
-void xbt_mutex_destroy(xbt_mutex_t mutex) {
+void xbt_os_mutex_destroy(xbt_os_mutex_t mutex) {
if (!mutex) return;
MAX_EVENTS = 2
};
-typedef struct xbt_thcond_ {
+typedef struct xbt_os_cond_ {
HANDLE events[MAX_EVENTS];
unsigned int waiters_count; /* the number of waiters */
CRITICAL_SECTION waiters_count_lock; /* protect access to waiters_count */
-} s_xbt_thcond_t;
+} s_xbt_os_cond_t;
-xbt_thcond_t xbt_thcond_init(void) {
+xbt_os_cond_t xbt_os_cond_init(void) {
- xbt_thcond_t res = xbt_new0(s_xbt_thcond_t,1);
+ xbt_os_cond_t res = xbt_new0(s_xbt_os_cond_t,1);
memset(& res->waiters_count_lock,0,sizeof(CRITICAL_SECTION));
return res;
}
-void xbt_thcond_wait(xbt_thcond_t cond, xbt_mutex_t mutex) {
+void xbt_os_cond_wait(xbt_os_cond_t cond, xbt_os_mutex_t mutex) {
unsigned long wait_result;
int is_last_waiter;
EnterCriticalSection (& mutex->lock);
}
-void xbt_thcond_signal(xbt_thcond_t cond) {
+void xbt_os_cond_signal(xbt_os_cond_t cond) {
int have_waiters;
EnterCriticalSection (& cond->waiters_count_lock);
if(!SetEvent(cond->events[SIGNAL]))
THROW0(system_error,0,"SetEvent failed");
- xbt_thread_yield();
+ xbt_os_thread_yield();
}
-void xbt_thcond_broadcast(xbt_thcond_t cond){
+void xbt_os_cond_broadcast(xbt_os_cond_t cond){
int have_waiters;
EnterCriticalSection (& cond->waiters_count_lock);
SetEvent(cond->events[BROADCAST]);
}
-void xbt_thcond_destroy(xbt_thcond_t cond){
+void xbt_os_cond_destroy(xbt_os_cond_t cond){
int error = 0;
if (!cond) return;
void xbt_context_init(void);
void xbt_context_exit(void);
-void xbt_thread_mod_init(void);
-void xbt_thread_mod_exit(void);
+void xbt_os_thread_mod_init(void);
+void xbt_os_thread_mod_exit(void);
#endif /* XBT_MODINTER_H */