Changeset ebd40c0 in rtems


Ignore:
Timestamp:
Jun 6, 1996, 2:55:08 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
65a5c1b
Parents:
2f200c7
Message:

Added Sporadic Server support to posix threads which required changes
in the core to support multiple algorithms to handle cpu time budgetting
which resulted in a change to the calling sequence of _Thread_Initialize.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/rtems/src/tasks.c

    r2f200c7 rebd40c0  
    355355    core_priority,
    356356    _Modes_Is_preempt(initial_modes)   ? TRUE : FALSE,
    357     _Modes_Is_timeslice(initial_modes) ? TRUE : FALSE,
     357    _Modes_Is_timeslice(initial_modes) ?
     358      THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE :
     359      THREAD_CPU_BUDGET_ALGORITHM_NONE,
     360    NULL,        /* no budget algorithm callout */
    358361    _Modes_Get_interrupt_level(initial_modes),
    359362    &name
     
    778781
    779782  old_mode  = (executing->is_preemptible) ? RTEMS_PREEMPT : RTEMS_NO_PREEMPT;
    780   old_mode |= (executing->is_timeslice) ? RTEMS_TIMESLICE : RTEMS_NO_TIMESLICE;
     783
     784  if ( executing->budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_NONE )
     785    old_mode |= RTEMS_NO_TIMESLICE;
     786  else
     787    old_mode |= RTEMS_TIMESLICE;
     788
    781789  old_mode |= (asr->is_enabled) ? RTEMS_ASR : RTEMS_NO_ASR;
    782790  old_mode |= _ISR_Get_level();
     
    791799    executing->is_preemptible = _Modes_Is_preempt(mode_set) ? TRUE : FALSE;
    792800
    793   if ( mask & RTEMS_TIMESLICE_MASK )
    794     executing->is_timeslice = _Modes_Is_timeslice(mode_set) ? TRUE : FALSE;
     801  if ( mask & RTEMS_TIMESLICE_MASK ) {
     802    if ( _Modes_Is_timeslice(mode_set) )
     803      executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
     804    else
     805      executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
     806  }
    795807
    796808  /*
  • c/src/exec/score/src/mpci.c

    r2f200c7 rebd40c0  
    116116    PRIORITY_MINIMUM,
    117117    FALSE,       /* no preempt */
    118     FALSE,       /* not timesliced */
     118    THREAD_CPU_BUDGET_ALGORITHM_NONE,
     119    NULL,        /* no budget algorithm callout */
    119120    0,           /* all interrupts enabled */
    120121    _MPCI_Internal_name
  • c/src/exec/score/src/thread.c

    r2f200c7 rebd40c0  
    137137    PRIORITY_MAXIMUM,
    138138    TRUE,        /* preemptable */
    139     FALSE,       /* not timesliced */
     139    THREAD_CPU_BUDGET_ALGORITHM_NONE,
     140    NULL,        /* no budget algorithm callout */
    140141    0,           /* all interrupts enabled */
    141142    _Thread_Idle_name
     
    244245    _User_extensions_Thread_switch( executing, heir );
    245246
    246     heir->cpu_time_budget = _Thread_Ticks_per_timeslice;
     247    if ( heir->budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE )
     248      heir->cpu_time_budget = _Thread_Ticks_per_timeslice;
    247249
    248250    /*
     
    384386
    385387boolean _Thread_Initialize(
    386   Objects_Information *information,
    387   Thread_Control      *the_thread,
    388   void                *stack_area,    /* NULL if to be allocated */
    389   unsigned32           stack_size,    /* insure it is >= min */
    390   boolean              is_fp,         /* TRUE if thread uses FP */
    391   Priority_Control     priority,
    392   boolean              is_preemptible,
    393   boolean              is_timeslice,
    394   unsigned32           isr_level,
    395   Objects_Name         name
    396  
     388  Objects_Information                  *information,
     389  Thread_Control                       *the_thread,
     390  void                                 *stack_area,
     391  unsigned32                            stack_size,
     392  boolean                               is_fp,
     393  Priority_Control                      priority,
     394  boolean                               is_preemptible,
     395  Thread_CPU_budget_algorithms          budget_algorithm,
     396  Thread_CPU_budget_algorithm_callout   budget_callout,
     397  unsigned32                            isr_level,
     398  Objects_Name                          name
    397399)
    398400{
     
    481483   */
    482484
    483   the_thread->Start.is_preemptible = is_preemptible;
    484   the_thread->Start.is_timeslice   = is_timeslice;
    485   the_thread->Start.isr_level      = isr_level;
     485  the_thread->Start.is_preemptible   = is_preemptible;
     486  the_thread->Start.budget_algorithm = budget_algorithm;
     487  the_thread->Start.budget_callout   = budget_callout;
     488  the_thread->Start.isr_level        = isr_level;
    486489
    487490  the_thread->current_state          = STATES_DORMANT;
     
    574577    _Thread_Set_transient( the_thread );
    575578    the_thread->resource_count = 0;
    576     the_thread->is_preemptible = the_thread->Start.is_preemptible;
    577     the_thread->is_timeslice   = the_thread->Start.is_timeslice;
     579    the_thread->is_preemptible   = the_thread->Start.is_preemptible;
     580    the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
     581    the_thread->budget_callout   = the_thread->Start.budget_callout;
    578582
    579583    the_thread->Start.pointer_argument = pointer_argument;
     
    875879    if ( _Chain_Has_only_one_node( ready ) ) {
    876880      _ISR_Enable( level );
    877       executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
    878881      return;
    879882    }
     
    906909void _Thread_Tickle_timeslice( void )
    907910{
    908   if ( !_Thread_Executing->is_timeslice  ||
    909        !_Thread_Executing->is_preemptible ||
    910        !_States_Is_ready( _Thread_Executing->current_state ) )
     911  Thread_Control *executing;
     912
     913  executing = _Thread_Executing;
     914
     915  if ( !executing->is_preemptible )
    911916    return;
    912917
    913   if ( --_Thread_Executing->cpu_time_budget == 0 ) {
    914       _Thread_Reset_timeslice();
     918  if ( !_States_Is_ready( executing->current_state ) )
     919    return;
     920
     921  switch ( executing->budget_algorithm ) {
     922    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
     923      break;
     924
     925    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
     926    case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
     927      if ( --executing->cpu_time_budget == 0 ) {
     928        _Thread_Reset_timeslice();
     929        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
     930      }
     931      break;
     932
     933    case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
     934      if ( --executing->cpu_time_budget == 0 )
     935        (*executing->budget_callout)( executing );
     936      break;
    915937  }
    916938}
     
    9871009
    9881010  the_thread->do_post_task_switch_extension = FALSE;
    989   the_thread->is_preemptible = the_thread->Start.is_preemptible;
    990   the_thread->is_timeslice   = the_thread->Start.is_timeslice;
     1011  the_thread->is_preemptible   = the_thread->Start.is_preemptible;
     1012  the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
     1013  the_thread->budget_callout   = the_thread->Start.budget_callout;
    9911014
    9921015  _Context_Initialize(
  • cpukit/rtems/src/tasks.c

    r2f200c7 rebd40c0  
    355355    core_priority,
    356356    _Modes_Is_preempt(initial_modes)   ? TRUE : FALSE,
    357     _Modes_Is_timeslice(initial_modes) ? TRUE : FALSE,
     357    _Modes_Is_timeslice(initial_modes) ?
     358      THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE :
     359      THREAD_CPU_BUDGET_ALGORITHM_NONE,
     360    NULL,        /* no budget algorithm callout */
    358361    _Modes_Get_interrupt_level(initial_modes),
    359362    &name
     
    778781
    779782  old_mode  = (executing->is_preemptible) ? RTEMS_PREEMPT : RTEMS_NO_PREEMPT;
    780   old_mode |= (executing->is_timeslice) ? RTEMS_TIMESLICE : RTEMS_NO_TIMESLICE;
     783
     784  if ( executing->budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_NONE )
     785    old_mode |= RTEMS_NO_TIMESLICE;
     786  else
     787    old_mode |= RTEMS_TIMESLICE;
     788
    781789  old_mode |= (asr->is_enabled) ? RTEMS_ASR : RTEMS_NO_ASR;
    782790  old_mode |= _ISR_Get_level();
     
    791799    executing->is_preemptible = _Modes_Is_preempt(mode_set) ? TRUE : FALSE;
    792800
    793   if ( mask & RTEMS_TIMESLICE_MASK )
    794     executing->is_timeslice = _Modes_Is_timeslice(mode_set) ? TRUE : FALSE;
     801  if ( mask & RTEMS_TIMESLICE_MASK ) {
     802    if ( _Modes_Is_timeslice(mode_set) )
     803      executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
     804    else
     805      executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
     806  }
    795807
    796808  /*
  • cpukit/score/src/mpci.c

    r2f200c7 rebd40c0  
    116116    PRIORITY_MINIMUM,
    117117    FALSE,       /* no preempt */
    118     FALSE,       /* not timesliced */
     118    THREAD_CPU_BUDGET_ALGORITHM_NONE,
     119    NULL,        /* no budget algorithm callout */
    119120    0,           /* all interrupts enabled */
    120121    _MPCI_Internal_name
  • cpukit/score/src/thread.c

    r2f200c7 rebd40c0  
    137137    PRIORITY_MAXIMUM,
    138138    TRUE,        /* preemptable */
    139     FALSE,       /* not timesliced */
     139    THREAD_CPU_BUDGET_ALGORITHM_NONE,
     140    NULL,        /* no budget algorithm callout */
    140141    0,           /* all interrupts enabled */
    141142    _Thread_Idle_name
     
    244245    _User_extensions_Thread_switch( executing, heir );
    245246
    246     heir->cpu_time_budget = _Thread_Ticks_per_timeslice;
     247    if ( heir->budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE )
     248      heir->cpu_time_budget = _Thread_Ticks_per_timeslice;
    247249
    248250    /*
     
    384386
    385387boolean _Thread_Initialize(
    386   Objects_Information *information,
    387   Thread_Control      *the_thread,
    388   void                *stack_area,    /* NULL if to be allocated */
    389   unsigned32           stack_size,    /* insure it is >= min */
    390   boolean              is_fp,         /* TRUE if thread uses FP */
    391   Priority_Control     priority,
    392   boolean              is_preemptible,
    393   boolean              is_timeslice,
    394   unsigned32           isr_level,
    395   Objects_Name         name
    396  
     388  Objects_Information                  *information,
     389  Thread_Control                       *the_thread,
     390  void                                 *stack_area,
     391  unsigned32                            stack_size,
     392  boolean                               is_fp,
     393  Priority_Control                      priority,
     394  boolean                               is_preemptible,
     395  Thread_CPU_budget_algorithms          budget_algorithm,
     396  Thread_CPU_budget_algorithm_callout   budget_callout,
     397  unsigned32                            isr_level,
     398  Objects_Name                          name
    397399)
    398400{
     
    481483   */
    482484
    483   the_thread->Start.is_preemptible = is_preemptible;
    484   the_thread->Start.is_timeslice   = is_timeslice;
    485   the_thread->Start.isr_level      = isr_level;
     485  the_thread->Start.is_preemptible   = is_preemptible;
     486  the_thread->Start.budget_algorithm = budget_algorithm;
     487  the_thread->Start.budget_callout   = budget_callout;
     488  the_thread->Start.isr_level        = isr_level;
    486489
    487490  the_thread->current_state          = STATES_DORMANT;
     
    574577    _Thread_Set_transient( the_thread );
    575578    the_thread->resource_count = 0;
    576     the_thread->is_preemptible = the_thread->Start.is_preemptible;
    577     the_thread->is_timeslice   = the_thread->Start.is_timeslice;
     579    the_thread->is_preemptible   = the_thread->Start.is_preemptible;
     580    the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
     581    the_thread->budget_callout   = the_thread->Start.budget_callout;
    578582
    579583    the_thread->Start.pointer_argument = pointer_argument;
     
    875879    if ( _Chain_Has_only_one_node( ready ) ) {
    876880      _ISR_Enable( level );
    877       executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
    878881      return;
    879882    }
     
    906909void _Thread_Tickle_timeslice( void )
    907910{
    908   if ( !_Thread_Executing->is_timeslice  ||
    909        !_Thread_Executing->is_preemptible ||
    910        !_States_Is_ready( _Thread_Executing->current_state ) )
     911  Thread_Control *executing;
     912
     913  executing = _Thread_Executing;
     914
     915  if ( !executing->is_preemptible )
    911916    return;
    912917
    913   if ( --_Thread_Executing->cpu_time_budget == 0 ) {
    914       _Thread_Reset_timeslice();
     918  if ( !_States_Is_ready( executing->current_state ) )
     919    return;
     920
     921  switch ( executing->budget_algorithm ) {
     922    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
     923      break;
     924
     925    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
     926    case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
     927      if ( --executing->cpu_time_budget == 0 ) {
     928        _Thread_Reset_timeslice();
     929        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
     930      }
     931      break;
     932
     933    case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
     934      if ( --executing->cpu_time_budget == 0 )
     935        (*executing->budget_callout)( executing );
     936      break;
    915937  }
    916938}
     
    9871009
    9881010  the_thread->do_post_task_switch_extension = FALSE;
    989   the_thread->is_preemptible = the_thread->Start.is_preemptible;
    990   the_thread->is_timeslice   = the_thread->Start.is_timeslice;
     1011  the_thread->is_preemptible   = the_thread->Start.is_preemptible;
     1012  the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
     1013  the_thread->budget_callout   = the_thread->Start.budget_callout;
    9911014
    9921015  _Context_Initialize(
Note: See TracChangeset for help on using the changeset viewer.