summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-25 16:49:53 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 16:16:21 +0200
commit3ca6e6185131ab804b2831ab308b44b4b174856a (patch)
treefc0adfd014751cbf3dd5170a98f8b25562c07a5b /cpukit/rtems
parentscore: Use thread queue lock for MrsP (diff)
downloadrtems-3ca6e6185131ab804b2831ab308b44b4b174856a.tar.bz2
rtems: Simplify rtems_semaphore_delete()
Diffstat (limited to '')
-rw-r--r--cpukit/rtems/include/rtems/rtems/sem.h5
-rw-r--r--cpukit/rtems/src/semdelete.c46
-rw-r--r--cpukit/rtems/src/semobtain.c5
3 files changed, 28 insertions, 28 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/sem.h b/cpukit/rtems/include/rtems/rtems/sem.h
index b3950a2939..2c99f57deb 100644
--- a/cpukit/rtems/include/rtems/rtems/sem.h
+++ b/cpukit/rtems/include/rtems/rtems/sem.h
@@ -75,6 +75,11 @@ typedef struct {
*/
union {
/**
+ * @brief The thread queue present in all other variants.
+ */
+ Thread_queue_Control Wait_queue;
+
+ /**
* This is the SuperCore Mutex instance associated with this Classic
* API Semaphore instance.
*/
diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index 13f2bf0268..16889cd6b6 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -29,6 +29,7 @@ rtems_status_code rtems_semaphore_delete(
Semaphore_Control *the_semaphore;
Thread_queue_Context queue_context;
rtems_attribute attribute_set;
+ Status_Control status;
_Objects_Allocator_lock();
the_semaphore = _Semaphore_Get( id, &queue_context );
@@ -47,47 +48,36 @@ rtems_status_code rtems_semaphore_delete(
attribute_set = the_semaphore->attribute_set;
+ _Thread_queue_Acquire_critical(
+ &the_semaphore->Core_control.Wait_queue,
+ &queue_context.Lock_context
+ );
+
#if defined(RTEMS_SMP)
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
- Status_Control status;
-
- _MRSP_Acquire_critical(
- &the_semaphore->Core_control.mrsp,
- &queue_context
- );
status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp );
- if ( status != STATUS_SUCCESSFUL ) {
- _MRSP_Release(
- &the_semaphore->Core_control.mrsp,
- &queue_context
- );
- _Objects_Allocator_unlock();
- return _Status_Get( status );
- }
} else
#endif
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
- _CORE_mutex_Acquire_critical(
- &the_semaphore->Core_control.mutex,
- &queue_context
- );
-
if (
_CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex )
&& !_Attributes_Is_simple_binary_semaphore( attribute_set )
) {
- _CORE_mutex_Release(
- &the_semaphore->Core_control.mutex,
- &queue_context
- );
- _Objects_Allocator_unlock();
- return RTEMS_RESOURCE_IN_USE;
+ status = STATUS_RESOURCE_IN_USE;
+ } else {
+ status = STATUS_SUCCESSFUL;
}
} else {
- _CORE_semaphore_Acquire_critical(
- &the_semaphore->Core_control.semaphore,
- &queue_context
+ status = STATUS_SUCCESSFUL;
+ }
+
+ if ( status != STATUS_SUCCESSFUL ) {
+ _Thread_queue_Release(
+ &the_semaphore->Core_control.Wait_queue,
+ &queue_context.Lock_context
);
+ _Objects_Allocator_unlock();
+ return _Status_Get( status );
}
_Objects_Close( &_Semaphore_Information, &the_semaphore->Object );
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 1a73120655..8cb195c5a2 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -25,6 +25,11 @@
THREAD_QUEUE_OBJECT_ASSERT(
Semaphore_Control,
+ Core_control.Wait_queue
+);
+
+THREAD_QUEUE_OBJECT_ASSERT(
+ Semaphore_Control,
Core_control.mutex.Wait_queue
);