Changeset 4b3251a in rtems


Ignore:
Timestamp:
06/16/16 10:05:42 (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
d5ff1398
Parents:
57c676c6
git-author:
Sebastian Huber <sebastian.huber@…> (06/16/16 10:05:42)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/16/16 10:46:48)
Message:

score: Fix thread delete race condition on SMP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/threadrestart.c

    r57c676c6 r4b3251a  
    136136}
    137137
    138 static void _Thread_Make_zombie( Thread_Control *the_thread )
     138static void _Thread_Add_to_zombie_chain( Thread_Control *the_thread )
    139139{
    140140  ISR_lock_Context       lock_context;
    141141  Thread_Zombie_control *zombies;
    142142
     143  zombies = &_Thread_Zombies;
     144  _ISR_lock_ISR_disable_and_acquire( &zombies->Lock, &lock_context );
     145  _Chain_Append_unprotected( &zombies->Chain, &the_thread->Object.Node );
     146  _ISR_lock_Release_and_ISR_enable( &zombies->Lock, &lock_context );
     147}
     148
     149static void _Thread_Make_zombie( Thread_Control *the_thread )
     150{
    143151  if ( _Thread_Owns_resources( the_thread ) ) {
    144152    _Terminate(
     
    154162  );
    155163
    156   _Thread_Wake_up_joining_threads( the_thread );
    157164  _Thread_Set_state( the_thread, STATES_ZOMBIE );
    158165  _Thread_queue_Extract_with_proxy( the_thread );
    159166  _Thread_Timer_remove( the_thread );
    160167
    161   zombies = &_Thread_Zombies;
    162   _ISR_lock_ISR_disable_and_acquire( &zombies->Lock, &lock_context );
    163   _Chain_Append_unprotected( &zombies->Chain, &the_thread->Object.Node );
    164   _ISR_lock_Release_and_ISR_enable( &zombies->Lock, &lock_context );
     168  /*
     169   * Add the thread to the thread zombie chain before we wake up joining
     170   * threads, so that they are able to clean up the thread immediately.  This
     171   * matters for SMP configurations.
     172   */
     173  _Thread_Add_to_zombie_chain( the_thread );
     174
     175  _Thread_Wake_up_joining_threads( the_thread );
    165176}
    166177
Note: See TracChangeset for help on using the changeset viewer.