Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#4679 closed enhancement (fixed)

Use priority inheritance for thread join

Reported by: Sebastian Huber Owned by: Sebastian Huber
Priority: normal Milestone: 6.1
Component: score Version: 6
Severity: normal Keywords: qualification
Cc: Blocked By:
Blocking:

Description (last modified by Sebastian Huber)

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:

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.

Change History (5)

comment:1 Changed on 07/19/22 at 06:44:07 by Sebastian Huber

Description: modified (diff)

comment:2 Changed on 07/28/22 at 05:36:09 by Sebastian Huber <sebastian.huber@…>

In [changeset:"81fd510a5cd92998f0a3ec65ce88d057e33da91d/rtems-docs" 81fd510/rtems-docs]:

c-user: Document task life states

Update #4679.

comment:3 Changed on 07/28/22 at 05:36:11 by Sebastian Huber <sebastian.huber@…>

In [changeset:"f4377b4479efdefc37f0e84c88568318eb89a9d2/rtems-docs" f4377b4/rtems-docs]:

c-user: Document new rtems_task_delete() behaviour

Update #4679.

comment:4 Changed on 07/28/22 at 05:45:19 by Sebastian Huber <sebastian.huber@…>

Resolution: fixed
Status: assignedclosed

In [changeset:"31036f1dc8a963fb0bc3fc103f63028988314fea/rtems" 31036f1d/rtems]:

score: Use priority inheritance for thread join

Threads may join the thread termination of another thread using the
pthread_join() or rtems_task_delete() directives. The thread cancel operation
used a special case priority boosting mechanism implemented by
_Thread_Raise_real_priority(). The problem was that this approach

  • is not transitive,
  • does not account for priority adjustments of the calling task while waiting for the join,
  • does not support clustered scheduling, and
  • does not detect deadlocks.

All these problems are fixed by using a priority inheritance thread queue for
the join operation.

Close #4679.

comment:5 Changed on 05/02/23 at 08:18:35 by Sebastian Huber

Keywords: qualification added
Note: See TracTickets for help on using tickets.