Changeset 31036f1d in rtems for cpukit/rtems


Ignore:
Timestamp:
07/18/22 07:41:39 (20 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
8a864bc6
Parents:
51ffa21
git-author:
Sebastian Huber <sebastian.huber@…> (07/18/22 07:41:39)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/28/22 05:52:59)
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/taskdelete.c

    r51ffa21 r31036f1d  
    4141
    4242#include <rtems/rtems/tasksimpl.h>
     43#include <rtems/rtems/statusimpl.h>
    4344#include <rtems/score/threadimpl.h>
    4445
     
    4849{
    4950  Thread_Control       *the_thread;
    50   Thread_Close_context  context;
     51  Thread_queue_Context  queue_context;
    5152  Per_CPU_Control      *cpu_self;
    5253  Thread_Control       *executing;
     54  Status_Control        status;
    5355
    54   _Thread_queue_Context_initialize( &context.Base );
    55   the_thread = _Thread_Get( id, &context.Base.Lock_context.Lock_context );
     56  _Thread_queue_Context_initialize( &queue_context );
     57  the_thread = _Thread_Get( id, &queue_context.Lock_context.Lock_context );
    5658
    5759  if ( the_thread == NULL ) {
     
    6870
    6971  if ( _Per_CPU_Is_ISR_in_progress( cpu_self ) ) {
    70     _ISR_lock_ISR_enable( &context.Base.Lock_context.Lock_context );
     72    _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
    7173    return RTEMS_CALLED_FROM_ISR;
    7274  }
     
    7577
    7678  if ( the_thread == executing ) {
    77     _ISR_lock_ISR_enable( &context.Base.Lock_context.Lock_context );
     79    _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
    7880
    7981    /*
     
    8284     */
    8385    _Thread_Exit( NULL, THREAD_LIFE_TERMINATING | THREAD_LIFE_DETACHED );
    84   } else {
    85     _Thread_Close( the_thread, executing, &context );
    8686  }
    8787
    88   return RTEMS_SUCCESSFUL;
     88  status = _Thread_Close( the_thread, executing, &queue_context );
     89  return _Status_Get( status );
    8990}
Note: See TracChangeset for help on using the changeset viewer.