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 ) ) if ( _Attributes_Is_inherit_priority( attribute_set ) )
return RTEMS_NOT_DEFINED; 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 ) && if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) &&
_Attributes_Is_priority( attribute_set ) ) ) _Attributes_Is_priority( attribute_set ) ) )

View File

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

View File

@@ -126,7 +126,8 @@ rtems_status_code rtems_semaphore_create(
if ( _Attributes_Is_inherit_priority( attribute_set ) ) if ( _Attributes_Is_inherit_priority( attribute_set ) )
return RTEMS_NOT_DEFINED; 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 ) && if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) &&
_Attributes_Is_priority( attribute_set ) ) ) _Attributes_Is_priority( attribute_set ) ) )

View File

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