diff options
Diffstat (limited to 'cpukit/rtems/src/semcreate.c')
-rw-r--r-- | cpukit/rtems/src/semcreate.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c index fb597d1cbd..5e93e02632 100644 --- a/cpukit/rtems/src/semcreate.c +++ b/cpukit/rtems/src/semcreate.c @@ -78,12 +78,19 @@ rtems_status_code rtems_semaphore_create( return RTEMS_MP_NOT_CONFIGURED; if ( _Attributes_Is_inherit_priority( attribute_set ) || - _Attributes_Is_priority_ceiling( attribute_set ) ) + _Attributes_Is_priority_ceiling( attribute_set ) || + _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) return RTEMS_NOT_DEFINED; } else #endif + if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) && + !( _Attributes_Is_binary_semaphore( attribute_set ) && + !_Attributes_Is_priority( attribute_set ) ) ) { + return RTEMS_NOT_DEFINED; + } + if ( _Attributes_Is_inherit_priority( attribute_set ) || _Attributes_Is_priority_ceiling( attribute_set ) ) { @@ -93,13 +100,22 @@ rtems_status_code rtems_semaphore_create( } - if ( _Attributes_Is_inherit_priority( attribute_set ) && - _Attributes_Is_priority_ceiling( attribute_set ) ) + if ( !_Attributes_Has_at_most_one_protocol( attribute_set ) ) return RTEMS_NOT_DEFINED; if ( !_Attributes_Is_counting_semaphore( attribute_set ) && ( count > 1 ) ) return RTEMS_INVALID_NUMBER; +#if !defined(RTEMS_SMP) + /* + * On uni-processor configurations the Multiprocessor Resource Sharing + * Protocol is equivalent to the Priority Ceiling Protocol. + */ + if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { + attribute_set |= RTEMS_PRIORITY_CEILING | RTEMS_PRIORITY; + } +#endif + the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { @@ -144,6 +160,22 @@ rtems_status_code rtems_semaphore_create( &the_semaphore_attr, count ); +#if defined(RTEMS_SMP) + } else if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { + MRSP_Status mrsp_status = _MRSP_Initialize( + &the_semaphore->Core_control.mrsp, + priority_ceiling, + _Thread_Get_executing(), + count != 1 + ); + + if ( mrsp_status != MRSP_SUCCESSFUL ) { + _Semaphore_Free( the_semaphore ); + _Objects_Allocator_unlock(); + + return _Semaphore_Translate_MRSP_status_code( mrsp_status ); + } +#endif } else { /* * It is either simple binary semaphore or a more powerful mutex |