Ignore:
Timestamp:
Oct 27, 2016, 4:42:06 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
1cafc46
Parents:
0e754fac
git-author:
Sebastian Huber <sebastian.huber@…> (10/27/16 04:42:06)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/02/16 09:05:44)
Message:

score: Second part of new MrsP implementation

Update #2556.

File:
1 edited

Legend:

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

    r0e754fac r6771359f  
    782782     * it now on the scheduled or ready set.
    783783     */
    784     if ( ( *order )( &node->Node, &highest_ready->Node ) ) {
     784    if (
     785      node->sticky_level > 0
     786        && ( *order )( &node->Node, &highest_ready->Node )
     787    ) {
    785788      ( *insert_scheduled )( context, node );
     789
     790      if ( _Scheduler_Node_get_idle( node ) != NULL ) {
     791        Thread_Control   *owner;
     792        ISR_lock_Context  lock_context;
     793
     794        owner = _Scheduler_Node_get_owner( node );
     795        _Thread_Scheduler_acquire_critical( owner, &lock_context );
     796
     797        if ( owner->Scheduler.state == THREAD_SCHEDULER_READY ) {
     798          _Thread_Scheduler_cancel_need_for_help(
     799            owner,
     800            _Thread_Get_CPU( owner )
     801          );
     802          _Scheduler_Discard_idle_thread(
     803            context,
     804            owner,
     805            node,
     806            _Scheduler_SMP_Release_idle_thread
     807          );
     808          _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED );
     809        }
     810
     811        _Thread_Scheduler_release_critical( owner, &lock_context );
     812      }
     813
    786814      return NULL;
    787815    }
     
    9931021    } else {
    9941022      _Assert( node_state == SCHEDULER_SMP_NODE_READY );
    995       _Assert(
    996         node->help_state == SCHEDULER_HELP_ACTIVE_OWNER
    997           || node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL
    998       );
     1023      _Assert( node->sticky_level > 0 );
    9991024      _Assert( node->idle == NULL );
    10001025
     
    11471172  _Thread_Scheduler_acquire_critical( thread, &lock_context );
    11481173
    1149   if (
    1150     thread->Scheduler.state == THREAD_SCHEDULER_READY
    1151       && _Scheduler_SMP_Node_state( node ) == SCHEDULER_SMP_NODE_BLOCKED
    1152   ) {
    1153     if ( ( *order )( &node->Node, &lowest_scheduled->Node ) ) {
     1174  if ( thread->Scheduler.state == THREAD_SCHEDULER_READY ) {
     1175    Scheduler_SMP_Node_state node_state;
     1176
     1177    node_state = _Scheduler_SMP_Node_state( node );
     1178
     1179    if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) {
     1180      if ( ( *order )( &node->Node, &lowest_scheduled->Node ) ) {
     1181        _Thread_Scheduler_cancel_need_for_help(
     1182          thread,
     1183          _Thread_Get_CPU( thread )
     1184        );
     1185        _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED );
     1186        _Thread_Scheduler_release_critical( thread, &lock_context );
     1187
     1188        _Scheduler_SMP_Preempt(
     1189          context,
     1190          node,
     1191          lowest_scheduled,
     1192          allocate_processor
     1193        );
     1194
     1195        ( *insert_scheduled )( context, node );
     1196        ( *move_from_scheduled_to_ready )( context, lowest_scheduled );
     1197
     1198        _Scheduler_Release_idle_thread(
     1199          context,
     1200          lowest_scheduled,
     1201          _Scheduler_SMP_Release_idle_thread
     1202        );
     1203        success = true;
     1204      } else {
     1205        _Thread_Scheduler_release_critical( thread, &lock_context );
     1206        _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY );
     1207        ( *insert_ready )( context, node );
     1208        success = false;
     1209      }
     1210    } else if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
    11541211      _Thread_Scheduler_cancel_need_for_help(
    11551212        thread,
    11561213        _Thread_Get_CPU( thread )
    11571214      );
     1215      _Scheduler_Discard_idle_thread(
     1216        context,
     1217        thread,
     1218        node,
     1219        _Scheduler_SMP_Release_idle_thread
     1220      );
    11581221      _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED );
    11591222      _Thread_Scheduler_release_critical( thread, &lock_context );
    1160 
    1161       _Scheduler_SMP_Preempt(
    1162         context,
    1163         node,
    1164         lowest_scheduled,
    1165         allocate_processor
    1166       );
    1167 
    1168       ( *insert_scheduled )( context, node );
    1169       ( *move_from_scheduled_to_ready )( context, lowest_scheduled );
    1170 
    1171       _Scheduler_Release_idle_thread(
    1172         context,
    1173         lowest_scheduled,
    1174         _Scheduler_SMP_Release_idle_thread
    1175       );
    11761223      success = true;
    11771224    } else {
    11781225      _Thread_Scheduler_release_critical( thread, &lock_context );
    1179       _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY );
    1180       ( *insert_ready )( context, node );
    11811226      success = false;
    11821227    }
     
    12031248    thread->Scheduler.state == THREAD_SCHEDULER_SCHEDULED
    12041249      && _Scheduler_SMP_Node_state( node ) == SCHEDULER_SMP_NODE_READY
     1250      && node->sticky_level == 1
    12051251  ) {
    12061252    _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
Note: See TracChangeset for help on using the changeset viewer.