Changeset 8fcafdd5 in rtems


Ignore:
Timestamp:
May 21, 2014, 8:33:43 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
5fd4e35f
Parents:
9f058fb
git-author:
Sebastian Huber <sebastian.huber@…> (05/21/14 08:33:43)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/28/14 08:50:41)
Message:

score: Multiprocessor Resource Sharing Protocol

Add basic support for the Multiprocessor Resource Sharing Protocol
(MrsP).

The Multiprocessor Resource Sharing Protocol (MrsP) is defined in A.
Burns and A.J. Wellings, A Schedulability Compatible Multiprocessor
Resource Sharing Protocol - MrsP, Proceedings of the 25th Euromicro
Conference on Real-Time Systems (ECRTS 2013), July 2013. It is a
generalization of the Priority Ceiling Protocol to SMP systems. Each
MrsP semaphore uses a ceiling priority per scheduler instance. These
ceiling priorities can be specified with rtems_semaphore_set_priority().
A task obtaining or owning a MrsP semaphore will execute with the
ceiling priority for its scheduler instance as specified by the MrsP
semaphore object. Tasks waiting to get ownership of a MrsP semaphore
will not relinquish the processor voluntarily. In case the owner of a
MrsP semaphore gets preempted it can ask all tasks waiting for this
semaphore to help out and temporarily borrow the right to execute on one
of their assigned processors.

The help out feature is not implemented with this patch.

Files:
11 added
21 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/Makefile.am

    r9f058fb r8fcafdd5  
    207207librtems_a_SOURCES += src/semtranslatereturncode.c
    208208librtems_a_SOURCES += src/semdata.c
     209librtems_a_SOURCES += src/semsetpriority.c
    209210
    210211## EVENT_C_FILES
  • cpukit/rtems/include/rtems/rtems/attr.h

    r9f058fb r8fcafdd5  
    140140#define RTEMS_PRIORITY_CEILING        0x00000080
    141141
     142/**
     143 *  This attribute constant indicates that the Classic API Semaphore instance
     144 *  created will NOT use the Multiprocessor Resource Sharing Protocol.
     145 */
     146#define RTEMS_NO_MULTIPROCESSOR_RESOURCE_SHARING 0x00000000
     147
     148/**
     149 *  This attribute constant indicates that the Classic API Semaphore instance
     150 *  created will use the Multiprocessor Resource Sharing Protocol.
     151 *
     152 *  @note The semaphore instance must be a binary semaphore.
     153 */
     154#define RTEMS_MULTIPROCESSOR_RESOURCE_SHARING 0x00000100
     155
    142156/******************** RTEMS Barrier Specific Attributes ********************/
    143157
  • cpukit/rtems/include/rtems/rtems/attrimpl.h

    r9f058fb r8fcafdd5  
    186186
    187187/**
     188 * @brief Returns true if the attribute set has at most one protocol, and false
     189 * otherwise.
     190 *
     191 * The protocols are RTEMS_INHERIT_PRIORITY, RTEMS_PRIORITY_CEILING and
     192 * RTEMS_MULTIPROCESSOR_RESOURCE_SHARING.
     193 */
     194RTEMS_INLINE_ROUTINE bool _Attributes_Has_at_most_one_protocol(
     195  rtems_attribute attribute_set
     196)
     197{
     198  attribute_set &= RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY_CEILING
     199    | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING;
     200
     201  return ( attribute_set & ( attribute_set - 1 ) ) == 0;
     202}
     203
     204/**
    188205 *  @brief Checks if the priority ceiling attribute
    189206 *  is enabled in the attribute_set
     
    200217
    201218/**
     219 *  @brief Checks if the Multiprocessor Resource Sharing Protocol attribute
     220 *  is enabled in the attribute_set
     221 *
     222 *  This function returns TRUE if the Multiprocessor Resource Sharing Protocol
     223 *  attribute is enabled in the attribute_set and FALSE otherwise.
     224 */
     225RTEMS_INLINE_ROUTINE bool _Attributes_Is_multiprocessor_resource_sharing(
     226  rtems_attribute attribute_set
     227)
     228{
     229  return ( attribute_set & RTEMS_MULTIPROCESSOR_RESOURCE_SHARING ) != 0;
     230}
     231
     232/**
    202233 *  @brief Checks if the barrier automatic release
    203234 *  attribute is enabled in the attribute_set
  • cpukit/rtems/include/rtems/rtems/sem.h

    r9f058fb r8fcafdd5  
    3939#include <rtems/score/object.h>
    4040#include <rtems/score/coresem.h>
     41#include <rtems/score/mrsp.h>
    4142
    4243#ifdef __cplusplus
     
    8990     */
    9091    CORE_semaphore_Control semaphore;
     92
     93#if defined(RTEMS_SMP)
     94    MRSP_Control mrsp;
     95#endif
    9196  } Core_control;
    9297}   Semaphore_Control;
     
    209214);
    210215
     216/**
     217 * @brief Sets the priority value with respect to the specified scheduler of a
     218 * semaphore.
     219 *
     220 * The special priority value @ref RTEMS_CURRENT_PRIORITY can be used to get
     221 * the current priority value without changing it.
     222 *
     223 * The interpretation of the priority value depends on the protocol of the
     224 * semaphore object.
     225 *
     226 * - The Multiprocessor Resource Sharing Protocol needs a ceiling priority per
     227 *   scheduler instance.  This operation can be used to specify these priority
     228 *   values.
     229 * - For the Priority Ceiling Protocol the ceiling priority is used with this
     230 *   operation.
     231 * - For other protocols this operation is not defined.
     232 *
     233 * @param[in] semaphore_id Identifier of the semaphore.
     234 * @param[in] scheduler_id Identifier of the scheduler.
     235 * @param[in] new_priority The new priority value.  Use
     236 * @ref RTEMS_CURRENT_PRIORITY to not set a new priority and only get the
     237 * current priority.
     238 * @param[out] old_priority Reference to store the old priority value.
     239 *
     240 * @retval RTEMS_SUCCESSFUL Successful operation.
     241 * @retval RTEMS_INVALID_ID Invalid semaphore or scheduler identifier.
     242 * @retval RTEMS_INVALID_ADDRESS The old priority reference is @c NULL.
     243 * @retval RTEMS_INVALID_PRIORITY The new priority value is invalid.
     244 * @retval RTEMS_NOT_DEFINED The set priority operation is not defined for the
     245 * protocol of this semaphore object.
     246 * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Not supported for remote semaphores.
     247 *
     248 * @see rtems_scheduler_ident() and rtems_task_set_priority().
     249 */
     250rtems_status_code rtems_semaphore_set_priority(
     251  rtems_id             semaphore_id,
     252  rtems_id             scheduler_id,
     253  rtems_task_priority  new_priority,
     254  rtems_task_priority *old_priority
     255);
     256
    211257/**@}*/
    212258
  • cpukit/rtems/include/rtems/rtems/semimpl.h

    r9f058fb r8fcafdd5  
    2121#include <rtems/score/coremuteximpl.h>
    2222#include <rtems/score/coresemimpl.h>
     23#include <rtems/score/mrspimpl.h>
    2324
    2425#ifdef __cplusplus
     
    9293  return _Semaphore_Translate_core_mutex_return_code_[status];
    9394}
     95
     96#if defined(RTEMS_SMP)
     97RTEMS_INLINE_ROUTINE rtems_status_code
     98_Semaphore_Translate_MRSP_status_code( MRSP_Status mrsp_status )
     99{
     100  return (rtems_status_code) mrsp_status;
     101}
     102#endif
    94103
    95104/**
  • cpukit/rtems/src/semcreate.c

    r9f058fb r8fcafdd5  
    7979
    8080    if ( _Attributes_Is_inherit_priority( attribute_set ) ||
    81          _Attributes_Is_priority_ceiling( attribute_set ) )
     81         _Attributes_Is_priority_ceiling( attribute_set ) ||
     82         _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) )
    8283      return RTEMS_NOT_DEFINED;
    8384
    8485  } else
    8586#endif
     87
     88  if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) &&
     89       !( _Attributes_Is_binary_semaphore( attribute_set ) &&
     90         !_Attributes_Is_priority( attribute_set ) ) ) {
     91    return RTEMS_NOT_DEFINED;
     92  }
    8693
    8794  if ( _Attributes_Is_inherit_priority( attribute_set ) ||
     
    94101  }
    95102
    96   if ( _Attributes_Is_inherit_priority( attribute_set ) &&
    97        _Attributes_Is_priority_ceiling( attribute_set ) )
     103  if ( !_Attributes_Has_at_most_one_protocol( attribute_set ) )
    98104    return RTEMS_NOT_DEFINED;
    99105
    100106  if ( !_Attributes_Is_counting_semaphore( attribute_set ) && ( count > 1 ) )
    101107    return RTEMS_INVALID_NUMBER;
     108
     109#if !defined(RTEMS_SMP)
     110  /*
     111   * On uni-processor configurations the Multiprocessor Resource Sharing
     112   * Protocol is equivalent to the Priority Ceiling Protocol.
     113   */
     114  if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     115    attribute_set |= RTEMS_PRIORITY_CEILING | RTEMS_PRIORITY;
     116  }
     117#endif
    102118
    103119  the_semaphore = _Semaphore_Allocate();
     
    145161      count
    146162    );
     163#if defined(RTEMS_SMP)
     164  } else if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     165    MRSP_Status mrsp_status = _MRSP_Initialize(
     166      &the_semaphore->Core_control.mrsp,
     167      priority_ceiling,
     168      _Thread_Get_executing(),
     169      count != 1
     170    );
     171
     172    if ( mrsp_status != MRSP_SUCCESSFUL ) {
     173      _Semaphore_Free( the_semaphore );
     174      _Objects_Allocator_unlock();
     175
     176      return _Semaphore_Translate_MRSP_status_code( mrsp_status );
     177    }
     178#endif
    147179  } else {
    148180    /*
  • cpukit/rtems/src/semdelete.c

    r9f058fb r8fcafdd5  
    4444  Semaphore_Control          *the_semaphore;
    4545  Objects_Locations           location;
     46  rtems_attribute             attribute_set;
    4647
    4748  _Objects_Allocator_lock();
     
    5152
    5253    case OBJECTS_LOCAL:
    53       if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
     54      attribute_set = the_semaphore->attribute_set;
     55#if defined(RTEMS_SMP)
     56      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     57        MRSP_Status mrsp_status = _MRSP_Destroy(
     58          &the_semaphore->Core_control.mrsp
     59        );
     60        if ( mrsp_status != MRSP_SUCCESSFUL ) {
     61          _Objects_Put( &the_semaphore->Object );
     62          _Objects_Allocator_unlock();
     63          return _Semaphore_Translate_MRSP_status_code( mrsp_status );
     64        }
     65      } else
     66#endif
     67      if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
    5468        if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) &&
    55              !_Attributes_Is_simple_binary_semaphore(
    56                  the_semaphore->attribute_set ) ) {
     69             !_Attributes_Is_simple_binary_semaphore( attribute_set ) ) {
    5770          _Objects_Put( &the_semaphore->Object );
    5871          _Objects_Allocator_unlock();
     
    7588
    7689#if defined(RTEMS_MULTIPROCESSING)
    77       if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) {
     90      if ( _Attributes_Is_global( attribute_set ) ) {
    7891
    7992        _Objects_MP_Close( &_Semaphore_Information, the_semaphore->Object.id );
  • cpukit/rtems/src/semflush.c

    r9f058fb r8fcafdd5  
    4444  Semaphore_Control          *the_semaphore;
    4545  Objects_Locations           location;
     46  rtems_attribute             attribute_set;
    4647
    4748  the_semaphore = _Semaphore_Get( id, &location );
     
    4950
    5051    case OBJECTS_LOCAL:
    51       if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
     52      attribute_set = the_semaphore->attribute_set;
     53#if defined(RTEMS_SMP)
     54      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     55        _Objects_Put( &the_semaphore->Object );
     56        return RTEMS_NOT_DEFINED;
     57      } else
     58#endif
     59      if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
    5260        _CORE_mutex_Flush(
    5361          &the_semaphore->Core_control.mutex,
  • cpukit/rtems/src/semobtain.c

    r9f058fb r8fcafdd5  
    4242  ISR_Level                       level;
    4343  Thread_Control                 *executing;
     44  rtems_attribute                 attribute_set;
    4445  bool                            wait;
    4546
     
    4950    case OBJECTS_LOCAL:
    5051      executing = _Thread_Executing;
     52      attribute_set = the_semaphore->attribute_set;
    5153      wait = !_Options_Is_no_wait( option_set );
    52       if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
     54#if defined(RTEMS_SMP)
     55      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     56        MRSP_Status mrsp_status;
     57
     58        _ISR_Enable( level );
     59        mrsp_status = _MRSP_Obtain(
     60          &the_semaphore->Core_control.mrsp,
     61          executing,
     62          wait,
     63          timeout
     64        );
     65        _Objects_Put_for_get_isr_disable( &the_semaphore->Object );
     66        return _Semaphore_Translate_MRSP_status_code( mrsp_status );
     67      } else
     68#endif
     69      if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
    5370        _CORE_mutex_Seize(
    5471          &the_semaphore->Core_control.mutex,
  • cpukit/rtems/src/semrelease.c

    r9f058fb r8fcafdd5  
    7474  CORE_mutex_Status           mutex_status;
    7575  CORE_semaphore_Status       semaphore_status;
     76  rtems_attribute             attribute_set;
    7677
    7778  the_semaphore = _Semaphore_Get( id, &location );
     
    7980
    8081    case OBJECTS_LOCAL:
    81       if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
     82      attribute_set = the_semaphore->attribute_set;
     83#if defined(RTEMS_SMP)
     84      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     85        MRSP_Status mrsp_status = _MRSP_Release(
     86          &the_semaphore->Core_control.mrsp,
     87          _Thread_Get_executing()
     88        );
     89        _Objects_Put( &the_semaphore->Object );
     90        return _Semaphore_Translate_MRSP_status_code( mrsp_status );
     91      } else
     92#endif
     93      if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
    8294        mutex_status = _CORE_mutex_Surrender(
    8395          &the_semaphore->Core_control.mutex,
  • cpukit/sapi/include/confdefs.h

    r9f058fb r8fcafdd5  
    17931793      CONFIGURE_NETWORKING_SEMAPHORES)
    17941794
     1795  #if !defined(RTEMS_SMP) || \
     1796    !defined(CONFIGURE_MAXIMUM_MRSP_SEMAPHORES)
     1797    #define CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES 0
     1798  #else
     1799    #define CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES \
     1800      CONFIGURE_MAXIMUM_MRSP_SEMAPHORES * \
     1801        _Configure_From_workspace( \
     1802          RTEMS_ARRAY_SIZE(_Scheduler_Table) * sizeof(Priority_Control) \
     1803        )
     1804  #endif
     1805
    17951806  /*
    17961807   * If there are no user or support semaphores defined, then we can assume
     
    18011812  #else
    18021813    #define CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) \
    1803       _Configure_Object_RAM(_semaphores, sizeof(Semaphore_Control) )
     1814      _Configure_Object_RAM(_semaphores, sizeof(Semaphore_Control) ) + \
     1815        CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES
    18041816  #endif
    18051817
  • cpukit/score/Makefile.am

    r9f058fb r8fcafdd5  
    4040include_rtems_score_HEADERS += include/rtems/score/isrlock.h
    4141include_rtems_score_HEADERS += include/rtems/score/freechain.h
     42include_rtems_score_HEADERS += include/rtems/score/mrsp.h
     43include_rtems_score_HEADERS += include/rtems/score/mrspimpl.h
    4244include_rtems_score_HEADERS += include/rtems/score/object.h
    4345include_rtems_score_HEADERS += include/rtems/score/objectimpl.h
  • cpukit/score/include/rtems/score/schedulerimpl.h

    r9f058fb r8fcafdd5  
    618618}
    619619
     620RTEMS_INLINE_ROUTINE bool _Scheduler_Is_id_valid( Objects_Id id )
     621{
     622  const Scheduler_Control *scheduler;
     623  bool ok = _Scheduler_Get_by_id( id, &scheduler );
     624
     625  (void) scheduler;
     626
     627  return ok;
     628}
     629
    620630RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index(
    621631  const Scheduler_Control *scheduler
  • cpukit/score/preinstall.am

    r9f058fb r8fcafdd5  
    139139        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/freechain.h
    140140PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/freechain.h
     141
     142$(PROJECT_INCLUDE)/rtems/score/mrsp.h: include/rtems/score/mrsp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     143        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mrsp.h
     144PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mrsp.h
     145
     146$(PROJECT_INCLUDE)/rtems/score/mrspimpl.h: include/rtems/score/mrspimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     147        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mrspimpl.h
     148PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mrspimpl.h
    141149
    142150$(PROJECT_INCLUDE)/rtems/score/object.h: include/rtems/score/object.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
  • doc/user/Makefile.am

    r9f058fb r8fcafdd5  
    9797
    9898barrier.texi: barrier.t
    99         $(BMENU2) -p "Semaphore Manager SEMAPHORE_FLUSH - Unblock all tasks waiting on a semaphore" \
     99        $(BMENU2) -p "Semaphore Manager SEMAPHORE_SET_PRIORITY - Set priority by scheduler for a semaphore" \
    100100            -u "Top" \
    101101            -n "Message Manager" < $< > $@
  • doc/user/conf.t

    r9f058fb r8fcafdd5  
    685685@subheading NOTES:
    686686This object class can be configured in unlimited allocation mode.
     687
     688@c
     689@c === CONFIGURE_MAXIMUM_MRSP_SEMAPHORES ===
     690@c
     691@subsection Specify Maximum Classic API Semaphores usable with MrsP
     692
     693@findex CONFIGURE_MAXIMUM_MRSP_SEMAPHORES
     694
     695@table @b
     696@item CONSTANT:
     697@code{CONFIGURE_MAXIMUM_MRSP_SEMAPHORES}
     698
     699@item DATA TYPE:
     700Unsigned integer (@code{uint32_t}).
     701
     702@item RANGE:
     703Zero or positive.
     704
     705@item DEFAULT VALUE:
     706The default value is 0.
     707
     708@end table
     709
     710@subheading DESCRIPTION:
     711@code{CONFIGURE_MAXIMUM_MRSP_SEMAPHORES} is the
     712maximum number of Classic API Semaphores using the Multiprocessor Resource
     713Sharing Protocol (MrsP) that can be concurrently active.
     714
     715@subheading NOTES:
     716This configuration option is only used on SMP configurations.  On uni-processor
     717configurations the Priority Ceiling Protocol is used for MrsP semaphores and
     718thus no extra memory is necessary.
    687719
    688720@c
  • doc/user/sem.t

    r9f058fb r8fcafdd5  
    2525@item @code{@value{DIRPREFIX}semaphore_release} - Release a semaphore
    2626@item @code{@value{DIRPREFIX}semaphore_flush} - Unblock all tasks waiting on a semaphore
     27@item @code{@value{DIRPREFIX}semaphore_set_priority} - Set priority by
     28scheduler for a semaphore
    2729@end itemize
    2830
     
    174176be restored to the normal value.
    175177
     178@subsection Multiprocessor Resource Sharing Protocol
     179
     180The Multiprocessor Resource Sharing Protocol (MrsP) is defined in @cite{A.
     181Burns and A.J.  Wellings, A Schedulability Compatible Multiprocessor Resource
     182Sharing Protocol - MrsP, Proceedings of the 25th Euromicro Conference on
     183Real-Time Systems (ECRTS 2013), July 2013}.  It is a generalization of the
     184Priority Ceiling Protocol to SMP systems.  Each MrsP semaphore uses a ceiling
     185priority per scheduler instance.  These ceiling priorities can be specified
     186with @code{rtems_semaphore_set_priority()}.  A task obtaining or owning a MrsP
     187semaphore will execute with the ceiling priority for its scheduler instance as
     188specified by the MrsP semaphore object.  Tasks waiting to get ownership of a
     189MrsP semaphore will not relinquish the processor voluntarily.  In case the
     190owner of a MrsP semaphore gets preempted it can ask all tasks waiting for this
     191semaphore to help out and temporarily borrow the right to execute on one of
     192their assigned processors.
     193
    176194@subsection Building a Semaphore Attribute Set
    177195
     
    199217@item @code{@value{RPREFIX}INHERIT_PRIORITY} - use priority inheritance
    200218
    201 @item @code{@value{RPREFIX}PRIORITY_CEILING} - use priority ceiling
    202 
    203219@item @code{@value{RPREFIX}NO_PRIORITY_CEILING} - do not use priority
    204220ceiling (default)
     221
     222@item @code{@value{RPREFIX}PRIORITY_CEILING} - use priority ceiling
     223
     224@item @code{@value{RPREFIX}NO_MULTIPROCESSOR_RESOURCE_SHARING} - do not use
     225Multiprocessor Resource Sharing Protocol (default)
     226
     227@item @code{@value{RPREFIX}MULTIPROCESSOR_RESOURCE_SHARING} - use
     228Multiprocessor Resource Sharing Protocol
    205229
    206230@item @code{@value{RPREFIX}LOCAL} - local semaphore (default)
     
    490514@item @code{@value{RPREFIX}INHERIT_PRIORITY} - use priority inheritance
    491515
    492 @item @code{@value{RPREFIX}PRIORITY_CEILING} - use priority ceiling
    493 
    494516@item @code{@value{RPREFIX}NO_PRIORITY_CEILING} - do not use priority
    495517ceiling (default)
     518
     519@item @code{@value{RPREFIX}PRIORITY_CEILING} - use priority ceiling
     520
     521@item @code{@value{RPREFIX}NO_MULTIPROCESSOR_RESOURCE_SHARING} - do not use
     522Multiprocessor Resource Sharing Protocol (default)
     523
     524@item @code{@value{RPREFIX}MULTIPROCESSOR_RESOURCE_SHARING} - use
     525Multiprocessor Resource Sharing Protocol
    496526
    497527@item @code{@value{RPREFIX}LOCAL} - local semaphore (default)
     
    512542The total number of global objects, including semaphores, is limited by
    513543the maximum_global_objects field in the Configuration Table.
     544
     545It is not allowed to create an initially locked MrsP semaphore and the
     546@code{@value{RPREFIX}INVALID_NUMBER} status code will be returned on SMP
     547configurations in this case.  This prevents lock order reversal problems with
     548the allocator mutex.
    514549
    515550@c
     
    736771this directive.
    737772
     773It is not allowed to obtain a MrsP semaphore more than once by one task at a
     774time (nested access) and the @code{@value{RPREFIX}UNSATISFIED} status code will
     775be returned on SMP configurations in this case.
     776
    738777@c
    739778@c
     
    832871@code{@value{RPREFIX}SUCCESSFUL} - semaphore released successfully@*
    833872@code{@value{RPREFIX}INVALID_ID} - invalid semaphore id@*
     873@code{@value{RPREFIX}NOT_DEFINED} - operation not defined for the protocol of
     874the semaphore@*
    834875@code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - not supported for remote semaphores
    835876
     
    859900unblocked, and the proxy used to represent the task is reclaimed.
    860901
    861 
     902It is not allowed to flush a MrsP semaphore and the
     903@code{@value{RPREFIX}NOT_DEFINED} status code will be returned on SMP
     904configurations in this case.
     905
     906@c
     907@c
     908@c
     909@page
     910@subsection SEMAPHORE_SET_PRIORITY - Set priority by scheduler for a semaphore
     911
     912@cindex set priority by scheduler for a semaphore
     913
     914@subheading CALLING SEQUENCE:
     915
     916@ifset is-C
     917@findex rtems_semaphore_set_priority
     918@example
     919rtems_status_code rtems_semaphore_set_priority(
     920  rtems_id             semaphore_id,
     921  rtems_id             scheduler_id,
     922  rtems_task_priority  new_priority,
     923  rtems_task_priority *old_priority
     924);
     925@end example
     926@end ifset
     927
     928@subheading DIRECTIVE STATUS CODES:
     929@code{@value{RPREFIX}SUCCESSFUL} - successful operation@*
     930@code{@value{RPREFIX}INVALID_ID} - invalid semaphore or scheduler id@*
     931@code{@value{RPREFIX}INVALID_ADDRESS} - @code{old_priority} is NULL@*
     932@code{@value{RPREFIX}INVALID_PRIORITY} - invalid new priority value@*
     933@code{@value{RPREFIX}NOT_DEFINED} - operation not defined for the protocol of
     934the semaphore@*
     935@code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - not supported for remote semaphores
     936
     937@subheading DESCRIPTION:
     938
     939This directive sets the priority value with respect to the specified scheduler
     940of a semaphore.
     941
     942The special priority value @code{RTEMS_CURRENT_PRIORITY} can be used to get the
     943current priority value without changing it.
     944
     945The interpretation of the priority value depends on the protocol of the
     946semaphore object.
     947
     948@itemize @bullet
     949@item The Multiprocessor Resource Sharing Protocol needs a ceiling priority per
     950scheduler instance.  This operation can be used to specify these priority
     951values.
     952@item For the Priority Ceiling Protocol the ceiling priority is used with this
     953operation.
     954@item For other protocols this operation is not defined.
     955@end itemize
     956
     957@subheading EXAMPLE:
     958
     959@example
     960@group
     961#include <assert.h>
     962#include <stdlib.h>
     963
     964#include <rtems.h>
     965
     966#define SCHED_A rtems_build_name(' ', ' ', ' ', 'A')
     967
     968#define SCHED_B rtems_build_name(' ', ' ', ' ', 'B')
     969
     970static void Init(rtems_task_argument arg)
     971@{
     972  rtems_status_code   sc;
     973  rtems_id            semaphore_id;
     974  rtems_id            scheduler_a_id;
     975  rtems_id            scheduler_b_id;
     976  rtems_task_priority prio;
     977
     978  /* Get the scheduler identifiers */
     979
     980  sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id);
     981  assert(sc == RTEMS_SUCCESSFUL);
     982
     983  sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
     984  assert(sc == RTEMS_SUCCESSFUL);
     985
     986  /* Create a MrsP semaphore object */
     987
     988  sc = rtems_semaphore_create(
     989    rtems_build_name('M', 'R', 'S', 'P'),
     990    1,
     991    RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
     992      | RTEMS_BINARY_SEMAPHORE,
     993    1,
     994    &semaphore_id
     995  );
     996  assert(sc == RTEMS_SUCCESSFUL);
     997
     998  /*
     999   * The ceiling priority values per scheduler are equal to the value specified
     1000   * for object creation.
     1001   */
     1002
     1003  prio = RTEMS_CURRENT_PRIORITY;
     1004  sc = rtems_semaphore_set_priority(semaphore_id, scheduler_a_id, prio, &prio);
     1005  assert(sc == RTEMS_SUCCESSFUL);
     1006  assert(prio == 1);
     1007
     1008  /* Check the old value and set a new ceiling priority for scheduler B */
     1009
     1010  prio = 2;
     1011  sc = rtems_semaphore_set_priority(semaphore_id, scheduler_b_id, prio, &prio);
     1012  assert(sc == RTEMS_SUCCESSFUL);
     1013  assert(prio == 1);
     1014
     1015  /* Check the ceiling priority values */
     1016
     1017  prio = RTEMS_CURRENT_PRIORITY;
     1018  sc = rtems_semaphore_set_priority(semaphore_id, scheduler_a_id, prio, &prio);
     1019  assert(sc == RTEMS_SUCCESSFUL);
     1020  assert(prio == 1);
     1021
     1022  prio = RTEMS_CURRENT_PRIORITY;
     1023  sc = rtems_semaphore_set_priority(semaphore_id, scheduler_b_id, prio, &prio);
     1024  assert(sc == RTEMS_SUCCESSFUL);
     1025  assert(prio == 2);
     1026
     1027  sc = rtems_semaphore_delete(semaphore_id);
     1028  assert(sc == RTEMS_SUCCESSFUL);
     1029
     1030  exit(0);
     1031@}
     1032
     1033#define CONFIGURE_SMP_APPLICATION
     1034
     1035#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     1036#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     1037
     1038#define CONFIGURE_MAXIMUM_TASKS 1
     1039#define CONFIGURE_MAXIMUM_SEMAPHORES 1
     1040#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
     1041
     1042#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 2
     1043
     1044#define CONFIGURE_SCHEDULER_SIMPLE_SMP
     1045
     1046#include <rtems/scheduler.h>
     1047
     1048RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP(a);
     1049
     1050RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP(b);
     1051
     1052#define CONFIGURE_SCHEDULER_CONTROLS \
     1053  RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP(a, SCHED_A), \
     1054  RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP(b, SCHED_B)
     1055
     1056#define CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS \
     1057  RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
     1058  RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
     1059
     1060#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     1061
     1062#define CONFIGURE_INIT
     1063
     1064#include <rtems/confdefs.h>
     1065@end group
     1066@end example
  • testsuites/smptests/Makefile.am

    r9f058fb r8fcafdd5  
    2323SUBDIRS += smpmigration01
    2424SUBDIRS += smpmigration02
     25SUBDIRS += smpmrsp01
    2526SUBDIRS += smpscheduler01
    2627SUBDIRS += smpscheduler02
  • testsuites/smptests/configure.ac

    r9f058fb r8fcafdd5  
    7878smpmigration01/Makefile
    7979smpmigration02/Makefile
     80smpmrsp01/Makefile
    8081smppsxaffinity01/Makefile
    8182smppsxaffinity02/Makefile
  • testsuites/sptests/Makefile.am

    r9f058fb r8fcafdd5  
    3838_SUBDIRS += sp29
    3939endif
     40_SUBDIRS += spmrsp01
    4041_SUBDIRS += spscheduler01
    4142_SUBDIRS += spprofiling01
  • testsuites/sptests/configure.ac

    r9f058fb r8fcafdd5  
    4141# Explicitly list all Makefiles here
    4242AC_CONFIG_FILES([Makefile
     43spmrsp01/Makefile
    4344spscheduler01/Makefile
    4445spfatal28/Makefile
Note: See TracChangeset for help on using the changeset viewer.