Changeset 4054c916 in rtems


Ignore:
Timestamp:
Mar 20, 2015, 12:41:27 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
ad57a59
Parents:
3134eb8
git-author:
Sebastian Huber <sebastian.huber@…> (03/20/15 12:41:27)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/24/15 13:35:05)
Message:

score: Add scheduler acquire/release

This is currently a global lock for all scheduler instances. It should
get replaced with one lock per scheduler instance in the future.

Update #2273.

Location:
cpukit
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/taskmode.c

    r3134eb8 r4054c916  
    111111
    112112  if ( preempt_enabled || needs_asr_dispatching ) {
    113     ISR_Level level;
     113    ISR_lock_Context lock_context;
    114114
    115115    _Thread_Disable_dispatch();
    116     _ISR_Disable( level );
     116    _Scheduler_Acquire( executing, &lock_context );
    117117    _Scheduler_Schedule( executing );
    118     _ISR_Enable( level );
     118    _Scheduler_Release( executing, &lock_context );
    119119    _Thread_Enable_dispatch();
    120120  }
  • cpukit/score/include/rtems/score/schedulerimpl.h

    r3134eb8 r4054c916  
    13751375#endif
    13761376
     1377ISR_LOCK_DECLARE( extern, _Scheduler_Lock )
     1378
     1379/**
     1380 * @brief Acquires the scheduler instance of the thread.
     1381 *
     1382 * @param[in] the_thread The thread.
     1383 * @param[in] lock_context The lock context for _Scheduler_Release().
     1384 */
     1385RTEMS_INLINE_ROUTINE void _Scheduler_Acquire(
     1386  Thread_Control   *the_thread,
     1387  ISR_lock_Context *lock_context
     1388)
     1389{
     1390  (void) the_thread;
     1391  _ISR_lock_ISR_disable_and_acquire( &_Scheduler_Lock, lock_context );
     1392}
     1393
     1394/**
     1395 * @brief Releases the scheduler instance of the thread.
     1396 *
     1397 * @param[in] the_thread The thread.
     1398 * @param[in] lock_context The lock context used for _Scheduler_Acquire().
     1399 */
     1400RTEMS_INLINE_ROUTINE void _Scheduler_Release(
     1401  Thread_Control   *the_thread,
     1402  ISR_lock_Context *lock_context
     1403)
     1404{
     1405  (void) the_thread;
     1406  _ISR_lock_Release_and_ISR_enable( &_Scheduler_Lock, lock_context );
     1407}
     1408
    13771409/** @} */
    13781410
  • cpukit/score/src/scheduler.c

    r3134eb8 r4054c916  
    2121#include <rtems/score/schedulerimpl.h>
    2222
     23ISR_LOCK_DEFINE( , _Scheduler_Lock, "Scheduler" )
     24
    2325void _Scheduler_Handler_initialization(void)
    2426{
  • cpukit/score/src/schedulercbsunblock.c

    r3134eb8 r4054c916  
    5454      /* Put late unblocked task to background until the end of period. */
    5555      new_priority = the_thread->Start.initial_priority;
    56       if ( the_thread->real_priority != new_priority )
    57         the_thread->real_priority = new_priority;
    58       if ( the_thread->current_priority != new_priority )
    59         _Thread_Change_priority(the_thread, new_priority, true);
     56      the_thread->real_priority = new_priority;
     57      if ( the_thread->current_priority != new_priority ) {
     58        the_thread->current_priority = new_priority;
     59        _Scheduler_Change_priority(the_thread, new_priority, true);
     60      }
    6061    }
    6162  }
  • cpukit/score/src/threadchangepriority.c

    r3134eb8 r4054c916  
    4040   */
    4141  if ( the_thread->current_priority != new_priority ) {
    42     uint32_t  my_generation;
    43     ISR_Level level;
     42    uint32_t my_generation;
    4443
    4544    my_generation = the_thread->Priority.generation + 1;
     
    5554    _Thread_Lock_release( lock, &lock_context );
    5655
    57     _ISR_Disable( level );
     56    _Scheduler_Acquire( the_thread, &lock_context );
    5857
    5958    if ( the_thread->Priority.generation == my_generation ) {
     
    6968    }
    7069
    71     _ISR_Enable( level );
     70    _Scheduler_Release( the_thread, &lock_context );
    7271  } else {
    7372    _Thread_Lock_release( lock, &lock_context );
  • cpukit/score/src/threadclearstate.c

    r3134eb8 r4054c916  
    2727)
    2828{
    29   ISR_Level       level;
    30   States_Control  current_state;
     29  ISR_lock_Context lock_context;
     30  States_Control   current_state;
    3131
    32   _ISR_Disable( level );
    33     current_state = the_thread->current_state;
     32  _Scheduler_Acquire( the_thread, &lock_context );
    3433
    35     if ( current_state & state ) {
    36       current_state =
    37       the_thread->current_state = _States_Clear( state, current_state );
     34  current_state = the_thread->current_state;
     35  if ( current_state & state ) {
     36    current_state =
     37    the_thread->current_state = _States_Clear( state, current_state );
    3838
    39       if ( _States_Is_ready( current_state ) ) {
    40         _Scheduler_Unblock( the_thread );
    41       }
     39    if ( _States_Is_ready( current_state ) ) {
     40      _Scheduler_Unblock( the_thread );
     41    }
    4242  }
    43   _ISR_Enable( level );
     43
     44  _Scheduler_Release( the_thread, &lock_context );
    4445}
  • cpukit/score/src/threadready.c

    r3134eb8 r4054c916  
    2727)
    2828{
    29   ISR_Level              level;
     29  ISR_lock_Context lock_context;
    3030
    31   _ISR_Disable( level );
     31  _Scheduler_Acquire( the_thread, &lock_context );
    3232
    3333  the_thread->current_state = STATES_READY;
     
    3535  _Scheduler_Unblock( the_thread );
    3636
    37   _ISR_Enable( level );
     37  _Scheduler_Release( the_thread, &lock_context );
    3838}
  • cpukit/score/src/threadsetstate.c

    r3134eb8 r4054c916  
    3131)
    3232{
    33   ISR_Level      level;
    34   States_Control current_state;
     33  ISR_lock_Context lock_context;
     34  States_Control   current_state;
    3535
    36   _ISR_Disable( level );
     36  _Scheduler_Acquire( the_thread, &lock_context );
    3737
    3838  current_state = the_thread->current_state;
     
    4545  }
    4646
    47   _ISR_Enable( level );
     47  _Scheduler_Release( the_thread, &lock_context );
    4848}
  • cpukit/score/src/threadyield.c

    r3134eb8 r4054c916  
    3030void _Thread_Yield( Thread_Control *executing )
    3131{
    32   ISR_Level level;
     32  ISR_lock_Context lock_context;
    3333
    34   _ISR_Disable( level );
     34  _Scheduler_Acquire( executing, &lock_context );
    3535
    3636  if ( _States_Is_ready( executing->current_state ) ) {
     
    3838  }
    3939
    40   _ISR_Enable( level );
     40  _Scheduler_Release( executing, &lock_context );
    4141}
Note: See TracChangeset for help on using the changeset viewer.