Changeset 6157743 in rtems


Ignore:
Timestamp:
Feb 23, 2015, 3:54:54 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
222dc77
Parents:
b8a5abf
git-author:
Sebastian Huber <sebastian.huber@…> (02/23/15 15:54:54)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/05/15 10:36:19)
Message:

score: Simplify and fix signal delivery

Deliver the POSIX signals after the thread state was updated to avoid
race-conditions on SMP configurations.

Update #2273.

Location:
cpukit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/psignalunblockthread.c

    rb8a5abf r6157743  
    3636#include <stdio.h>
    3737
     38static bool _POSIX_signals_Unblock_thread_done(
     39  Thread_Control    *the_thread,
     40  POSIX_API_Control *api,
     41  bool               status
     42)
     43{
     44  _Thread_Add_post_switch_action( the_thread, &api->Signal_action );
     45
     46  return status;
     47}
     48
    3849bool _POSIX_signals_Unblock_thread(
    3950  Thread_Control  *the_thread,
     
    4758
    4859  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
    49 
    50   _Thread_Add_post_switch_action( the_thread, &api->Signal_action );
    5160
    5261  mask = signo_to_mask( signo );
     
    7281
    7382      _Thread_queue_Extract_with_proxy( the_thread );
    74       return true;
     83      return _POSIX_signals_Unblock_thread_done( the_thread, api, true );
    7584    }
    7685
     
    7988     */
    8089
    81     return false;
     90    return _POSIX_signals_Unblock_thread_done( the_thread, api, false );
    8291  }
    8392
     
    112121          _Thread_Unblock( the_thread );
    113122       }
    114 
    115     } else if ( the_thread->current_state == STATES_READY ) {
    116       _Thread_Signal_notification( the_thread );
    117123    }
    118124  }
    119   return false;
     125  return _POSIX_signals_Unblock_thread_done( the_thread, api, false );
    120126}
  • cpukit/rtems/src/signalsend.c

    rb8a5abf r6157743  
    5252            &api->Signal_action
    5353          );
    54           _Thread_Signal_notification( the_thread );
    5554        } else {
    5655          _ASR_Post_signals( asr, signal_set, &asr->signals_pending );
  • cpukit/score/include/rtems/score/threadimpl.h

    rb8a5abf r6157743  
    696696}
    697697
    698 RTEMS_INLINE_ROUTINE void _Thread_Request_dispatch_if_executing(
    699   Thread_Control *thread
    700 )
    701 {
    702 #if defined(RTEMS_SMP)
    703   if ( _Thread_Is_executing_on_a_processor( thread ) ) {
    704     const Per_CPU_Control *cpu_of_executing = _Per_CPU_Get();
    705     Per_CPU_Control *cpu_of_thread = _Thread_Get_CPU( thread );
    706 
    707     cpu_of_thread->dispatch_necessary = true;
    708 
    709     if ( cpu_of_executing != cpu_of_thread ) {
    710       _Per_CPU_Send_interrupt( cpu_of_thread );
    711     }
    712   }
    713 #else
    714   (void) thread;
    715 #endif
    716 }
    717 
    718 RTEMS_INLINE_ROUTINE void _Thread_Signal_notification( Thread_Control *thread )
    719 {
    720   if ( _ISR_Is_in_progress() && _Thread_Is_executing( thread ) ) {
    721     _Thread_Dispatch_necessary = true;
    722   } else {
    723 #if defined(RTEMS_SMP)
    724     if ( _Thread_Is_executing_on_a_processor( thread ) ) {
    725       const Per_CPU_Control *cpu_of_executing = _Per_CPU_Get();
    726       Per_CPU_Control *cpu_of_thread = _Thread_Get_CPU( thread );
    727 
    728       if ( cpu_of_executing != cpu_of_thread ) {
    729         cpu_of_thread->dispatch_necessary = true;
    730         _Per_CPU_Send_interrupt( cpu_of_thread );
    731       }
    732     }
    733 #endif
    734   }
    735 }
    736 
    737698/**
    738699 * @brief Gets the heir of the processor and makes it executing.
     
    871832)
    872833{
    873   Per_CPU_Control *cpu;
     834  Per_CPU_Control *cpu_of_thread;
    874835  ISR_Level        level;
    875836
    876   cpu = _Thread_Action_ISR_disable_and_acquire( thread, &level );
     837  cpu_of_thread = _Thread_Action_ISR_disable_and_acquire( thread, &level );
     838  cpu_of_thread->dispatch_necessary = true;
     839
     840#if defined(RTEMS_SMP)
     841  if ( _Per_CPU_Get() != cpu_of_thread ) {
     842    _Per_CPU_Send_interrupt( cpu_of_thread );
     843  }
     844#endif
     845
    877846  _Chain_Append_if_is_off_chain_unprotected(
    878847    &thread->Post_switch_actions.Chain,
    879848    &action->Node
    880849  );
    881   _Thread_Action_release_and_ISR_enable( cpu, level );
     850
     851  _Thread_Action_release_and_ISR_enable( cpu_of_thread, level );
    882852}
    883853
  • cpukit/score/src/threadrestart.c

    rb8a5abf r6157743  
    236236  _Thread_Add_post_switch_action( the_thread, &the_thread->Life.Action );
    237237  _Thread_Ready( the_thread );
    238   _Thread_Request_dispatch_if_executing( the_thread );
    239238}
    240239
Note: See TracChangeset for help on using the changeset viewer.