Changeset 4edf348c in rtems


Ignore:
Timestamp:
May 22, 2014, 7:31:13 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
0af322c
Parents:
decff888
git-author:
Sebastian Huber <sebastian.huber@…> (05/22/14 07:31:13)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/23/14 06:57:32)
Message:

score: PR2179: Fix initially locked PCP mutexes

Elevate the priority of the creating task to the ceiling priority in
case a semaphore is created as initially locked.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/coremutex.c

    rdecff888 r4edf348c  
    4444    if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
    4545         _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
     46      Priority_Control ceiling = the_mutex->Attributes.priority_ceiling;
    4647
    47       if ( executing->current_priority <
    48              the_mutex->Attributes.priority_ceiling )
    49        return CORE_MUTEX_STATUS_CEILING_VIOLATED;
     48      /*
     49       * The mutex initialization is only protected by the allocator lock in
     50       * general.  Disable thread dispatching before the priority check to
     51       * prevent interference with priority inheritance.
     52       */
     53      _Thread_Disable_dispatch();
     54
     55      if ( executing->current_priority < ceiling ) {
     56        _Thread_Enable_dispatch();
     57        return CORE_MUTEX_STATUS_CEILING_VIOLATED;
     58      }
     59
    5060#ifdef __RTEMS_STRICT_ORDER_MUTEX__
    5161       _Chain_Prepend_unprotected( &executing->lock_mutex,
     
    5565
    5666      executing->resource_count++;
     67
     68      _Thread_Change_priority( executing, ceiling, false );
     69      _Thread_Enable_dispatch();
    5770    }
    5871  } else {
  • testsuites/sptests/sp65/init.c

    rdecff888 r4edf348c  
    2929#endif
    3030
     31static void assert_priority(rtems_task_priority expected)
     32{
     33  rtems_status_code sc;
     34  rtems_task_priority prio;
     35
     36  sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio);
     37  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     38
     39  rtems_test_assert(prio == expected);
     40}
     41
    3142rtems_task Init(
    3243  rtems_task_argument ignored
     
    3748
    3849  TEST_BEGIN();
     50
     51  /*
     52   * Verify that an initially locked priority ceiling mutex elevates the
     53   * priority of the creating task.
     54   */
     55
     56  status = rtems_semaphore_create(
     57    rtems_build_name( 's','e','m','1' ),
     58    0,
     59    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
     60    1,
     61    &Mutex_id
     62  );
     63  rtems_test_assert(status == RTEMS_SUCCESSFUL);
     64
     65  assert_priority(1);
     66
     67  status = rtems_semaphore_release(Mutex_id);
     68  rtems_test_assert(status == RTEMS_SUCCESSFUL);
     69
     70  assert_priority(TASK_PRIORITY);
     71
     72  status = rtems_semaphore_delete(Mutex_id);
     73  rtems_test_assert(status == RTEMS_SUCCESSFUL);
    3974
    4075  /*
Note: See TracChangeset for help on using the changeset viewer.