diff options
author | sh <sh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-12-02 14:13:12 +0000 |
---|---|---|
committer | sh <sh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-12-02 14:13:12 +0000 |
commit | b31e35de50d57501895ab343aa20ec135f108e64 (patch) | |
tree | 8ca30f0332f0da78a9d5fa75b3d15687858c3b10 /libgomp | |
parent | e7a6ef612a3e48068b6c76ff33442c733e37766b (diff) | |
download | gcc-b31e35de50d57501895ab343aa20ec135f108e64.tar.gz |
[RTEMS] Use spin lock for pool management
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243181 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 9 | ||||
-rw-r--r-- | libgomp/config/rtems/pool.h | 10 | ||||
-rw-r--r-- | libgomp/config/rtems/proc.c | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index f072ce49711..469e8967409 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,14 @@ 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 thread pool in case nthreads == 1. diff --git a/libgomp/config/rtems/pool.h b/libgomp/config/rtems/pool.h index e69eca45dda..83fddc8a1b2 100644 --- a/libgomp/config/rtems/pool.h +++ b/libgomp/config/rtems/pool.h @@ -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); } } diff --git a/libgomp/config/rtems/proc.c b/libgomp/config/rtems/proc.c index d4123d26bf4..5e04b47ca1a 100644 --- a/libgomp/config/rtems/proc.c +++ b/libgomp/config/rtems/proc.c @@ -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; |