Changeset 33e250c9 in rtems for cpukit/rtems


Ignore:
Timestamp:
May 27, 2016, 1:41:41 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0b713f89
Parents:
5a598ac
git-author:
Sebastian Huber <sebastian.huber@…> (05/27/16 13:41:41)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/30/16 14:16:23)
Message:

score: Rework CORE priority ceiling mutex

Rework seize and surrender methods to use CORE_ceiling_mutex_Control.
This eliminates CORE_mutex_Disciplines.

Location:
cpukit/rtems
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/include/rtems/rtems/semimpl.h

    r5a598ac r33e250c9  
    3434typedef enum {
    3535  SEMAPHORE_VARIANT_MUTEX,
     36  SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING,
    3637  SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL,
    3738  SEMAPHORE_VARIANT_SIMPLE_BINARY,
  • cpukit/rtems/src/semcreate.c

    r5a598ac r33e250c9  
    137137#endif
    138138
     139  priority_ceiling = _RTEMS_tasks_Priority_to_Core( priority_ceiling );
    139140  the_semaphore->attribute_set = attribute_set;
    140141  executing = _Thread_Get_executing();
     
    170171    );
    171172#endif
    172   } else if (
    173     !_Attributes_Is_inherit_priority( attribute_set )
    174       && !_Attributes_Is_priority_ceiling( attribute_set )
    175   ) {
     173  } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
     174    _Assert( _Attributes_Is_binary_semaphore( attribute_set ) );
     175    the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING;
     176    _CORE_ceiling_mutex_Initialize(
     177      &the_semaphore->Core_control.Mutex,
     178      priority_ceiling
     179    );
     180
     181    if ( count == 0 ) {
     182      Thread_queue_Context queue_context;
     183
     184      _Thread_queue_Context_initialize( &queue_context );
     185      _ISR_lock_ISR_disable( &queue_context.Lock_context );
     186      _CORE_mutex_Acquire_critical(
     187        &the_semaphore->Core_control.Mutex.Recursive.Mutex,
     188        &queue_context
     189      );
     190      status = _CORE_ceiling_mutex_Set_owner(
     191        &the_semaphore->Core_control.Mutex,
     192        executing,
     193        &queue_context
     194      );
     195    } else {
     196      status = STATUS_SUCCESSFUL;
     197    }
     198  } else if ( !_Attributes_Is_inherit_priority( attribute_set ) ) {
    176199    _Assert( _Attributes_Is_binary_semaphore( attribute_set ) );
    177200    the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL;
     
    190213  } else {
    191214    _Assert( _Attributes_Is_binary_semaphore( attribute_set ) );
     215    _Assert( _Attributes_Is_inherit_priority( attribute_set ) );
    192216    the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX;
    193217
    194     the_mutex_attr.priority_ceiling =
    195       _RTEMS_tasks_Priority_to_Core( priority_ceiling );
    196218    the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
    197 
    198     if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
    199       the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
    200     } else {
    201       _Assert( _Attributes_Is_priority_ceiling( attribute_set ) );
    202       the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
    203     }
    204219
    205220    status = _CORE_mutex_Initialize(
  • cpukit/rtems/src/semdelete.c

    r5a598ac r33e250c9  
    5252  switch ( the_semaphore->variant ) {
    5353    case SEMAPHORE_VARIANT_MUTEX:
     54    case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
    5455    case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
    5556      if (
     
    9899      _Assert(
    99100        the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX
     101          || the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING
    100102          || the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
    101103          || the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
  • cpukit/rtems/src/semflush.c

    r5a598ac r33e250c9  
    5959      _Assert(
    6060        the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX
     61          || the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING
    6162          || the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
    6263          || the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
  • cpukit/rtems/src/semobtain.c

    r5a598ac r33e250c9  
    9191      );
    9292      break;
     93    case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
     94      status = _CORE_ceiling_mutex_Seize(
     95        &the_semaphore->Core_control.Mutex,
     96        executing,
     97        wait,
     98        timeout,
     99        _CORE_recursive_mutex_Seize_nested,
     100        &queue_context
     101      );
     102      break;
    93103    case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
    94104      status = _CORE_recursive_mutex_Seize_no_protocol(
  • cpukit/rtems/src/semrelease.c

    r5a598ac r33e250c9  
    2929  Semaphore_Control    *the_semaphore;
    3030  Thread_queue_Context  queue_context;
     31  Thread_Control       *executing;
    3132  Status_Control        status;
    3233
     
    4142  }
    4243
     44  executing = _Thread_Executing;
     45
    4346  _Thread_queue_Context_set_MP_callout(
    4447    &queue_context,
     
    5154      status = _MRSP_Surrender(
    5255        &the_semaphore->Core_control.mrsp,
    53         _Thread_Executing,
     56        executing,
    5457        &queue_context
    5558      );
     
    5962      status = _CORE_mutex_Surrender(
    6063        &the_semaphore->Core_control.Mutex.Recursive.Mutex,
     64        &queue_context
     65      );
     66      break;
     67    case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
     68      status = _CORE_ceiling_mutex_Surrender(
     69        &the_semaphore->Core_control.Mutex,
     70        executing,
    6171        &queue_context
    6272      );
  • cpukit/rtems/src/semsetpriority.c

    r5a598ac r33e250c9  
    1818
    1919#include <rtems/rtems/semimpl.h>
    20 #include <rtems/rtems/attrimpl.h>
    2120#include <rtems/rtems/tasksimpl.h>
    2221#include <rtems/score/schedulerimpl.h>
     
    3029)
    3130{
    32   rtems_status_code   sc;
    33   rtems_attribute     attribute_set = the_semaphore->attribute_set;
    34   rtems_task_priority old_priority;
     31  rtems_status_code    sc;
     32  rtems_task_priority  old_priority;
     33#if defined(RTEMS_SMP)
     34  MRSP_Control        *mrsp;
     35  uint32_t             scheduler_index;
     36#endif
    3537
    3638  new_priority = _RTEMS_tasks_Priority_to_Core( new_priority );
    3739
     40  switch ( the_semaphore->variant ) {
     41    case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
     42      _CORE_mutex_Acquire_critical(
     43        &the_semaphore->Core_control.Mutex.Recursive.Mutex,
     44        queue_context
     45      );
     46
     47      old_priority = the_semaphore->Core_control.Mutex.priority_ceiling;
     48
     49      if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
     50        the_semaphore->Core_control.Mutex.priority_ceiling = new_priority;
     51      }
     52
     53      _CORE_mutex_Release(
     54        &the_semaphore->Core_control.Mutex.Recursive.Mutex,
     55        queue_context
     56      );
     57      sc = RTEMS_SUCCESSFUL;
     58      break;
    3859#if defined(RTEMS_SMP)
    39   if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
    40     MRSP_Control *mrsp = &the_semaphore->Core_control.mrsp;
    41     uint32_t scheduler_index = _Scheduler_Get_index_by_id( scheduler_id );
     60    case SEMAPHORE_VARIANT_MRSP:
     61      mrsp = &the_semaphore->Core_control.mrsp;
     62      scheduler_index = _Scheduler_Get_index_by_id( scheduler_id );
    4263
    43     _MRSP_Acquire_critical( mrsp, queue_context );
     64      _MRSP_Acquire_critical( mrsp, queue_context );
    4465
    45     old_priority = _MRSP_Get_ceiling_priority( mrsp, scheduler_index );
     66      old_priority = _MRSP_Get_ceiling_priority( mrsp, scheduler_index );
    4667
    47     if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
    48       _MRSP_Set_ceiling_priority( mrsp, scheduler_index, new_priority );
    49     }
     68      if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
     69        _MRSP_Set_ceiling_priority( mrsp, scheduler_index, new_priority );
     70      }
    5071
    51     _MRSP_Release( mrsp, queue_context );
    52 
    53     sc = RTEMS_SUCCESSFUL;
    54   } else
     72      _MRSP_Release( mrsp, queue_context );
     73      sc = RTEMS_SUCCESSFUL;
     74      break;
    5575#endif
    56   if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
    57     CORE_mutex_Control *mutex;
    58 
    59     mutex = &the_semaphore->Core_control.Mutex.Recursive.Mutex;
    60     _CORE_mutex_Acquire_critical( mutex, queue_context );
    61 
    62     old_priority = mutex->Attributes.priority_ceiling;
    63 
    64     if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
    65       mutex->Attributes.priority_ceiling = new_priority;
    66     }
    67 
    68     _CORE_mutex_Release( mutex, queue_context );
    69 
    70     sc = RTEMS_SUCCESSFUL;
    71   } else {
    72     _ISR_lock_ISR_enable( &queue_context->Lock_context );
    73 
    74     old_priority = 0;
    75 
    76     sc = RTEMS_NOT_DEFINED;
     76    default:
     77      _Assert(
     78        the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX
     79          || the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
     80          || the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
     81          || the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING
     82      );
     83      _ISR_lock_ISR_enable( &queue_context->Lock_context );
     84      old_priority = 0;
     85      sc = RTEMS_NOT_DEFINED;
     86      break;
    7787  }
    7888
Note: See TracChangeset for help on using the changeset viewer.