summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 06:59:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 16:16:23 +0200
commit0b713f8940d90b480f8cd36663c11aa0688587d8 (patch)
treec71a01748c3749e0243518b486c2bb32a1c67df1 /cpukit/rtems
parentscore: Rework CORE priority ceiling mutex (diff)
downloadrtems-0b713f8940d90b480f8cd36663c11aa0688587d8.tar.bz2
score: Rework CORE inherit priority mutex
Provide dedicated seize and surrender methods for inherit priority mutexes. This eliminates CORE_mutex_Attributes.
Diffstat (limited to '')
-rw-r--r--cpukit/rtems/include/rtems/rtems/sem.h7
-rw-r--r--cpukit/rtems/include/rtems/rtems/semimpl.h2
-rw-r--r--cpukit/rtems/src/semcreate.c35
-rw-r--r--cpukit/rtems/src/semdelete.c4
-rw-r--r--cpukit/rtems/src/semflush.c2
-rw-r--r--cpukit/rtems/src/semobtain.c7
-rw-r--r--cpukit/rtems/src/semrelease.c7
-rw-r--r--cpukit/rtems/src/semsetpriority.c2
8 files changed, 28 insertions, 38 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/sem.h b/cpukit/rtems/include/rtems/rtems/sem.h
index 220b0e392e..725d9999e5 100644
--- a/cpukit/rtems/include/rtems/rtems/sem.h
+++ b/cpukit/rtems/include/rtems/rtems/sem.h
@@ -113,13 +113,6 @@ typedef struct {
#if defined(RTEMS_MULTIPROCESSING)
unsigned int is_global : 1;
#endif
-
- /**
- * This is the Classic API attribute provided to the create directive.
- * It is translated into behavioral attributes on the SuperCore Semaphore
- * or Mutex instance.
- */
- rtems_attribute attribute_set;
} Semaphore_Control;
/**
diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h
index 9d82a12b3c..3259916d52 100644
--- a/cpukit/rtems/include/rtems/rtems/semimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/semimpl.h
@@ -32,7 +32,7 @@ extern "C" {
* Must be in synchronization with Semaphore_Control::variant.
*/
typedef enum {
- SEMAPHORE_VARIANT_MUTEX,
+ SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY,
SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING,
SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL,
SEMAPHORE_VARIANT_SIMPLE_BINARY,
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c
index 720fb63a0d..943d787246 100644
--- a/cpukit/rtems/src/semcreate.c
+++ b/cpukit/rtems/src/semcreate.c
@@ -61,10 +61,9 @@ rtems_status_code rtems_semaphore_create(
rtems_id *id
)
{
- Semaphore_Control *the_semaphore;
- CORE_mutex_Attributes the_mutex_attr;
- Thread_Control *executing;
- Status_Control status;
+ Semaphore_Control *the_semaphore;
+ Thread_Control *executing;
+ Status_Control status;
if ( !rtems_is_name_valid( name ) )
return RTEMS_INVALID_NAME;
@@ -137,7 +136,6 @@ rtems_status_code rtems_semaphore_create(
#endif
priority_ceiling = _RTEMS_tasks_Priority_to_Core( priority_ceiling );
- the_semaphore->attribute_set = attribute_set;
executing = _Thread_Get_executing();
if ( _Attributes_Is_priority( attribute_set ) ) {
@@ -195,9 +193,15 @@ rtems_status_code rtems_semaphore_create(
} else {
status = STATUS_SUCCESSFUL;
}
- } else if ( !_Attributes_Is_inherit_priority( attribute_set ) ) {
+ } else {
_Assert( _Attributes_Is_binary_semaphore( attribute_set ) );
- the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL;
+
+ if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
+ the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY;
+ } else {
+ the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL;
+ }
+
_CORE_recursive_mutex_Initialize(
&the_semaphore->Core_control.Mutex.Recursive
);
@@ -207,22 +211,13 @@ rtems_status_code rtems_semaphore_create(
&the_semaphore->Core_control.Mutex.Recursive.Mutex,
executing
);
+
+ if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
+ ++executing->resource_count;
+ }
}
status = STATUS_SUCCESSFUL;
- } else {
- _Assert( _Attributes_Is_binary_semaphore( attribute_set ) );
- _Assert( _Attributes_Is_inherit_priority( attribute_set ) );
- the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX;
-
- the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
-
- status = _CORE_mutex_Initialize(
- &the_semaphore->Core_control.Mutex.Recursive.Mutex,
- executing,
- &the_mutex_attr,
- count != 1
- );
}
if ( status != STATUS_SUCCESSFUL ) {
diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index a38d761320..db8c8008e5 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -50,7 +50,7 @@ rtems_status_code rtems_semaphore_delete(
);
switch ( the_semaphore->variant ) {
- case SEMAPHORE_VARIANT_MUTEX:
+ case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
if (
@@ -97,7 +97,7 @@ rtems_status_code rtems_semaphore_delete(
#endif
default:
_Assert(
- the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX
+ the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
|| the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING
|| the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
|| the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c
index 17c589f588..3970d22fc7 100644
--- a/cpukit/rtems/src/semflush.c
+++ b/cpukit/rtems/src/semflush.c
@@ -57,7 +57,7 @@ rtems_status_code rtems_semaphore_flush( rtems_id id )
#endif
default:
_Assert(
- the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX
+ the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
|| the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING
|| the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
|| the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 44507abefb..80bb199dc2 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -81,12 +81,13 @@ rtems_status_code rtems_semaphore_obtain(
);
break;
#endif
- case SEMAPHORE_VARIANT_MUTEX:
- status = _CORE_mutex_Seize(
- &the_semaphore->Core_control.Mutex.Recursive.Mutex,
+ case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
+ status = _CORE_recursive_mutex_Seize(
+ &the_semaphore->Core_control.Mutex.Recursive,
executing,
wait,
timeout,
+ _CORE_recursive_mutex_Seize_nested,
&queue_context
);
break;
diff --git a/cpukit/rtems/src/semrelease.c b/cpukit/rtems/src/semrelease.c
index d92197b8f4..0808a2a475 100644
--- a/cpukit/rtems/src/semrelease.c
+++ b/cpukit/rtems/src/semrelease.c
@@ -58,9 +58,10 @@ rtems_status_code rtems_semaphore_release( rtems_id id )
);
break;
#endif
- case SEMAPHORE_VARIANT_MUTEX:
- status = _CORE_mutex_Surrender(
- &the_semaphore->Core_control.Mutex.Recursive.Mutex,
+ case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
+ status = _CORE_recursive_mutex_Surrender(
+ &the_semaphore->Core_control.Mutex.Recursive,
+ executing,
&queue_context
);
break;
diff --git a/cpukit/rtems/src/semsetpriority.c b/cpukit/rtems/src/semsetpriority.c
index 57a5368353..14aa34eae4 100644
--- a/cpukit/rtems/src/semsetpriority.c
+++ b/cpukit/rtems/src/semsetpriority.c
@@ -75,7 +75,7 @@ static rtems_status_code _Semaphore_Set_priority(
#endif
default:
_Assert(
- the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX
+ the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
|| the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
|| the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
|| the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING