summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/semcreate.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-26 22:29:56 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 16:16:22 +0200
commit09c5ca4cb4f30ba9e0c3c3915a70af7ff3916ec0 (patch)
tree70b4e6167e38902fce2ffebbf343df6ac8a6fe06 /cpukit/rtems/src/semcreate.c
parentscore: Add semaphore variants (diff)
downloadrtems-09c5ca4cb4f30ba9e0c3c3915a70af7ff3916ec0.tar.bz2
score: Simplify CORE mutex
Remove superfluous support for simple binary semaphores. With this we can get rid of the CORE_MUTEX_NESTING_BLOCKS variant.
Diffstat (limited to 'cpukit/rtems/src/semcreate.c')
-rw-r--r--cpukit/rtems/src/semcreate.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c
index be8f9f5d3b..455182bd90 100644
--- a/cpukit/rtems/src/semcreate.c
+++ b/cpukit/rtems/src/semcreate.c
@@ -143,9 +143,6 @@ rtems_status_code rtems_semaphore_create(
the_semaphore->discipline = SEMAPHORE_DISCIPLINE_FIFO;
}
- /*
- * Initialize it as a counting semaphore.
- */
if ( _Attributes_Is_counting_semaphore( attribute_set ) ) {
the_semaphore->variant = SEMAPHORE_VARIANT_COUNTING;
_CORE_semaphore_Initialize(
@@ -153,6 +150,13 @@ rtems_status_code rtems_semaphore_create(
count
);
status = STATUS_SUCCESSFUL;
+ } else if ( _Attributes_Is_simple_binary_semaphore( attribute_set ) ) {
+ the_semaphore->variant = SEMAPHORE_VARIANT_SIMPLE_BINARY;
+ _CORE_semaphore_Initialize(
+ &the_semaphore->Core_control.semaphore,
+ count != 0
+ );
+ status = STATUS_SUCCESSFUL;
#if defined(RTEMS_SMP)
} else if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
the_semaphore->variant = SEMAPHORE_VARIANT_MRSP;
@@ -166,6 +170,8 @@ rtems_status_code rtems_semaphore_create(
} else {
the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX;
+ _Assert( _Attributes_Is_binary_semaphore( attribute_set ) );
+
/*
* It is either simple binary semaphore or a more powerful mutex
* style binary semaphore. This is the mutex style.
@@ -175,25 +181,20 @@ rtems_status_code rtems_semaphore_create(
else
the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_FIFO;
- if ( _Attributes_Is_binary_semaphore( attribute_set ) ) {
- the_mutex_attr.priority_ceiling = _RTEMS_tasks_Priority_to_Core(
- priority_ceiling
- );
- the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
- the_mutex_attr.only_owner_release = false;
-
- if ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) {
- if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
- the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
- the_mutex_attr.only_owner_release = true;
- } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
- the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
- the_mutex_attr.only_owner_release = true;
- }
+ the_mutex_attr.priority_ceiling = _RTEMS_tasks_Priority_to_Core(
+ priority_ceiling
+ );
+ the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
+ the_mutex_attr.only_owner_release = false;
+
+ if ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) {
+ if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
+ the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
+ the_mutex_attr.only_owner_release = true;
+ } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
+ the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
+ the_mutex_attr.only_owner_release = true;
}
- } else /* must be simple binary semaphore */ {
- the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS;
- the_mutex_attr.only_owner_release = false;
}
status = _CORE_mutex_Initialize(