[RTEMS Project] #4679: Use priority inheritance for thread join

RTEMS trac trac at rtems.org
Tue Jul 19 06:44:07 UTC 2022


#4679: Use priority inheritance for thread join
-----------------------------+------------------------------
 Reporter:  Sebastian Huber  |       Owner:  Sebastian Huber
     Type:  enhancement      |      Status:  assigned
 Priority:  normal           |   Milestone:  6.1
Component:  score            |     Version:  6
 Severity:  normal           |  Resolution:
 Keywords:                   |  Blocked By:
 Blocking:                   |
-----------------------------+------------------------------
Description changed by Sebastian Huber:

Old description:

> Threads may join the thread termination of another thread using the
> `pthread_join()` or `rtems_task_delete()` directives. Currently, the
> thread join operation uses a special case priority boosting mechanism:
> {{{#!c
> static void _Thread_Raise_real_priority(
>   Thread_Control   *the_thread,
>   Priority_Control  priority
> )
> {
>   Thread_queue_Context queue_context;
>
>   _Thread_queue_Context_initialize( &queue_context );
>   _Thread_queue_Context_clear_priority_updates( &queue_context );
>   _Thread_Wait_acquire( the_thread, &queue_context );
>
>   if ( priority < the_thread->Real_priority.priority ) {
>     _Thread_Priority_change(
>       the_thread,
>       &the_thread->Real_priority,
>       priority,
>       PRIORITY_GROUP_LAST,
>       &queue_context
>     );
>   }
>
>   _Thread_Wait_release( the_thread, &queue_context );
>   _Thread_Priority_update( &queue_context );
> }
> }}}
> The problem is that this approach is not transitive, it does not account
> for priority adjustments of the calling task while waiting for the join,
> clustered scheduling is not supported, and deadlocks are not detected.
> All these problems are fixed by using a priority inheritance thread queue
> for the join operation.

New description:

 Threads may join the thread termination of another thread using the
 `pthread_join()` or `rtems_task_delete()` directives. Currently, the
 thread cancel operation uses a special case priority boosting mechanism:
 {{{#!c
 static void _Thread_Raise_real_priority(
   Thread_Control   *the_thread,
   Priority_Control  priority
 )
 {
   Thread_queue_Context queue_context;

   _Thread_queue_Context_initialize( &queue_context );
   _Thread_queue_Context_clear_priority_updates( &queue_context );
   _Thread_Wait_acquire( the_thread, &queue_context );

   if ( priority < the_thread->Real_priority.priority ) {
     _Thread_Priority_change(
       the_thread,
       &the_thread->Real_priority,
       priority,
       PRIORITY_GROUP_LAST,
       &queue_context
     );
   }

   _Thread_Wait_release( the_thread, &queue_context );
   _Thread_Priority_update( &queue_context );
 }
 }}}
 The problem is that this approach is not transitive, it does not account
 for priority adjustments of the calling task while waiting for the join,
 clustered scheduling is not supported, and deadlocks are not detected. All
 these problems are fixed by using a priority inheritance thread queue for
 the join operation.

--

--
Ticket URL: <http://devel.rtems.org/ticket/4679#comment:1>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list