[PATCH v2] score: Fix _Thread_Change_priority()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Mar 18 20:43:21 UTC 2015


----- Joel Sherrill <joel.sherrill at oarcorp.com> schrieb:
> 
> 
> On 3/18/2015 3:20 PM, Sebastian Huber wrote:
[...]
> > diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
> > index d61dfb8..6ee65f5 100644
> > --- a/cpukit/score/src/threadchangepriority.c
> > +++ b/cpukit/score/src/threadchangepriority.c
> > @@ -29,29 +29,36 @@ void _Thread_Change_priority(
> >    bool              prepend_it
> >  )
> >  {
> > +  ISR_Level level;
> > +
> > +  _ISR_Disable( level );
> > +
> >    /*
> >     *  Do not bother recomputing all the priority related information if
> >     *  we are not REALLY changing priority.
> >     */
> >    if ( the_thread->current_priority != new_priority ) {
> > -    ISR_Level level;
> > -
> > -    _ISR_Disable( level );
> > +    uint32_t my_generation = the_thread->priority_generation + 1;
> >
> >      the_thread->current_priority = new_priority;
> > +    the_thread->priority_generation = my_generation;
> >
> > -    if ( _States_Is_ready( the_thread->current_state ) ) {
> > -      _Scheduler_Change_priority(
> > -        the_thread,
> > -        new_priority,
> > -        prepend_it
> > -      );
> > -    } else {
> > -      _Scheduler_Update_priority( the_thread, new_priority );
> > -    }
> > +    _Thread_queue_Requeue( the_thread->Wait.queue, the_thread );
> Can we get a comment above this call that _Thread_queue_Requeue
> checks that the thread is actually blocked on the specified queue so
> we don't need to check the thread state?

I want to get rid of this _Thread_queue_Requeue() in a follow up patch.  Things are getting much more compilicated on SMP since we now have to take the lock order into account to avoid deadlocks.



More information about the devel mailing list