Changeset d057d653 in rtems


Ignore:
Timestamp:
Sep 30, 2016, 8:10:22 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
d097b546
Parents:
fac8a3a
git-author:
Sebastian Huber <sebastian.huber@…> (09/30/16 08:10:22)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/02/16 09:05:40)
Message:

score: Fix _Scheduler_Try_to_schedule_node() usage

Fix wrong use of continue statement in while loops.

File:
1 edited

Legend:

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

    rfac8a3a rd057d653  
    715715)
    716716{
    717   Thread_Control *needs_help;
    718 
    719   do {
    720     Scheduler_Node *highest_ready = ( *get_highest_ready )( context, node );
     717  while ( true ) {
     718    Scheduler_Node                   *highest_ready;
     719    Scheduler_Try_to_schedule_action  action;
     720
     721    highest_ready = ( *get_highest_ready )( context, node );
    721722
    722723    /*
     
    726727    if ( ( *order )( &node->Node, &highest_ready->Node ) ) {
    727728      ( *insert_scheduled )( context, node );
    728 
    729       needs_help = NULL;
    730     } else {
    731       Scheduler_Try_to_schedule_action action;
    732 
    733       action = _Scheduler_Try_to_schedule_node(
     729      return NULL;
     730    }
     731
     732    action = _Scheduler_Try_to_schedule_node(
     733      context,
     734      highest_ready,
     735      _Scheduler_Node_get_idle( node ),
     736      _Scheduler_SMP_Get_idle_thread
     737    );
     738
     739    if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) {
     740      Thread_Control *user = _Scheduler_Node_get_user( node );
     741      Thread_Control *idle;
     742
     743      _Scheduler_SMP_Node_change_state(
     744        _Scheduler_SMP_Node_downcast( node ),
     745        SCHEDULER_SMP_NODE_READY
     746      );
     747      _Scheduler_Thread_change_state( user, THREAD_SCHEDULER_READY );
     748
     749      _Scheduler_SMP_Allocate_processor(
    734750        context,
    735751        highest_ready,
    736         _Scheduler_Node_get_idle( node ),
    737         _Scheduler_SMP_Get_idle_thread
    738       );
    739 
    740       if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) {
    741         Thread_Control *user = _Scheduler_Node_get_user( node );
    742         Thread_Control *idle;
    743 
    744         _Scheduler_SMP_Node_change_state(
    745           _Scheduler_SMP_Node_downcast( node ),
    746           SCHEDULER_SMP_NODE_READY
    747         );
    748         _Scheduler_Thread_change_state( user, THREAD_SCHEDULER_READY );
    749 
    750         _Scheduler_SMP_Allocate_processor(
    751           context,
    752           highest_ready,
    753           node,
    754           allocate_processor
    755         );
    756 
    757         ( *insert_ready )( context, node );
    758         ( *move_from_ready_to_scheduled )( context, highest_ready );
    759 
    760         idle = _Scheduler_Release_idle_thread(
    761           context,
    762           node,
    763           _Scheduler_SMP_Release_idle_thread
    764         );
    765         if ( idle == NULL ) {
    766           needs_help = user;
    767         } else {
    768           needs_help = NULL;
    769         }
    770       } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) {
    771         _Scheduler_SMP_Node_change_state(
    772           _Scheduler_SMP_Node_downcast( node ),
    773           SCHEDULER_SMP_NODE_READY
    774         );
    775         _Scheduler_SMP_Node_change_state(
    776           _Scheduler_SMP_Node_downcast( highest_ready ),
    777           SCHEDULER_SMP_NODE_SCHEDULED
    778         );
    779 
    780         ( *insert_ready )( context, node );
    781         ( *move_from_ready_to_scheduled )( context, highest_ready );
    782 
    783         _Scheduler_Exchange_idle_thread(
    784           highest_ready,
    785           node,
    786           _Scheduler_Node_get_idle( node )
    787         );
    788 
    789         needs_help = NULL;
     752        node,
     753        allocate_processor
     754      );
     755
     756      ( *insert_ready )( context, node );
     757      ( *move_from_ready_to_scheduled )( context, highest_ready );
     758
     759      idle = _Scheduler_Release_idle_thread(
     760        context,
     761        node,
     762        _Scheduler_SMP_Release_idle_thread
     763      );
     764
     765      if ( idle == NULL ) {
     766        return user;
    790767      } else {
    791         _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK );
    792 
    793         _Scheduler_SMP_Node_change_state(
    794           _Scheduler_SMP_Node_downcast( highest_ready ),
    795           SCHEDULER_SMP_NODE_BLOCKED
    796         );
    797 
    798         ( *extract_from_ready )( context, highest_ready );
    799 
    800         continue;
     768        return NULL;
    801769      }
     770    } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) {
     771      _Scheduler_SMP_Node_change_state(
     772        _Scheduler_SMP_Node_downcast( node ),
     773        SCHEDULER_SMP_NODE_READY
     774      );
     775      _Scheduler_SMP_Node_change_state(
     776        _Scheduler_SMP_Node_downcast( highest_ready ),
     777        SCHEDULER_SMP_NODE_SCHEDULED
     778      );
     779
     780      ( *insert_ready )( context, node );
     781      ( *move_from_ready_to_scheduled )( context, highest_ready );
     782
     783      _Scheduler_Exchange_idle_thread(
     784        highest_ready,
     785        node,
     786        _Scheduler_Node_get_idle( node )
     787      );
     788      return NULL;
     789    } else {
     790      _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK );
     791
     792      _Scheduler_SMP_Node_change_state(
     793        _Scheduler_SMP_Node_downcast( highest_ready ),
     794        SCHEDULER_SMP_NODE_BLOCKED
     795      );
     796
     797      ( *extract_from_ready )( context, highest_ready );
    802798    }
    803   } while ( false );
    804 
    805   return needs_help;
     799  }
    806800}
    807801
     
    822816)
    823817{
     818  Scheduler_Try_to_schedule_action action;
     819
    824820  do {
    825821    Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim );
    826     Scheduler_Try_to_schedule_action action;
    827822
    828823    action = _Scheduler_Try_to_schedule_node(
     
    851846
    852847      ( *extract_from_ready )( context, highest_ready );
    853 
    854       continue;
    855848    }
    856   } while ( false );
     849  } while ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK );
    857850}
    858851
Note: See TracChangeset for help on using the changeset viewer.