summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-19 17:02:54 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-22 09:25:08 +0200
commit4025a60fcb892169266102a58beef4caad17340c (patch)
tree004df492a31db98faa24335a663eed429ebb5d05 /cpukit/posix/src
parentposix: Avoid Giant lock in sem_getvalue() (diff)
downloadrtems-4025a60fcb892169266102a58beef4caad17340c.tar.bz2
score: Avoid Giant lock for CORE mtx/sem
Avoid Giant lock for CORE mutex and semaphore flush and delete operations. Update #2555.
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r--cpukit/posix/src/semaphoredeletesupp.c22
-rw-r--r--cpukit/posix/src/semclose.c22
-rw-r--r--cpukit/posix/src/semdestroy.c27
-rw-r--r--cpukit/posix/src/semunlink.c9
4 files changed, 41 insertions, 39 deletions
diff --git a/cpukit/posix/src/semaphoredeletesupp.c b/cpukit/posix/src/semaphoredeletesupp.c
index 4394674699..7c23bb889d 100644
--- a/cpukit/posix/src/semaphoredeletesupp.c
+++ b/cpukit/posix/src/semaphoredeletesupp.c
@@ -18,25 +18,23 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <limits.h>
-
-#include <rtems/system.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
void _POSIX_Semaphore_Delete(
- POSIX_Semaphore_Control *the_semaphore
+ POSIX_Semaphore_Control *the_semaphore,
+ ISR_lock_Context *lock_context
)
{
if ( !the_semaphore->linked && !the_semaphore->open_count ) {
_Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
- _CORE_semaphore_Destroy( &the_semaphore->Semaphore, NULL, 0 );
+ _CORE_semaphore_Destroy(
+ &the_semaphore->Semaphore,
+ NULL,
+ 0,
+ lock_context
+ );
_POSIX_Semaphore_Free( the_semaphore );
+ } else {
+ _CORE_semaphore_Release( &the_semaphore->Semaphore, lock_context );
}
}
diff --git a/cpukit/posix/src/semclose.c b/cpukit/posix/src/semclose.c
index f134dc43a7..1468c7fb35 100644
--- a/cpukit/posix/src/semclose.c
+++ b/cpukit/posix/src/semclose.c
@@ -18,17 +18,9 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
#include <semaphore.h>
-#include <limits.h>
-#include <rtems/system.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
int sem_close(
sem_t *sem
@@ -36,15 +28,23 @@ int sem_close(
{
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
+ ISR_lock_Context lock_context;
_Objects_Allocator_lock();
- the_semaphore = _POSIX_Semaphore_Get( sem, &location );
+ the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
+ sem,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
+ _CORE_semaphore_Acquire_critical(
+ &the_semaphore->Semaphore,
+ &lock_context
+ );
the_semaphore->open_count -= 1;
- _POSIX_Semaphore_Delete( the_semaphore );
- _Objects_Put( &the_semaphore->Object );
+ _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
_Objects_Allocator_unlock();
return 0;
diff --git a/cpukit/posix/src/semdestroy.c b/cpukit/posix/src/semdestroy.c
index 896dece149..751169941b 100644
--- a/cpukit/posix/src/semdestroy.c
+++ b/cpukit/posix/src/semdestroy.c
@@ -18,17 +18,9 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
#include <semaphore.h>
-#include <limits.h>
-#include <rtems/system.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
int sem_destroy(
sem_t *sem
@@ -36,21 +28,30 @@ int sem_destroy(
{
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
+ ISR_lock_Context lock_context;
_Objects_Allocator_lock();
- the_semaphore = _POSIX_Semaphore_Get( sem, &location );
+ the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
+ sem,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
+ _CORE_semaphore_Acquire_critical(
+ &the_semaphore->Semaphore,
+ &lock_context
+ );
+
/*
* Undefined operation on a named semaphore. Release the object
* and fall to the EINVAL return at the bottom.
*/
- if ( the_semaphore->named == true ) {
- _Objects_Put( &the_semaphore->Object );
+ if ( the_semaphore->named ) {
+ _CORE_semaphore_Release( &the_semaphore->Semaphore, &lock_context );
} else {
- _POSIX_Semaphore_Delete( the_semaphore );
- _Objects_Put( &the_semaphore->Object );
+ _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
_Objects_Allocator_unlock();
return 0;
}
diff --git a/cpukit/posix/src/semunlink.c b/cpukit/posix/src/semunlink.c
index b8406185d4..665aa7337c 100644
--- a/cpukit/posix/src/semunlink.c
+++ b/cpukit/posix/src/semunlink.c
@@ -21,7 +21,6 @@
#include <semaphore.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
int sem_unlink(
const char *name
@@ -29,6 +28,7 @@ int sem_unlink(
{
POSIX_Semaphore_Control *the_semaphore;
Objects_Get_by_name_error error;
+ ISR_lock_Context lock_context;
_Objects_Allocator_lock();
@@ -38,9 +38,12 @@ int sem_unlink(
rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
}
- the_semaphore->linked = false;
_POSIX_Semaphore_Namespace_remove( the_semaphore );
- _POSIX_Semaphore_Delete( the_semaphore );
+
+ _ISR_lock_ISR_disable( &lock_context );
+ _CORE_semaphore_Acquire_critical( &the_semaphore->Semaphore, &lock_context );
+ the_semaphore->linked = false;
+ _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
_Objects_Allocator_unlock();
return 0;