summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-20 06:15:07 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-22 09:25:08 +0200
commitb5a21bf139168285a009c8da65e63ea99bc064ba (patch)
treec2817f7cd6c2f50aaa90367139267f9767da1123
parentscore: Rename _CORE_RWLock_Obtain() (diff)
downloadrtems-b5a21bf139168285a009c8da65e63ea99bc064ba.tar.bz2
posix: Avoid Giant lock in sem_getvalue()
Update #2555.
-rw-r--r--cpukit/posix/src/semgetvalue.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/cpukit/posix/src/semgetvalue.c b/cpukit/posix/src/semgetvalue.c
index ed49c09d38..f89526610f 100644
--- a/cpukit/posix/src/semgetvalue.c
+++ b/cpukit/posix/src/semgetvalue.c
@@ -37,13 +37,22 @@ int sem_getvalue(
{
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
+ ISR_lock_Context lock_context;
- the_semaphore = _POSIX_Semaphore_Get( sem, &location );
+ the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
+ sem,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
+ /*
+ * Assume a relaxed atomic load of the value on SMP configurations.
+ * Thus, there is no need to acquire a lock.
+ */
*sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore );
- _Objects_Put( &the_semaphore->Object );
+ _ISR_lock_ISR_enable( &lock_context );
return 0;
#if defined(RTEMS_MULTIPROCESSING)