[RTEMS] Use spin lock for pool management
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Fri, 2 Dec 2016 14:13:12 +0000 (14:13 +0000)
committerSebastian Huber <sh@gcc.gnu.org>
Fri, 2 Dec 2016 14:13:12 +0000 (14:13 +0000)
libgomp/

* libgomp/config/rtems/pool.h (gomp_thread_pool_reservoir): Use
pthread_spinlock_t instead of gomp_mutex_t lock.
(gomp_get_thread_pool): Likewise.
(gomp_release_thread_pool): Likewise.
* libgomp/config/rtems/proc.c (allocate_thread_pool_reservoir):
Likewise.

From-SVN: r243181

libgomp/ChangeLog
libgomp/config/rtems/pool.h
libgomp/config/rtems/proc.c

index f072ce4971175c6cfa8629584f52c7a2e9665f3e..469e8967409400aee476031420f5acf04c916cc0 100644 (file)
@@ -1,3 +1,12 @@
+2016-12-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+       * libgomp/config/rtems/pool.h (gomp_thread_pool_reservoir): Use
+       pthread_spinlock_t instead of gomp_mutex_t lock.
+       (gomp_get_thread_pool): Likewise.
+       (gomp_release_thread_pool): Likewise.
+       * libgomp/config/rtems/proc.c (allocate_thread_pool_reservoir):
+       Likewise.
+
 2016-12-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
        * config/rtems/pool.h (gomp_get_thread_pool): Return proper
index e69eca45dda615539ed1e64821fa3d7f2a22112a..83fddc8a1b258839676abfcd470c5bf16e39f1f8 100644 (file)
@@ -39,7 +39,7 @@
    GOMP_RTEMS_THREAD_POOLS environment variable.  */
 struct gomp_thread_pool_reservoir {
   gomp_sem_t available;
-  gomp_mutex_t lock;
+  pthread_spinlock_t lock;
   size_t index;
   int priority;
   struct gomp_thread_pool *pools[];
@@ -96,9 +96,9 @@ gomp_get_thread_pool (struct gomp_thread *thr, unsigned nthreads)
   if (res != NULL)
     {
       gomp_sem_wait (&res->available);
-      gomp_mutex_lock (&res->lock);
+      pthread_spin_lock (&res->lock);
       pool = res->pools[--res->index];
-      gomp_mutex_unlock (&res->lock);
+      pthread_spin_unlock (&res->lock);
       pool->threads_busy = nthreads;
       thr->thread_pool = pool;
     }
@@ -115,9 +115,9 @@ gomp_release_thread_pool (struct gomp_thread_pool *pool)
     gomp_tls_rtems_data.thread_pool_reservoir;
   if (res != NULL)
     {
-      gomp_mutex_lock (&res->lock);
+      pthread_spin_lock (&res->lock);
       res->pools[res->index++] = pool;
-      gomp_mutex_unlock (&res->lock);
+      pthread_spin_unlock (&res->lock);
       gomp_sem_post (&res->available);
     }
 }
index d4123d26bf468b5a638758d236ee55579b471de9..5e04b47ca1a544e8e7a835f44c52d9e84e77507b 100644 (file)
@@ -66,7 +66,7 @@ allocate_thread_pool_reservoir (unsigned long count, unsigned long priority,
   res->index = count;
   res->priority = priority;
   gomp_sem_init (&res->available, count);
-  gomp_mutex_init (&res->lock);
+  pthread_spin_init (&res->lock, PTHREAD_PROCESS_PRIVATE);
   for (i = 0; i < count; ++i)
     res->pools[i] = &pools[i];
   gomp_thread_pool_reservoirs[scheduler] = res;