summaryrefslogtreecommitdiffstats
path: root/c/src/exec
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/exec')
-rw-r--r--c/src/exec/rtems/include/rtems/rtems/attr.h6
-rw-r--r--c/src/exec/rtems/inline/rtems/rtems/attr.inl17
-rw-r--r--c/src/exec/rtems/macros/rtems/rtems/attr.inl9
-rw-r--r--c/src/exec/rtems/src/semcreate.c9
-rw-r--r--c/src/exec/rtems/src/semtranslatereturncode.c2
-rw-r--r--c/src/exec/score/src/coremutexseize.c1
-rw-r--r--c/src/exec/score/src/coremutexsurrender.c31
7 files changed, 58 insertions, 17 deletions
diff --git a/c/src/exec/rtems/include/rtems/rtems/attr.h b/c/src/exec/rtems/include/rtems/rtems/attr.h
index cf9b073360..20d8eebe01 100644
--- a/c/src/exec/rtems/include/rtems/rtems/attr.h
+++ b/c/src/exec/rtems/include/rtems/rtems/attr.h
@@ -46,8 +46,12 @@ typedef unsigned32 rtems_attribute;
#define RTEMS_NO_PRIORITY_CEILING 0x00000000
#define RTEMS_PRIORITY_CEILING 0x00000040
+#define RTEMS_NESTING_ALLOWED 0x00000000
+#define RTEMS_NO_NESTING_ALLOWED 0x00000080
+
#define RTEMS_APPLICATION_TASK 0x00000000
-#define RTEMS_SYSTEM_TASK 0x00000080
+#define RTEMS_SYSTEM_TASK 0x00000100
+
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
#define ATTRIBUTES_NOT_SUPPORTED 0
diff --git a/c/src/exec/rtems/inline/rtems/rtems/attr.inl b/c/src/exec/rtems/inline/rtems/rtems/attr.inl
index 0f9e3bbbf9..94a8052648 100644
--- a/c/src/exec/rtems/inline/rtems/rtems/attr.inl
+++ b/c/src/exec/rtems/inline/rtems/rtems/attr.inl
@@ -158,6 +158,23 @@ RTEMS_INLINE_ROUTINE boolean _Attributes_Is_priority_ceiling(
/*PAGE
*
+ * _Attributes_Is_nesting_allowed
+ *
+ * DESCRIPTION:
+ *
+ * This function returns TRUE if the nesting allowed attribute
+ * is enabled in the attribute_set and FALSE otherwise.
+ */
+
+RTEMS_INLINE_ROUTINE boolean _Attributes_Is_nesting_allowed(
+ rtems_attribute attribute_set
+)
+{
+ return ( !(attribute_set & RTEMS_NO_NESTING_ALLOWED) );
+}
+
+/*PAGE
+ *
* _Attributes_Is_system_task
*
* DESCRIPTION:
diff --git a/c/src/exec/rtems/macros/rtems/rtems/attr.inl b/c/src/exec/rtems/macros/rtems/rtems/attr.inl
index 035a6b8bc5..516752b7d1 100644
--- a/c/src/exec/rtems/macros/rtems/rtems/attr.inl
+++ b/c/src/exec/rtems/macros/rtems/rtems/attr.inl
@@ -90,6 +90,15 @@
/*PAGE
*
+ * _Attributes_Is_nesting_allowed
+ *
+ */
+
+#define _Attributes_Is_nesting_allowed( _attribute_set ) \
+ ( !((_attribute_set) & RTEMS_NO_NESTING_ALLOWED) )
+
+/*PAGE
+ *
* _Attributes_Is_system_task
*
*/
diff --git a/c/src/exec/rtems/src/semcreate.c b/c/src/exec/rtems/src/semcreate.c
index 84a960f5b2..a63814acfe 100644
--- a/c/src/exec/rtems/src/semcreate.c
+++ b/c/src/exec/rtems/src/semcreate.c
@@ -129,14 +129,17 @@ rtems_status_code rtems_semaphore_create(
if ( _Attributes_Is_binary_semaphore( attribute_set ) ) {
if ( _Attributes_Is_inherit_priority( attribute_set ) )
the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
- else if (_Attributes_Is_priority_ceiling( attribute_set ) )
+ else if ( _Attributes_Is_priority_ceiling( attribute_set ) )
the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
- else if (_Attributes_Is_priority( attribute_set ) )
+ else if ( _Attributes_Is_priority( attribute_set ) )
the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY;
else
the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO;
- the_mutex_attributes.allow_nesting = TRUE;
+ if ( _Attributes_Is_nesting_allowed( attribute_set ) )
+ the_mutex_attributes.allow_nesting = TRUE;
+ else
+ the_mutex_attributes.allow_nesting = FALSE;
/* Add priority ceiling code here ????? */
diff --git a/c/src/exec/rtems/src/semtranslatereturncode.c b/c/src/exec/rtems/src/semtranslatereturncode.c
index 0f9bf7d3f5..adae1df600 100644
--- a/c/src/exec/rtems/src/semtranslatereturncode.c
+++ b/c/src/exec/rtems/src/semtranslatereturncode.c
@@ -67,7 +67,7 @@ rtems_status_code _Semaphore_Translate_core_mutex_return_code (
case CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT:
return RTEMS_UNSATISFIED;
case CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED:
- return RTEMS_INTERNAL_ERROR;
+ return RTEMS_UNSATISFIED;
case CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE:
return RTEMS_NOT_OWNER_OF_RESOURCE;
case CORE_MUTEX_WAS_DELETED:
diff --git a/c/src/exec/score/src/coremutexseize.c b/c/src/exec/score/src/coremutexseize.c
index 0fe5fd288a..c2a70da762 100644
--- a/c/src/exec/score/src/coremutexseize.c
+++ b/c/src/exec/score/src/coremutexseize.c
@@ -90,6 +90,7 @@ void _CORE_mutex_Seize(
);
}
}
+ executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
return;
}
diff --git a/c/src/exec/score/src/coremutexsurrender.c b/c/src/exec/score/src/coremutexsurrender.c
index fbd75fd8e8..7f5fc2e911 100644
--- a/c/src/exec/score/src/coremutexsurrender.c
+++ b/c/src/exec/score/src/coremutexsurrender.c
@@ -61,24 +61,31 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* must be released by the thread which acquired them.
*/
- if ( !_Objects_Are_ids_equal(
- _Thread_Executing->Object.id, the_mutex->holder_id ) ) {
-
- switch ( the_mutex->Attributes.discipline ) {
- case CORE_MUTEX_DISCIPLINES_FIFO:
- case CORE_MUTEX_DISCIPLINES_PRIORITY:
- break;
- case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
- case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
- return( CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE );
- break;
+ if ( the_mutex->Attributes.allow_nesting ) {
+ if ( !_Objects_Are_ids_equal(
+ _Thread_Executing->Object.id, the_mutex->holder_id ) ) {
+
+ switch ( the_mutex->Attributes.discipline ) {
+ case CORE_MUTEX_DISCIPLINES_FIFO:
+ case CORE_MUTEX_DISCIPLINES_PRIORITY:
+ break;
+ case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
+ case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
+ return( CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE );
+ break;
+ }
}
}
+ /* XXX already unlocked -- not right status */
+
+ if ( !the_mutex->nest_count )
+ return( CORE_MUTEX_STATUS_SUCCESSFUL );
+
the_mutex->nest_count--;
if ( the_mutex->nest_count != 0 )
- return( CORE_MUTEX_STATUS_SUCCESSFUL );
+ return( CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED );
_Thread_Executing->resource_count--;
the_mutex->holder = NULL;