Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Protect with HAVE_FUTEX_H
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 7 Mar 2011 11:21:04 +0000 (11:21 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 7 Mar 2011 11:21:04 +0000 (11:21 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9763 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/parmap.c
src/xbt/parmap_private.h

index 9e9a0df..b489549 100644 (file)
@@ -34,18 +34,22 @@ xbt_parmap_t xbt_parmap_new(unsigned int num_workers)
 
   /* Initialize the thread pool data structure */
   xbt_parmap_t parmap = xbt_new0(s_xbt_parmap_t, 1);
+#ifdef HAVE_FUTEX_H
   parmap->sync_event = xbt_new0(s_xbt_event_t, 1);
+#endif
   parmap->num_workers = num_workers;
   parmap->status = PARMAP_WORK;
+#ifdef HAVE_FUTEX_H
   parmap->sync_event->threads_to_wait = num_workers;
-
+#endif
   /* Create the pool of worker threads */
   for(i=0; i < num_workers; i++){
     worker = xbt_os_thread_create(NULL, _xbt_parmap_worker_main, parmap, NULL);
     xbt_os_thread_detach(worker);
   }
-
+#ifdef HAVE_FUTEX_H
   xbt_event_init(parmap->sync_event);
+#endif
   return parmap;
 }
 
@@ -53,8 +57,10 @@ void xbt_parmap_destroy(xbt_parmap_t parmap)
 { 
   XBT_DEBUG("Destroy parmap %p", parmap);
   parmap->status = PARMAP_DESTROY;
+#ifdef HAVE_FUTEX_H
   xbt_event_signal(parmap->sync_event);
   xbt_free(parmap->sync_event);
+#endif
   xbt_free(parmap);
 }
 
@@ -63,9 +69,9 @@ void xbt_parmap_destroy(xbt_parmap_t parmap)
   /* Assign resources to worker threads*/
   parmap->fun = fun;
   parmap->data = data;
-
+#ifdef HAVE_FUTEX_H
   xbt_event_signal(parmap->sync_event);
-
+#endif
   XBT_DEBUG("Job done");
 }
 
@@ -82,7 +88,9 @@ static void *_xbt_parmap_worker_main(void *arg)
   
   /* Worker's main loop */
   while(1){
+#ifdef HAVE_FUTEX_H
     xbt_event_wait(parmap->sync_event);
+#endif
     if(parmap->status == PARMAP_WORK){
       XBT_DEBUG("Worker %u got a job", worker_id);
 
@@ -107,7 +115,9 @@ static void *_xbt_parmap_worker_main(void *arg)
 
     /* We are destroying the parmap */
     }else{
+#ifdef HAVE_FUTEX_H
       xbt_event_end(parmap->sync_event);
+#endif
       XBT_DEBUG("Shutting down worker %u", worker_id);
       return NULL;
     }
index 0ed8c7a..b6309be 100644 (file)
@@ -35,7 +35,9 @@ void xbt_event_end(xbt_event_t event);
 
 typedef struct s_xbt_parmap {
   e_xbt_parmap_flag_t status;
+#ifdef HAVE_FUTEX_H
   xbt_event_t sync_event;
+#endif
   unsigned int num_workers;
   unsigned int workers_max_id;
   void_f_pvoid_t fun;