Ticket #514: timeslice_exhaust.diff

File timeslice_exhaust.diff, 13.5 KB (added by Joel Sherrill, on Dec 3, 2006 at 1:31:13 PM)

timeslice_exhaust.diff

  • CPUKIT/ADA/RTEMS.ADS

    diff -x *~ -N -P -r -u rtems-orig/CPUKIT/ADA/RTEMS.ADS rtems/CPUKIT/ADA/RTEMS.ADS
    old new  
    99--
    1010--
    1111--
    12 --  COPYRIGHT (c) 1997.
     12--  COPYRIGHT (c) 1997-2003.
    1313--  On-Line Applications Research Corporation (OAR).
    1414--
    1515--  The license and distribution terms for this file may in
     
    205205   All_Mode_Masks     : constant RTEMS.Mode := 16#0000_ffff#;
    206206   Current_Mode       : constant RTEMS.Mode := 16#0000_0000#;
    207207   Preempt_Mask       : constant RTEMS.Mode := 16#0000_0100#;
    208    Timeslice_Mask     : constant RTEMS.Mode := 16#0000_0200#;
     208   Timeslice_Mask     : constant RTEMS.Mode := 16#0000_0A00#;
    209209   ASR_Mask           : constant RTEMS.Mode := 16#0000_0400#;
    210210   Interrupt_Mask     : RTEMS.Mode;
    211211   Preempt            : constant RTEMS.Mode := 16#0000_0000#;
    212212   No_Preempt         : constant RTEMS.Mode := 16#0000_0100#;
    213213   No_Timeslice       : constant RTEMS.Mode := 16#0000_0000#;
    214214   Timeslice          : constant RTEMS.Mode := 16#0000_0200#;
     215   Timeslice_Exhaust  : constant RTEMS.Mode := 16#0000_0800#;
    215216   ASR                : constant RTEMS.Mode := 16#0000_0000#;
    216217   No_ASR             : constant RTEMS.Mode := 16#0000_0400#;
    217218
  • CPUKIT/RTEMS/INCLUDE/RTEMS/RTEMS/MODES.H

    diff -x *~ -N -P -r -u rtems-orig/CPUKIT/RTEMS/INCLUDE/RTEMS/RTEMS/MODES.H rtems/CPUKIT/RTEMS/INCLUDE/RTEMS/RTEMS/MODES.H
    old new  
    3232/*
    3333 *  The following constants define the individual modes and masks
    3434 *  which may be used to compose a mode set and to alter modes.
     35 *
     36 *  The following combinations correspond to the POSIX Schedulers.
     37 *
     38 *     SCHED_FIFO  - RTEMS_PREEMPT | RTEMS_NO_TIMESLICE
     39 *     SCHED_RR    - RTEMS_PREEMPT | RTEMS_TIMESLICE_EXHAUST
     40 *     SCHED_OTHER - RTEMS_PREEMPT | RTEMS_TIMESLICE
    3541 */
    3642
    3743#define RTEMS_ALL_MODE_MASKS     0x0000ffff
     
    4046#define RTEMS_CURRENT_MODE      0
    4147
    4248#define RTEMS_PREEMPT_MASK    0x00000100  /* preemption bit           */
    43 #define RTEMS_TIMESLICE_MASK  0x00000200  /* timeslice bit            */
    44 #define RTEMS_ASR_MASK        0x00000400  /* RTEMS_ASR enable bit           */
     49#define RTEMS_TIMESLICE_MASK  0x00000A00  /* timeslice bits           */
     50#define RTEMS_ASR_MASK        0x00000400  /* RTEMS_ASR enable bit     */
    4551#define RTEMS_INTERRUPT_MASK  CPU_MODES_INTERRUPT_MASK
    4652
    4753#define RTEMS_PREEMPT      0x00000000     /* enable preemption        */
    4854#define RTEMS_NO_PREEMPT   0x00000100     /* disable preemption       */
    4955
    50 #define RTEMS_NO_TIMESLICE 0x00000000     /* disable timeslicing      */
    51 #define RTEMS_TIMESLICE    0x00000200     /* enable timeslicing       */
     56#define RTEMS_NO_TIMESLICE      0x00000000 /* disable timeslicing     */
     57#define RTEMS_TIMESLICE         0x00000200 /* use basic timeslicing   */
     58#define RTEMS_TIMESLICE_EXHAUST 0x00000800 /* POSIX SCHED_RR          */
    5259
    53 #define RTEMS_ASR          0x00000000     /* enable RTEMS_ASR               */
    54 #define RTEMS_NO_ASR       0x00000400     /* disable RTEMS_ASR              */
     60#define RTEMS_ASR          0x00000000     /* enable RTEMS_ASR         */
     61#define RTEMS_NO_ASR       0x00000400     /* disable RTEMS_ASR        */
    5562
    5663/*
    5764 *  The number of bits for interrupt levels is CPU dependent.
  • CPUKIT/RTEMS/INLINE/RTEMS/RTEMS/MODES.INL

    diff -x *~ -N -P -r -u rtems-orig/CPUKIT/RTEMS/INLINE/RTEMS/RTEMS/MODES.INL rtems/CPUKIT/RTEMS/INLINE/RTEMS/RTEMS/MODES.INL
    old new  
    7474 *
    7575 *  DESCRIPTION:
    7676 *
    77  *  This function returns TRUE if mode_set indicates that timeslicing
     77 *  This function returns TRUE if mode_set indicates that basic timeslicing
    7878 *  is enabled, and FALSE otherwise.
    7979 */
    8080
     
    8585  return (mode_set & RTEMS_TIMESLICE_MASK) == RTEMS_TIMESLICE;
    8686}
    8787
     88/*PAGE
     89 *
     90 *  _Modes_Is_timeslice_exhaust
     91 *
     92 *  DESCRIPTION:
     93 *
     94 *  This function returns TRUE if mode_set indicates that timeslicing
     95 *  as defined by POSIX SCHED_RR is enabled, and FALSE otherwise.
     96 */
     97
     98RTEMS_INLINE_ROUTINE boolean _Modes_Is_timeslice_exhaust (
     99  Modes_Control mode_set
     100)
     101{
     102  return (mode_set & RTEMS_TIMESLICE_MASK) == RTEMS_TIMESLICE_EXHAUST;
     103}
    88104/*PAGE
    89105 *
    90106 *  _Modes_Get_interrupt_level
  • CPUKIT/RTEMS/MACROS/RTEMS/RTEMS/MODES.INL

    diff -x *~ -N -P -r -u rtems-orig/CPUKIT/RTEMS/MACROS/RTEMS/RTEMS/MODES.INL rtems/CPUKIT/RTEMS/MACROS/RTEMS/RTEMS/MODES.INL
    old new  
    5454
    5555/*PAGE
    5656 *
     57 *  _Modes_Is_timeslice_exhaust
     58 *
     59 */
     60
     61#define _Modes_Is_timeslice_exhaust( _mode_set ) \
     62  (((_mode_set) & RTEMS_TIMESLICE_MASK) == RTEMS_TIMESLICE_EXHAUST)
     63
     64/*PAGE
     65 *
    5766 *  _Modes_Get_interrupt_level
    5867 *
    5968 */
  • CPUKIT/RTEMS/SRC/TASKMODE.C

    diff -x *~ -N -P -r -u rtems-orig/CPUKIT/RTEMS/SRC/TASKMODE.C rtems/CPUKIT/RTEMS/SRC/TASKMODE.C
    old new  
    8181  if ( mask & RTEMS_PREEMPT_MASK )
    8282    executing->is_preemptible = _Modes_Is_preempt(mode_set) ? TRUE : FALSE;
    8383
    84   if ( mask & RTEMS_TIMESLICE_MASK ) {
    85     if ( _Modes_Is_timeslice(mode_set) )
    86       executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
    87     else
     84  switch ( mode_set & RTEMS_TIMESLICE_MASK ) {
     85      break;
     86    case RTEMS_TIMESLICE:
     87      executing->budget_algorithm =
     88        THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
     89      break;
     90    case RTEMS_TIMESLICE_EXHAUST:
     91      executing->budget_algorithm =
     92        THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE;
     93      break;
     94    case RTEMS_NO_TIMESLICE:
     95    default:                 /* XXX default is an invalid case */
    8896      executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
     97      break;
    8998  }
    9099
    91100  /*
  • CPUKIT/RTEMS/SRC/taskcreate.c

    diff -x *~ -N -P -r -u rtems-orig/CPUKIT/RTEMS/SRC/taskcreate.c rtems/CPUKIT/RTEMS/SRC/taskcreate.c
    old new  
    169169   *  Initialize the core thread for this task.
    170170   */
    171171
     172  Thread_CPU_budget_algorithms budget_algorithm;
     173  budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
     174
     175  switch ( mode_set & RTEMS_TIMESLICE_MASK ) {
     176    case RTEMS_TIMESLICE:
     177      budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
     178      break;
     179    case RTEMS_TIMESLICE_EXHAUST:
     180      budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE;
     181      break;
     182    case RTEMS_NO_TIMESLICE:
     183    default:
     184      /* XXX this is an invalid case */
     185      break;
     186  }
     187
    172188  status = _Thread_Initialize(
    173189    &_RTEMS_tasks_Information,
    174190    the_thread,
     
    177193    is_fp,
    178194    core_priority,
    179195    _Modes_Is_preempt(initial_modes)   ? TRUE : FALSE,
    180     _Modes_Is_timeslice(initial_modes) ?
    181       THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE :
    182       THREAD_CPU_BUDGET_ALGORITHM_NONE,
     196    budget_algorithm,
    183197    NULL,        /* no budget algorithm callout */
    184198    _Modes_Get_interrupt_level(initial_modes),
    185199    (Objects_Name) name
  • DOC/USER/TASK.T

    diff -x *~ -N -P -r -u rtems-orig/DOC/USER/TASK.T rtems/DOC/USER/TASK.T
    old new  
    178178
    179179@cindex timeslicing
    180180
    181 The timeslicing component is used by the RTEMS scheduler to determine how
    182 the processor is allocated to tasks of equal priority.  If timeslicing is
    183 enabled (@code{@value{RPREFIX}TIMESLICE}), then RTEMS will limit the amount
    184 of time the task can execute before the processor is allocated to another
    185 ready task of equal priority. The length of the timeslice is application
    186 dependent and specified in the Configuration Table.  If timeslicing is
    187 disabled (@code{@value{RPREFIX}NO_TIMESLICE}), then the task will be
    188 allowed to execute until a task of higher priority is made ready.  If
    189 @code{@value{RPREFIX}NO_PREEMPT} is selected, then the timeslicing
    190 component is ignored by the scheduler.
     181If a task is preemptible, then the task's execution time may be limited
     182using timeslicing.  The timeslicing component of task mode is used by the
     183RTEMS scheduler to determine how the processor is allocated to
     184tasks of equal priority.  The length of the timeslice quantum is
     185application dependent and specified in the Configuration Table.  There
     186are three algorithms for timeslice management in the RTEMS Classic API.
     187
     188
     189@itemize @bullet
     190
     191@item If the (@code{@value{RPREFIX}NO_TIMESLICE}) is selected,
     192timeslicing is disabled.  Thus the task will be
     193allowed to execute until a task of higher priority is made ready. 
     194
     195@cindex SCHED_OTHER
     196
     197@item If the @code{@value{RPREFIX}TIMESLICE}) timeslicing algorithm
     198is enabled, then RTEMS will limit the amount of time the task
     199can execute before the processor is allocated to another
     200ready task of equal priority.  Each time a task using this algorithm
     201is context switched to it will have its timeslice replenished.  For
     202example, if the timeslicing quantum is ten milliseconds and the task
     203executes for five milliseconds before being context switched out, then
     204the next time it executes it will again be given a full ten millisecond
     205timeslice.  This is the same algorithm used by POSIX threads using
     206the @code{SCHED_OTHER} scheduling algorithm.  Note that the POSIX
     207standard does not specify the behavior of the @code{SCHED_OTHER}
     208algorithm, thus leaving it implementation defined.
     209
     210@cindex SCHED_RR
     211
     212@item If the @code{@value{RPREFIX}TIMESLICE_EXHAUST}) timeslicing algorithm
     213is enabled, then RTEMS will limit the amount of time the task
     214can execute before the processor is allocated to another
     215ready task of equal priority.  A task using this algorithm
     216will only have its timeslice replenished when it has been completely
     217used.  For example, if the timeslicing quantum is ten milliseconds and
     218the task executes for five milliseconds before being context switched out,
     219then the next time it executes it will only have five milliseconds
     220remaining in its timeslice.  This is the same algorithm used by POSIX
     221threads using the @code{SCHED_RR} scheduling algorithm.
     222
     223@end itemize
     224
     225If a task is not preemptible (e.g. @code{@value{RPREFIX}NO_PREEMPT}
     226is selected), then the timeslicing component is ignored by the scheduler.
    191227
    192228The asynchronous signal processing component is used to determine when
    193229received signals are to be processed by the task.
     
    209245@item @code{@value{RPREFIX}PREEMPT} - enable preemption (default)
    210246@item @code{@value{RPREFIX}NO_PREEMPT} - disable preemption
    211247@item @code{@value{RPREFIX}NO_TIMESLICE} - disable timeslicing (default)
    212 @item @code{@value{RPREFIX}TIMESLICE} - enable timeslicing
     248@item @code{@value{RPREFIX}TIMESLICE} - enable basic timeslicing
     249@item @code{@value{RPREFIX}TIMESLICE_EXHAUST} - enable POSIX style timeslicing
    213250@item @code{@value{RPREFIX}ASR} - enable ASR processing (default)
    214251@item @code{@value{RPREFIX}NO_ASR} - disable ASR processing
    215252@item @code{@value{RPREFIX}INTERRUPT_LEVEL(0)} - enable all interrupts (default)
     
    395432@code{@value{RPREFIX}TIMESLICE_MASK} and disables timeslicing
    396433
    397434@item @code{@value{RPREFIX}TIMESLICE} is masked by
    398 @code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing
     435@code{@value{RPREFIX}TIMESLICE_MASK} and enables basic timeslicing
     436
     437@item @code{@value{RPREFIX}TIMESLICE} is masked by
     438@code{@value{RPREFIX}TIMESLICE_EXHAUST} and enables POSIX style timeslicing
    399439
    400440@item @code{@value{RPREFIX}ASR} is masked by
    401441@code{@value{RPREFIX}ASR_MASK} and enables ASR processing
     
    426466
    427467@item @code{@value{RPREFIX}TIMESLICE} is masked by
    428468@code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing
     469with automatic timeslice replenishment.
     470
     471@item @code{@value{RPREFIX}TIMESLICE} is masked by
     472@code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing
     473with timeslice replenishment only when consumed.
    429474
    430475@item @code{@value{RPREFIX}ASR} is masked by
    431476@code{@value{RPREFIX}ASR_MASK} and enables ASR processing
     
    463508    <TD ALIGN=center>disables timeslicing</TD></TR>
    464509<TR><TD ALIGN=center>@value{RPREFIX}TIMESLICE</TD>
    465510    <TD ALIGN=center>@value{RPREFIX}TIMESLICE_MASK</TD>
    466     <TD ALIGN=center>enables timeslicing</TD></TR>
     511    <TD ALIGN=center>enables timeslicing with automatic replenishment</TD></TR>
     512<TR><TD ALIGN=center>@value{RPREFIX}TIMESLICE_EXHAUST</TD>
     513    <TD ALIGN=center>@value{RPREFIX}TIMESLICE_MASK</TD>
     514    <TD ALIGN=center>enables timeslicing with replenishment only when consumed</TD></TR>
    467515<TR><TD ALIGN=center>@value{RPREFIX}ASR</TD>
    468516    <TD ALIGN=center>@value{RPREFIX}ASR_MASK</TD>
    469517    <TD ALIGN=center>enables ASR processing</TD></TR>
     
    12411289@cindex current task mode
    12421290@cindex set task mode
    12431291@cindex get task mode
     1292@cindex set task timeslicing mode
     1293@cindex get task timeslicing mode
    12441294@cindex set task preemption mode
    12451295@cindex get task preemption mode
    12461296@cindex obtain task mode
     
    13121362@code{@value{RPREFIX}TIMESLICE_MASK} and disables timeslicing
    13131363
    13141364@item @code{@value{RPREFIX}TIMESLICE} is masked by
    1315 @code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing
     1365@code{@value{RPREFIX}TIMESLICE_MASK} and enables basic timeslicing
     1366with automatic timeslice replenishment.
     1367
     1368@item @code{@value{RPREFIX}TIMESLICE_EXHAUST} is masked by
     1369@code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing
     1370with timeslice replenishment only when it has been consumed.
    13161371
    13171372@item @code{@value{RPREFIX}ASR} is masked by
    13181373@code{@value{RPREFIX}ASR_MASK} and enables ASR processing