mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 12:34:45 +00:00
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.
This commit is contained in:
@@ -64,9 +64,9 @@ CORE_mutex_Status _CORE_mutex_Initialize(
|
||||
the_mutex->holder_id = _Thread_Executing->Object.id;
|
||||
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
|
||||
_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
|
||||
Priority_Control ceiling = the_mutex->Attributes.priority_ceiling;
|
||||
|
||||
if ( _Thread_Executing->current_priority <
|
||||
the_mutex->Attributes.priority_ceiling )
|
||||
if ( _Thread_Executing->current_priority < ceiling )
|
||||
return CORE_MUTEX_STATUS_CEILING_VIOLATED;
|
||||
#ifdef __RTEMS_STRICT_ORDER_MUTEX__
|
||||
_Chain_Prepend_unprotected( &_Thread_Executing->lock_mutex,
|
||||
@@ -75,6 +75,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
|
||||
#endif
|
||||
|
||||
_Thread_Executing->resource_count++;
|
||||
_Thread_Change_priority( _Thread_Executing, ceiling, false );
|
||||
}
|
||||
} else {
|
||||
the_mutex->nest_count = 0;
|
||||
|
||||
@@ -24,6 +24,17 @@ rtems_task Task_1(
|
||||
rtems_task_argument arg
|
||||
);
|
||||
|
||||
static void assert_priority(rtems_task_priority expected)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_task_priority prio;
|
||||
|
||||
sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
rtems_test_assert(prio == expected);
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument ignored
|
||||
)
|
||||
@@ -33,6 +44,30 @@ rtems_task Init(
|
||||
|
||||
puts( "\n\n*** TEST " TEST_NAME " ***" );
|
||||
|
||||
/*
|
||||
* Verify that an initially locked priority ceiling mutex elevates the
|
||||
* priority of the creating task.
|
||||
*/
|
||||
|
||||
status = rtems_semaphore_create(
|
||||
rtems_build_name( 's','e','m','1' ),
|
||||
0,
|
||||
RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
|
||||
1,
|
||||
&Mutex_id
|
||||
);
|
||||
rtems_test_assert(status == RTEMS_SUCCESSFUL);
|
||||
|
||||
assert_priority(1);
|
||||
|
||||
status = rtems_semaphore_release(Mutex_id);
|
||||
rtems_test_assert(status == RTEMS_SUCCESSFUL);
|
||||
|
||||
assert_priority(TASK_PRIORITY);
|
||||
|
||||
status = rtems_semaphore_delete(Mutex_id);
|
||||
rtems_test_assert(status == RTEMS_SUCCESSFUL);
|
||||
|
||||
/*
|
||||
* Create binary semaphore (a.k.a. Mutex) with Priority Ceiling
|
||||
* attribute.
|
||||
|
||||
@@ -26,3 +26,5 @@ concepts:
|
||||
+ Verify the priority ceiling mutex getting released which results in a thread
|
||||
being unblocked and the unblocked thread's priority being elevated.
|
||||
|
||||
+ Verify that an initially locked priority ceiling mutex elevates the priority
|
||||
of the creating task.
|
||||
|
||||
Reference in New Issue
Block a user