Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Drop xbt_os_thread_t
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 15 Jan 2019 23:56:48 +0000 (00:56 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 15 Jan 2019 23:57:02 +0000 (00:57 +0100)
ChangeLog
include/xbt/xbt_os_thread.h
src/xbt/xbt_main.cpp
src/xbt/xbt_os_thread.c
src/xbt_modinter.h

index 2e43e78..ecaba6b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,14 +25,7 @@ XBT:
  - Implement the 'thread' factory with std::thread instead of xbt ones.
    It is not possible to set the stack size with threads anymore, but
    -fsplit-stack is the way to go nowadays when using threads.
- - Drop several unused xbt_os_thread_t functions:
-   - xbt_os_thread_exit()
-   - xbt_os_thread_get_extra_data()
-   - xbt_os_thread_set_extra_data()
-   - xbt_os_thread_self()
-   - xbt_os_thread_self_name()
-   - xbt_os_thread_setstacksize()
-   - xbt_os_thread_setguardsize()
+ - Drop the xbt_os_thread_t module (now unused)
  - Drop xbt_ex_display(), use simgrid::xbt::log_exception() instead.
 
 Fixed bugs:
index 44e6557..95a3377 100644 (file)
@@ -24,13 +24,6 @@ SG_BEGIN_DECL()
  *  @{
  */
 
-/** @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_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 int xbt_os_thread_bind(xbt_os_thread_t thread, int core);
 XBT_PUBLIC int xbt_os_thread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
 
 /** @brief Thread mutex data type (opaque structure) */
@@ -40,13 +33,6 @@ XBT_PUBLIC void xbt_os_mutex_acquire(xbt_os_mutex_t mutex);
 XBT_PUBLIC void xbt_os_mutex_release(xbt_os_mutex_t mutex);
 XBT_PUBLIC void xbt_os_mutex_destroy(xbt_os_mutex_t mutex);
 
-/** @brief Semaphore data type (opaque structure) */
-typedef struct xbt_os_sem_ *xbt_os_sem_t;
-XBT_PUBLIC xbt_os_sem_t xbt_os_sem_init(unsigned int value);
-XBT_PUBLIC void xbt_os_sem_acquire(xbt_os_sem_t sem);
-XBT_PUBLIC void xbt_os_sem_release(xbt_os_sem_t sem);
-XBT_PUBLIC void xbt_os_sem_destroy(xbt_os_sem_t sem);
-
 /** @} */
 
 SG_END_DECL()
index 6cf96b8..dc54415 100644 (file)
@@ -92,7 +92,6 @@ static void xbt_preinit()
   _set_output_format(_TWO_DIGIT_EXPONENT);
 #endif
   xbt_log_preinit();
-  xbt_os_thread_mod_preinit();
   xbt_dict_preinit();
 
   srand(seed);
@@ -108,7 +107,6 @@ static void xbt_postexit()
     return;
   xbt_initialized--;
   xbt_dict_postexit();
-  xbt_os_thread_mod_postexit();
   xbt_dynar_free(&xbt_cmdline);
   xbt_log_postexit();
 #if SIMGRID_HAVE_MC
index 707f5b9..1a19ba5 100644 (file)
@@ -48,37 +48,6 @@ typedef struct xbt_os_thread_ {
   void *param;
   pvoid_f_pvoid_t start_routine;
 } s_xbt_os_thread_t;
-static xbt_os_thread_t main_thread = NULL;
-
-/* thread-specific data containing the xbt_os_thread_t structure */
-static int thread_mod_inited = 0;
-
-/* frees the xbt_os_thread_t corresponding to the current thread */
-static void xbt_os_thread_free_thread_data(xbt_os_thread_t thread)
-{
-  if (thread == main_thread)    /* just killed main thread */
-    main_thread = NULL;
-  free(thread);
-}
-
-void xbt_os_thread_mod_preinit(void)
-{
-  if (thread_mod_inited)
-    return;
-
-  main_thread = xbt_new(s_xbt_os_thread_t, 1);
-  main_thread->param = NULL;
-  main_thread->start_routine = NULL;
-
-  thread_mod_inited = 1;
-}
-
-void xbt_os_thread_mod_postexit(void)
-{
-  free(main_thread);
-  main_thread = NULL;
-  thread_mod_inited = 0;
-}
 
 /** Calls pthread_atfork() if present, and raise an exception otherwise.
  *
@@ -93,50 +62,6 @@ int xbt_os_thread_atfork(void (*prepare)(void), void (*parent)(void), void (*chi
   return pthread_atfork(prepare, parent, child);
 }
 
-static void *wrapper_start_routine(void *s)
-{
-  xbt_os_thread_t t = s;
-
-  return t->start_routine(t->param);
-}
-
-xbt_os_thread_t xbt_os_thread_create(pvoid_f_pvoid_t start_routine, void* param)
-{
-  xbt_os_thread_t res_thread = xbt_new(s_xbt_os_thread_t, 1);
-  res_thread->start_routine = start_routine;
-  res_thread->param = param;
-
-  int errcode = pthread_create(&(res_thread->t), NULL, wrapper_start_routine, res_thread);
-  xbt_assert(errcode == 0, "pthread_create failed: %s", strerror(errcode));
-
-  return res_thread;
-}
-
-/** Bind the thread to the given core, if possible.
- *
- * If pthread_setaffinity_np is not usable on that (non-gnu) platform, this function does nothing.
- */
-int xbt_os_thread_bind(XBT_ATTRIB_UNUSED xbt_os_thread_t thread, XBT_ATTRIB_UNUSED int cpu)
-{
-  int errcode = 0;
-#if HAVE_PTHREAD_SETAFFINITY
-  pthread_t pthread = thread->t;
-  cpu_set_t cpuset;
-  CPU_ZERO(&cpuset);
-  CPU_SET(cpu, &cpuset);
-  errcode = pthread_setaffinity_np(pthread, sizeof(cpu_set_t), &cpuset);
-#endif
-  return errcode;
-}
-
-void xbt_os_thread_join(xbt_os_thread_t thread, void **thread_return)
-{
-  int errcode = pthread_join(thread->t, thread_return);
-
-  xbt_assert(errcode==0, "pthread_join failed: %s", strerror(errcode));
-  xbt_os_thread_free_thread_data(thread);
-}
-
 /****** mutex related functions ******/
 typedef struct xbt_os_mutex_ {
   pthread_mutex_t m;
index 6dcb224..0b5b855 100644 (file)
@@ -19,9 +19,6 @@ void xbt_log_postexit(void);
 void xbt_dict_preinit(void);
 void xbt_dict_postexit(void);
 
-void xbt_os_thread_mod_preinit(void);
-void xbt_os_thread_mod_postexit(void);
-
 void *mmalloc_preinit(void);
 void mmalloc_postexit(void);