Changeset edb020c in rtems


Ignore:
Timestamp:
Oct 14, 2016, 11:03:46 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ebdd2a3
Parents:
a7a8ec03
git-author:
Sebastian Huber <sebastian.huber@…> (10/14/16 11:03:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/02/16 09:05:42)
Message:

score: Protect thread CPU by thread scheduler lock

Update #2556.

Location:
cpukit/score/include/rtems/score
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/schedulerimpl.h

    ra7a8ec03 redb020c  
    11031103 * @param[in] get_idle_thread Function to get an idle thread.
    11041104 *
    1105  * @retval true Continue with the blocking operation.
    1106  * @retval false Otherwise.
    1107  */
    1108 RTEMS_INLINE_ROUTINE bool _Scheduler_Block_node(
     1105 * @retval thread_cpu The processor of the thread.  Indicates to continue with
     1106 *   the blocking operation.
     1107 * @retval NULL Otherwise.
     1108 */
     1109RTEMS_INLINE_ROUTINE Per_CPU_Control *_Scheduler_Block_node(
    11091110  Scheduler_Context         *context,
    11101111  Thread_Control            *thread,
     
    11171118  Thread_Control   *old_user;
    11181119  Thread_Control   *new_user;
     1120  Per_CPU_Control  *thread_cpu;
    11191121
    11201122  _Thread_Scheduler_acquire_critical( thread, &lock_context );
     1123  thread_cpu = _Thread_Get_CPU( thread );
    11211124  _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED );
    11221125  _Thread_Scheduler_release_critical( thread, &lock_context );
     
    11251128    _Assert( thread == _Scheduler_Node_get_user( node ) );
    11261129
    1127     return true;
     1130    return thread_cpu;
    11281131  }
    11291132
     
    11671170  }
    11681171
    1169   return false;
     1172  return NULL;
    11701173}
    11711174
  • cpukit/score/include/rtems/score/schedulersmpimpl.h

    ra7a8ec03 redb020c  
    320320typedef void ( *Scheduler_SMP_Allocate_processor )(
    321321  Scheduler_Context *context,
    322   Thread_Control    *scheduled,
    323   Thread_Control    *victim
     322  Thread_Control    *scheduled_thread,
     323  Thread_Control    *victim_thread,
     324  Per_CPU_Control   *victim_cpu
    324325);
    325326
     
    471472  Scheduler_Context *context,
    472473  Thread_Control    *scheduled_thread,
    473   Thread_Control    *victim_thread
     474  Thread_Control    *victim_thread,
     475  Per_CPU_Control   *victim_cpu
    474476)
    475477{
    476478  Per_CPU_Control *scheduled_cpu = _Thread_Get_CPU( scheduled_thread );
    477   Per_CPU_Control *victim_cpu = _Thread_Get_CPU( victim_thread );
    478479  Per_CPU_Control *cpu_self = _Per_CPU_Get();
    479480  Thread_Control *heir;
     
    512513  Scheduler_Context *context,
    513514  Thread_Control    *scheduled_thread,
    514   Thread_Control    *victim_thread
    515 )
    516 {
    517   Per_CPU_Control *victim_cpu = _Thread_Get_CPU( victim_thread );
     515  Thread_Control    *victim_thread,
     516  Per_CPU_Control   *victim_cpu
     517)
     518{
    518519  Per_CPU_Control *cpu_self = _Per_CPU_Get();
    519520
     
    528529  Scheduler_Node                   *scheduled,
    529530  Thread_Control                   *victim_thread,
     531  Per_CPU_Control                  *victim_cpu,
    530532  Scheduler_SMP_Allocate_processor  allocate_processor
    531533)
     
    535537  _Scheduler_SMP_Node_change_state( scheduled, SCHEDULER_SMP_NODE_SCHEDULED );
    536538
    537   ( *allocate_processor )( context, scheduled_thread, victim_thread );
     539  ( *allocate_processor )(
     540    context,
     541    scheduled_thread,
     542    victim_thread,
     543    victim_cpu
     544  );
    538545}
    539546
     
    547554  Thread_Control   *victim_thread;
    548555  ISR_lock_Context  lock_context;
     556  Per_CPU_Control  *victim_cpu;
    549557
    550558  victim_thread = _Scheduler_Node_get_user( victim );
     
    552560
    553561  _Thread_Scheduler_acquire_critical( victim_thread, &lock_context );
     562  victim_cpu = _Thread_Get_CPU( victim_thread );
    554563  _Scheduler_Thread_change_state( victim_thread, THREAD_SCHEDULER_READY );
    555564  _Thread_Scheduler_release_critical( victim_thread, &lock_context );
     
    559568    scheduled,
    560569    victim_thread,
     570    victim_cpu,
    561571    allocate_processor
    562572  );
     
    824834  Scheduler_Context                *context,
    825835  Scheduler_Node                   *victim,
     836  Per_CPU_Control                  *victim_cpu,
    826837  Scheduler_SMP_Extract             extract_from_ready,
    827838  Scheduler_SMP_Get_highest_ready   get_highest_ready,
     
    847858        highest_ready,
    848859        _Scheduler_Node_get_user( victim ),
     860        victim_cpu,
    849861        allocate_processor
    850862      );
     
    886898)
    887899{
    888   Scheduler_SMP_Node_state node_state;
    889   bool                     block;
     900  Scheduler_SMP_Node_state  node_state;
     901  Per_CPU_Control          *thread_cpu;
    890902
    891903  node_state = _Scheduler_SMP_Node_state( node );
    892904  _Assert( node_state != SCHEDULER_SMP_NODE_BLOCKED );
    893905
    894   block = _Scheduler_Block_node(
     906  thread_cpu = _Scheduler_Block_node(
    895907    context,
    896908    thread,
     
    899911    _Scheduler_SMP_Get_idle_thread
    900912  );
    901   if ( block ) {
     913  if ( thread_cpu != NULL ) {
    902914    _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
    903915
    904916    if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
    905917      _Scheduler_SMP_Extract_from_scheduled( node );
    906 
    907918      _Scheduler_SMP_Schedule_highest_ready(
    908919        context,
    909920        node,
     921        thread_cpu,
    910922        extract_from_ready,
    911923        get_highest_ready,
Note: See TracChangeset for help on using the changeset viewer.