added priority ceiling support

This commit is contained in:
Joel Sherrill
1996-06-03 21:08:26 +00:00
parent f39b01e676
commit 742b399c66
4 changed files with 126 additions and 66 deletions

View File

@@ -126,7 +126,8 @@ rtems_status_code rtems_semaphore_create(
if ( _Attributes_Is_inherit_priority( attribute_set ) )
return RTEMS_NOT_DEFINED;
} else if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
} else if ( _Attributes_Is_inherit_priority( attribute_set ) ||
_Attributes_Is_priority_ceiling( attribute_set ) ) {
if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) &&
_Attributes_Is_priority( attribute_set ) ) )

View File

@@ -144,14 +144,37 @@ void _CORE_mutex_Seize(
executing->Wait.id = id;
_ISR_Enable( level );
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) &&
the_mutex->holder->current_priority >
_Thread_Executing->current_priority ) {
_Thread_Change_priority(
the_mutex->holder, _Thread_Executing->current_priority );
switch ( the_mutex->Attributes.discipline ) {
case CORE_MUTEX_DISCIPLINES_FIFO:
case CORE_MUTEX_DISCIPLINES_PRIORITY:
case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
break;
case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
if ( the_mutex->holder->current_priority > executing->current_priority ) {
_Thread_Change_priority(
the_mutex->holder,
executing->current_priority
);
}
break;
}
_Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout );
if ( _Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_SUCCESSFUL ) {
switch ( the_mutex->Attributes.discipline ) {
case CORE_MUTEX_DISCIPLINES_FIFO:
case CORE_MUTEX_DISCIPLINES_PRIORITY:
case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
break;
case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
_Thread_Change_priority(
executing,
the_mutex->Attributes.priority_ceiling
);
break;
}
}
}
/*
@@ -180,6 +203,9 @@ CORE_mutex_Status _CORE_mutex_Surrender(
)
{
Thread_Control *the_thread;
Thread_Control *executing;
executing = _Thread_Executing;
if ( !_Objects_Are_ids_equal(
_Thread_Executing->Object.id, the_mutex->holder_id ) )
@@ -200,16 +226,21 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* mutex (i.e. resource) this task has.
*/
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) &&
_Thread_Executing->resource_count == 0 &&
_Thread_Executing->real_priority !=
_Thread_Executing->current_priority ) {
_Thread_Change_priority(
_Thread_Executing,
_Thread_Executing->real_priority
);
switch ( the_mutex->Attributes.discipline ) {
case CORE_MUTEX_DISCIPLINES_FIFO:
case CORE_MUTEX_DISCIPLINES_PRIORITY:
break;
case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
if ( executing->resource_count == 0 &&
executing->real_priority !=
executing->current_priority ) {
_Thread_Change_priority( executing, executing->real_priority );
}
break;
}
if ( ( the_thread = _Thread_queue_Dequeue( &the_mutex->Wait_queue ) ) ) {
if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {
@@ -228,9 +259,9 @@ CORE_mutex_Status _CORE_mutex_Surrender(
the_mutex->nest_count = 1;
/*
* No special action for priority inheritance because the_thread
* is guaranteed to be the highest priority thread waiting for
* the mutex.
* No special action for priority inheritance or priority ceiling
* because the_thread is guaranteed to be the highest priority
* thread waiting for the mutex.
*/
}
} else
@@ -259,11 +290,9 @@ void _CORE_mutex_Flush(
unsigned32 status
)
{
_Thread_queue_Flush(
&the_mutex->Wait_queue,
remote_extract_callout,
status
);
}

View File

@@ -126,7 +126,8 @@ rtems_status_code rtems_semaphore_create(
if ( _Attributes_Is_inherit_priority( attribute_set ) )
return RTEMS_NOT_DEFINED;
} else if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
} else if ( _Attributes_Is_inherit_priority( attribute_set ) ||
_Attributes_Is_priority_ceiling( attribute_set ) ) {
if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) &&
_Attributes_Is_priority( attribute_set ) ) )

View File

@@ -144,14 +144,37 @@ void _CORE_mutex_Seize(
executing->Wait.id = id;
_ISR_Enable( level );
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) &&
the_mutex->holder->current_priority >
_Thread_Executing->current_priority ) {
_Thread_Change_priority(
the_mutex->holder, _Thread_Executing->current_priority );
switch ( the_mutex->Attributes.discipline ) {
case CORE_MUTEX_DISCIPLINES_FIFO:
case CORE_MUTEX_DISCIPLINES_PRIORITY:
case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
break;
case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
if ( the_mutex->holder->current_priority > executing->current_priority ) {
_Thread_Change_priority(
the_mutex->holder,
executing->current_priority
);
}
break;
}
_Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout );
if ( _Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_SUCCESSFUL ) {
switch ( the_mutex->Attributes.discipline ) {
case CORE_MUTEX_DISCIPLINES_FIFO:
case CORE_MUTEX_DISCIPLINES_PRIORITY:
case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
break;
case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
_Thread_Change_priority(
executing,
the_mutex->Attributes.priority_ceiling
);
break;
}
}
}
/*
@@ -180,6 +203,9 @@ CORE_mutex_Status _CORE_mutex_Surrender(
)
{
Thread_Control *the_thread;
Thread_Control *executing;
executing = _Thread_Executing;
if ( !_Objects_Are_ids_equal(
_Thread_Executing->Object.id, the_mutex->holder_id ) )
@@ -200,16 +226,21 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* mutex (i.e. resource) this task has.
*/
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) &&
_Thread_Executing->resource_count == 0 &&
_Thread_Executing->real_priority !=
_Thread_Executing->current_priority ) {
_Thread_Change_priority(
_Thread_Executing,
_Thread_Executing->real_priority
);
switch ( the_mutex->Attributes.discipline ) {
case CORE_MUTEX_DISCIPLINES_FIFO:
case CORE_MUTEX_DISCIPLINES_PRIORITY:
break;
case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
if ( executing->resource_count == 0 &&
executing->real_priority !=
executing->current_priority ) {
_Thread_Change_priority( executing, executing->real_priority );
}
break;
}
if ( ( the_thread = _Thread_queue_Dequeue( &the_mutex->Wait_queue ) ) ) {
if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {
@@ -228,9 +259,9 @@ CORE_mutex_Status _CORE_mutex_Surrender(
the_mutex->nest_count = 1;
/*
* No special action for priority inheritance because the_thread
* is guaranteed to be the highest priority thread waiting for
* the mutex.
* No special action for priority inheritance or priority ceiling
* because the_thread is guaranteed to be the highest priority
* thread waiting for the mutex.
*/
}
} else
@@ -259,11 +290,9 @@ void _CORE_mutex_Flush(
unsigned32 status
)
{
_Thread_queue_Flush(
&the_mutex->Wait_queue,
remote_extract_callout,
status
);
}