Semaphore creation

Joel Sherrill joel.sherrill at OARcorp.com
Wed Feb 25 16:09:10 UTC 2009


Helder Silva wrote:
>
> Good Afternoon to All,
>
>  
>
> I would like to know your opinion in a topic we have found in RTEMS. 
> When using rtems_semaphore_create function to create a semaphore with 
> both priority ceiling and priority inherence, it returns successful. 
> Is this the correct behavior or should it give an error? Is this a 
> bug? In case this is not an error, what is the expected behavior of 
> RTEMS when using both protocols?
>
>  
>
I wonder consider it a bug with no expected behaviour.

But the actual behaviour is clear from the code:

  if ( !_Attributes_Is_counting_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 ) )
      the_mutex_attributes.discipline = 
CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
    else if ( _Attributes_Is_priority( attribute_set ) )

inheritance is checked first so it will be selected.

Try this:

$ cvs diff -u  semcreate.c
Index: semcreate.c
===================================================================
RCS file: /usr1/CVS/rtems/cpukit/rtems/src/semcreate.c,v
retrieving revision 1.17
diff -u -r1.17 semcreate.c
--- semcreate.c    6 Jan 2009 05:00:45 -0000    1.17
+++ semcreate.c    25 Feb 2009 16:08:39 -0000
@@ -111,6 +111,10 @@
 
   }
 
+  if ( _Attributes_Is_inherit_priority( attribute_set ) &&
+       _Attributes_Is_priority_ceiling( attribute_set ) )
+    return RTEMS_NOT_DEFINED;
+
   if ( !_Attributes_Is_counting_semaphore( attribute_set ) && ( count > 
1 ) )
     return RTEMS_INVALID_NUMBER;
 
Let me know if that works.
>
> Kind regards,
>
> Helder
>


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985





More information about the users mailing list