Changeset 0faa9dad in rtems


Ignore:
Timestamp:
Nov 24, 2010, 3:51:28 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
db9964f1
Parents:
505866a0
Message:

2010-11-24 Gedare Bloom <giddyup44@…>

PR 1647/cpukit

  • posix/src/nanosleep.c, posix/src/sched_yield.c, rtems/src/taskwakeafter.c, sapi/include/confdefs.h, sapi/include/rtems/config.h, sapi/src/exinit.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/prioritybitmap.h, score/include/rtems/score/thread.h, score/inline/rtems/score/thread.inl, score/src/thread.c, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadclose.c, score/src/threadinitialize.c, score/src/threadready.c, score/src/threadresume.c, score/src/threadsetpriority.c, score/src/threadsetstate.c, score/src/threadsettransient.c, score/src/threadsuspend.c, score/src/threadtickletimeslice.c: Refactor scheduler out of thread handler to facilitate alternate scheduler implementations.
  • score/src/threadyieldprocessor.c: Removed.
  • score/src/schedulerprioritythreadschedulerupdate.c, score/src/schedulerprioritythreadschedulerfree.c, score/src/schedulerpriorityblock.c, score/src/scheduler.c, score/src/schedulerprioritythreadschedulerallocate.c, score/src/schedulerpriorityunblock.c, score/src/schedulerpriority.c, score/src/schedulerpriorityyield.c, score/include/rtems/score/schedulerpriority.h, score/include/rtems/score/scheduler.h, score/inline/rtems/score/scheduler.inl, score/inline/rtems/score/schedulerpriority.inl: New files.
Location:
cpukit
Files:
13 added
24 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r505866a0 r0faa9dad  
     12010-11-24      Gedare Bloom <giddyup44@yahoo.com>
     2
     3        PR 1647/cpukit
     4        * posix/src/nanosleep.c, posix/src/sched_yield.c,
     5        rtems/src/taskwakeafter.c, sapi/include/confdefs.h,
     6        sapi/include/rtems/config.h, sapi/src/exinit.c, score/Makefile.am,
     7        score/preinstall.am, score/include/rtems/score/prioritybitmap.h,
     8        score/include/rtems/score/thread.h,
     9        score/inline/rtems/score/thread.inl, score/src/thread.c,
     10        score/src/threadchangepriority.c, score/src/threadclearstate.c,
     11        score/src/threadclose.c, score/src/threadinitialize.c,
     12        score/src/threadready.c, score/src/threadresume.c,
     13        score/src/threadsetpriority.c, score/src/threadsetstate.c,
     14        score/src/threadsettransient.c, score/src/threadsuspend.c,
     15        score/src/threadtickletimeslice.c: Refactor scheduler out of thread
     16        handler to facilitate alternate scheduler implementations.
     17        * score/src/threadyieldprocessor.c: Removed.
     18        * score/src/schedulerprioritythreadschedulerupdate.c,
     19        score/src/schedulerprioritythreadschedulerfree.c,
     20        score/src/schedulerpriorityblock.c, score/src/scheduler.c,
     21        score/src/schedulerprioritythreadschedulerallocate.c,
     22        score/src/schedulerpriorityunblock.c,
     23        score/src/schedulerpriority.c, score/src/schedulerpriorityyield.c,
     24        score/include/rtems/score/schedulerpriority.h,
     25        score/include/rtems/score/scheduler.h,
     26        score/inline/rtems/score/scheduler.inl,
     27        score/inline/rtems/score/schedulerpriority.inl: New files.
     28
    1292010-11-23      Sebastian Huber <sebastian.huber@embedded-brains.de>
    230
  • cpukit/posix/src/nanosleep.c

    r505866a0 r0faa9dad  
    1919#include <rtems/system.h>
    2020#include <rtems/score/isr.h>
     21#include <rtems/score/scheduler.h>
    2122#include <rtems/score/thread.h>
    2223#include <rtems/score/tod.h>
     
    5758  if ( !ticks ) {
    5859    _Thread_Disable_dispatch();
    59       _Thread_Yield_processor();
     60      _Scheduler_Yield();
    6061    _Thread_Enable_dispatch();
    6162    if ( rmtp ) {
  • cpukit/posix/src/sched_yield.c

    r505866a0 r0faa9dad  
    2020
    2121#include <rtems/system.h>
     22#include <rtems/score/scheduler.h>
    2223#include <rtems/score/tod.h>
    2324#include <rtems/score/thread.h>
     
    2930{
    3031  _Thread_Disable_dispatch();
    31     _Thread_Yield_processor();
     32    _Scheduler_Yield();
    3233  _Thread_Enable_dispatch();
    3334  return 0;
  • cpukit/rtems/src/taskwakeafter.c

    r505866a0 r0faa9dad  
    2222#include <rtems/rtems/modes.h>
    2323#include <rtems/score/object.h>
     24#include <rtems/score/scheduler.h>
    2425#include <rtems/score/stack.h>
    2526#include <rtems/score/states.h>
     
    5354  _Thread_Disable_dispatch();
    5455    if ( ticks == 0 ) {
    55       _Thread_Yield_processor();
     56      _Scheduler_Yield();
    5657    } else {
    5758      _Thread_Set_state( _Thread_Executing, STATES_DELAYING );
  • cpukit/sapi/include/confdefs.h

    r505866a0 r0faa9dad  
    536536
    537537/*
     538 * Scheduler configuration.
     539 *
     540 * The scheduler configuration allows an application to select the
     541 * scheduling policy to use.  The supported configurations are:
     542 *  CONFIGURE_SCHEDULER_USER
     543 *  CONFIGURE_SCHEDULER_PRIORITY
     544 *
     545 * If no configuration is specified by the application, then
     546 * CONFIGURE_SCHEDULER_PRIORITY is assumed to be the default.
     547 *
     548 * An application can define its own scheduling policy by defining
     549 * CONFIGURE_SCHEDULER_USER and CONFIGURE_SCHEDULER_ENTRY_USER to point
     550 * to an initialization routine.  Note: CONFIGURE_SCHEDULER_USER is not
     551 * fully supported, since it has no per-thread field.
     552 *
     553 * To add a new scheduler:
     554 */
     555#include <rtems/score/scheduler.h>
     556
     557#if defined(CONFIGURE_SCHEDULER_USER) && \
     558    !defined(CONFIGURE_SCHEDULER_ENTRY_USER)
     559  #error "CONFIGURE_ERROR: CONFIGURE_SCHEDULER_USER without CONFIGURE_SCHEDULER_ENTRY_USER"
     560#endif
     561
     562/* enable all RTEMS-provided schedulers */
     563#if defined(CONFIGURE_SCHEDULER_ALL)
     564  #define CONFIGURE_SCHEDULER_PRIORITY
     565#endif
     566
     567/* If no scheduler is specified, the priority scheduler is default. */
     568#if !defined(CONFIGURE_SCHEDULER_USER) && \
     569    !defined(CONFIGURE_SCHEDULER_PRIORITY)
     570  #define CONFIGURE_SCHEDULER_PRIORITY
     571  #define CONFIGURE_SCHEDULER_POLICY _Scheduler_PRIORITY
     572#endif
     573
     574/*
     575 * If a user scheduler is specified and no policy is set,
     576 * the user scheduler is the default policy.
     577 */
     578#if defined(CONFIGURE_SCHEDULER_USER) && \
     579    !defined(CONFIGURE_SCHEDULER_POLICY)
     580  #define CONFIGURE_SCHEDULER_POLICY _Scheduler_USER
     581#endif
     582
     583/*
     584 * Check for priority scheduler next, as it is the default policy if there
     585 * is no CONFIGURE_SCHEDULER_POLICY set and no USER scheduler provided.
     586 */
     587#if defined(CONFIGURE_SCHEDULER_PRIORITY)
     588  #include <rtems/score/schedulerpriority.h>
     589  #define CONFIGURE_SCHEDULER_ENTRY_PRIORITY { _Scheduler_priority_Initialize }
     590  #if !defined(CONFIGURE_SCHEDULER_POLICY)
     591    #define CONFIGURE_SCHEDULER_POLICY _Scheduler_PRIORITY
     592  #endif
     593
     594  /**
     595   * define the memory used by the priority scheduler
     596   */
     597  #define CONFIGURE_MEMORY_SCHEDULER_PRIORITY ( \
     598    _Configure_From_workspace( \
     599      ((CONFIGURE_MAXIMUM_PRIORITY+1) * sizeof(Chain_Control)) ) \
     600  )
     601  #define CONFIGURE_MEMORY_PER_TASK_SCHEDULER_PRIORITY ( \
     602    _Configure_From_workspace(sizeof(Scheduler_priority_Per_thread)) )
     603#endif
     604
     605/*
     606 * Set up the scheduler table.  The scheduling code indexes this table to
     607 * invoke the correct scheduling implementation. The scheduler to use is
     608 * determined by the Configuration.scheduler_policy field, which is set
     609 * by CONFIGURE_SCHEDULER_POLICY.  If a particular scheduler is not enabled,
     610 * an empty entry is included in its entry in the scheduler table.
     611 */
     612
     613  /**
     614   * An empty scheduler entry
     615   */
     616  #define CONFIGURE_SCHEDULER_NULL { NULL }
     617
     618#ifdef CONFIGURE_INIT
     619  /* the table of available schedulers. */
     620  const Scheduler_Table_t _Scheduler_Table[] = {
     621    #if defined(CONFIGURE_SCHEDULER_USER) && \
     622        defined(CONFIGURE_SCHEDULER_ENTRY_USER)
     623      CONFIGURE_SCHEDULER_ENTRY_USER,
     624    #else
     625      CONFIGURE_SCHEDULER_NULL,
     626    #endif
     627    #if defined(CONFIGURE_SCHEDULER_PRIORITY) && \
     628        defined(CONFIGURE_SCHEDULER_ENTRY_PRIORITY)
     629      CONFIGURE_SCHEDULER_ENTRY_PRIORITY,
     630    #else
     631      CONFIGURE_SCHEDULER_NULL,
     632    #endif
     633  };
     634#endif
     635
     636/**
     637 * Define the memory overhead for the scheduler
     638 */
     639#define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
     640    CONFIGURE_MEMORY_SCHEDULER_PRIORITY \
     641  )
     642
     643#define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
     644    CONFIGURE_MEMORY_PER_TASK_SCHEDULER_PRIORITY \
     645  )
     646
     647/*
    538648 *  If you said the IDLE task was going to do application initialization
    539649 *  and didn't override the IDLE body, then something is amiss.
     
    16081718    CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API + \
    16091719    CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB + \
    1610     CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API))  + \
     1720    CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API + \
     1721    CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER))  + \
    16111722  _Configure_From_workspace( \
    16121723    _Configure_Max_Objects(_number_FP_tasks) * CONTEXT_FP_SIZE) + \
     
    17061817
    17071818/**
    1708  *  This defines the memory used by the thread ready chains.  There is
    1709  *  one chain per priority.
    1710  */
    1711 #define CONFIGURE_MEMORY_FOR_THREAD_READY_CHAINS \
    1712     _Configure_From_workspace( \
    1713         ((CONFIGURE_MAXIMUM_PRIORITY+1) * sizeof(Chain_Control)) )
    1714 /**
    17151819 *  This defines the amount of memory reserved for the IDLE task
    17161820 *  control structures and stack.
     
    17251829#define CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \
    17261830  ( CONFIGURE_MEMORY_FOR_IDLE_TASK +                /* IDLE and stack */ \
    1727     CONFIGURE_MEMORY_FOR_THREAD_READY_CHAINS +     /* Ready chains */ \
     1831    CONFIGURE_MEMORY_FOR_SCHEDULER +                /* Scheduler */ \
    17281832    CONFIGURE_INTERRUPT_VECTOR_TABLE +             /* interrupt vectors */ \
    17291833    CONFIGURE_INTERRUPT_STACK_MEMORY +             /* interrupt stack */ \
     
    20062110    CONFIGURE_MICROSECONDS_PER_TICK,          /* microseconds per clock tick */
    20072111    CONFIGURE_TICKS_PER_TIMESLICE,            /* ticks per timeslice quantum */
     2112    CONFIGURE_SCHEDULER_POLICY,               /* scheduling policy */
    20082113    CONFIGURE_IDLE_TASK_BODY,                 /* user's IDLE task */
    20092114    CONFIGURE_IDLE_TASK_STACK_SIZE,           /* IDLE task stack size */
  • cpukit/sapi/include/rtems/config.h

    r505866a0 r0faa9dad  
    119119  uint32_t                       ticks_per_timeslice;
    120120
     121  /** This field specifies the scheduling policy to use.
     122   */
     123  uint32_t                       scheduler_policy;
     124
    121125  /** This element points to the BSP's optional idle task which may override
    122126   *  the default one provided with RTEMS.
  • cpukit/sapi/src/exinit.c

    r505866a0 r0faa9dad  
    4343#endif
    4444#include <rtems/score/priority.h>
    45 #include <rtems/score/prioritybitmap.h>
     45#include <rtems/score/scheduler.h>
    4646#include <rtems/score/thread.h>
    4747#include <rtems/score/tod.h>
     
    132132  _Thread_Handler_initialization();
    133133
     134  _Scheduler_Handler_initialization();
     135
    134136  #if defined(RTEMS_MULTIPROCESSING)
    135137    _Objects_MP_Handler_initialization();
  • cpukit/score/Makefile.am

    r505866a0 r0faa9dad  
    2727    include/rtems/score/object.h include/rtems/score/percpu.h \
    2828    include/rtems/score/priority.h include/rtems/score/prioritybitmap.h \
     29    include/rtems/score/scheduler.h include/rtems/score/schedulerpriority.h \
    2930    include/rtems/score/stack.h include/rtems/score/states.h \
    3031    include/rtems/score/sysstate.h include/rtems/score/thread.h \
     
    5556    inline/rtems/score/isr.inl inline/rtems/score/object.inl \
    5657    inline/rtems/score/priority.inl inline/rtems/score/prioritybitmap.inl \
     58    inline/rtems/score/scheduler.inl inline/rtems/score/schedulerpriority.inl \
    5759    inline/rtems/score/stack.inl inline/rtems/score/states.inl \
    5860    inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
     
    137139    src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
    138140    src/objectnamespaceremove.c
     141
     142## SCHEDULER_C_FILES
     143libscore_a_SOURCES += src/scheduler.c
     144
     145## SCHEDULERPRIORITY_C_FILES
     146libscore_a_SOURCES += src/schedulerpriority.c \
     147                                                                                        src/schedulerpriorityblock.c \
     148                      src/schedulerprioritythreadschedulerallocate.c \
     149                      src/schedulerprioritythreadschedulerfree.c \
     150                      src/schedulerprioritythreadschedulerupdate.c \
     151                                                                                        src/schedulerpriorityschedule.c \
     152                                                                                        src/schedulerpriorityunblock.c \
     153                                                                                        src/schedulerpriorityyield.c
    139154
    140155## PROTECTED_HEAP_C_FILES
     
    154169    src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \
    155170    src/threadstartmultitasking.c src/threadsuspend.c \
    156     src/threadtickletimeslice.c src/threadyieldprocessor.c \
     171    src/threadtickletimeslice.c \
    157172    src/iterateoverthreads.c src/threadblockingoperationcancel.c
    158173
  • cpukit/score/include/rtems/score/prioritybitmap.h

    r505866a0 r0faa9dad  
    3838#include <rtems/score/priority.h>
    3939
     40
    4041/*
    41  * TODO:
    42  * These should only be instantiated if using the bit map handler.  The
    43  * logical place for this is in confdefs.h when a scheduler that uses the
    44  * bit map handler is configured.
     42 * The Priority_bit_map_Control variables are instantiated only
     43 * if using the bit map handler.
    4544 */
    4645
     
    4948 *  the sixteen entries in the Priority Bit map.
    5049 */
    51 SCORE_EXTERN volatile Priority_bit_map_Control _Priority_Major_bit_map;
     50extern volatile Priority_bit_map_Control _Priority_Major_bit_map;
    5251
    5352/** Each bit in the Priority Bitmap indicates whether or not there are
     
    5756 *  threads are ready at that priority.
    5857 */
    59 SCORE_EXTERN Priority_bit_map_Control
     58extern Priority_bit_map_Control
    6059               _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
    6160
  • cpukit/score/include/rtems/score/thread.h

    r505866a0 r0faa9dad  
    7171#include <rtems/score/object.h>
    7272#include <rtems/score/priority.h>
    73 #include <rtems/score/prioritybitmap.h>
     73#include <rtems/score/scheduler.h>
    7474#include <rtems/score/stack.h>
    7575#include <rtems/score/states.h>
     
    391391   */
    392392  Thread_CPU_usage_t                    cpu_time_used;
    393   /** This field points to the Ready FIFO for this priority. */
    394   Chain_Control                        *ready;
    395   /** This field contains precalculated priority map indices. */
    396   Priority_bit_map_Information          Priority_map;
     393  /** This union holds per-thread data for the scheduler and ready queue. */
     394  union {
     395    Scheduler_priority_Per_thread      *priority;
     396  } scheduler;
    397397  /** This field contains information about the starting state of
    398398   *  this thread.
     
    455455 */
    456456SCORE_EXTERN uint32_t   _Thread_Ticks_per_timeslice;
    457 
    458 /**
    459  *  The following points to the array of FIFOs used to manage the
    460  *  set of ready threads.
    461  */
    462 SCORE_EXTERN Chain_Control *_Thread_Ready_chain;
    463457
    464458/**
     
    655649
    656650/**
    657  *  This routine is invoked when a thread wishes to voluntarily
    658  *  transfer control of the processor to another thread of equal
    659  *  or greater priority.
    660  */
    661 void _Thread_Yield_processor( void );
    662 
    663 /**
    664651 *  This routine initializes the context of the_thread to its
    665652 *  appropriate starting state.
  • cpukit/score/inline/rtems/score/thread.inl

    r505866a0 r0faa9dad  
    118118
    119119  _CPU_Context_Restart_self( &_Thread_Executing->Registers );
    120 }
    121 
    122 /**
    123  *  This function returns a pointer to the highest priority
    124  *  ready thread.
    125  */
    126 
    127 RTEMS_INLINE_ROUTINE void _Thread_Calculate_heir( void )
    128 {
    129   _Thread_Heir = (Thread_Control *)
    130     _Thread_Ready_chain[ _Priority_bit_map_Get_highest() ].first;
    131120}
    132121
  • cpukit/score/preinstall.am

    r505866a0 r0faa9dad  
    112112PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h
    113113
     114$(PROJECT_INCLUDE)/rtems/score/scheduler.h: include/rtems/score/scheduler.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     115        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduler.h
     116PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduler.h
     117
     118$(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h: include/rtems/score/schedulerpriority.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     119        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h
     120PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h
     121
    114122$(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    115123        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h
     
    246254PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl
    247255
     256$(PROJECT_INCLUDE)/rtems/score/scheduler.inl: inline/rtems/score/scheduler.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     257        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduler.inl
     258PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduler.inl
     259
     260$(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl: inline/rtems/score/schedulerpriority.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     261        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl
     262PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl
     263
    248264$(PROJECT_INCLUDE)/rtems/score/stack.inl: inline/rtems/score/stack.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    249265        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl
  • cpukit/score/src/thread.c

    r505866a0 r0faa9dad  
    2525#include <rtems/score/object.h>
    2626#include <rtems/score/priority.h>
     27#include <rtems/score/scheduler.h>
    2728#include <rtems/score/states.h>
    2829#include <rtems/score/sysstate.h>
     
    4647void _Thread_Handler_initialization(void)
    4748{
    48   uint32_t     index;
    4949  uint32_t     ticks_per_timeslice;
    5050  uint32_t     maximum_extensions;
     
    8181  _Thread_Ticks_per_timeslice  = ticks_per_timeslice;
    8282
    83   _Thread_Ready_chain = (Chain_Control *) _Workspace_Allocate_or_fatal_error(
    84     (PRIORITY_MAXIMUM + 1) * sizeof(Chain_Control)
    85   );
    86 
    87   for ( index=0; index <= PRIORITY_MAXIMUM ; index++ )
    88     _Chain_Initialize_empty( &_Thread_Ready_chain[ index ] );
    89 
    9083#if defined(RTEMS_MULTIPROCESSING)
    9184  _Thread_MP_Handler_initialization( maximum_proxies );
  • cpukit/score/src/threadchangepriority.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
     27#include <rtems/score/schedulerpriority.h>
    2628#include <rtems/score/states.h>
    2729#include <rtems/score/sysstate.h>
     
    118120     *  the TRANSIENT state.  So we have to place it on the appropriate
    119121     *  Ready Queue with interrupts off.
     122     *
     123     *  FIXME: hard-coded for priority scheduling. Might be ok since this
     124     *  function is specific to priority scheduling?
    120125     */
    121126    the_thread->current_state = _States_Clear( STATES_TRANSIENT, state );
    122127
    123     _Priority_bit_map_Add( &the_thread->Priority_map );
    124128    if ( prepend_it )
    125       _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node );
     129      _Scheduler_priority_Ready_queue_enqueue_first( the_thread );
    126130    else
    127       _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
     131      _Scheduler_priority_Ready_queue_enqueue( the_thread );
    128132  }
    129133
     
    134138   *  who is the heir and if we need to switch to them.
    135139   */
    136   _Thread_Calculate_heir();
     140  _Scheduler_Schedule(&_Scheduler);
    137141
    138142  if ( !_Thread_Is_executing_also_the_heir() &&
  • cpukit/score/src/threadclearstate.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    6768
    6869      if ( _States_Is_ready( current_state ) ) {
    69 
    70         _Priority_bit_map_Add( &the_thread->Priority_map );
    71 
    72         _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
    73 
    74         _ISR_Flash( level );
    75 
    76         /*
    77          *  If the thread that was unblocked is more important than the heir,
    78          *  then we have a new heir.  This may or may not result in a
    79          *  context switch.
    80          *
    81          *  Normal case:
    82          *    If the current thread is preemptible, then we need to do
    83          *    a context switch.
    84          *  Pseudo-ISR case:
    85          *    Even if the thread isn't preemptible, if the new heir is
    86          *    a pseudo-ISR system task, we need to do a context switch.
    87          */
    88         if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
    89           _Thread_Heir = the_thread;
    90           if ( _Thread_Executing->is_preemptible ||
    91                the_thread->current_priority == 0 )
    92             _Thread_Dispatch_necessary = true;
    93         }
     70        _Scheduler_Unblock( &_Scheduler, the_thread);
    9471      }
    9572  }
  • cpukit/score/src/threadclose.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    8788
    8889  /*
     90   * Free the per-thread scheduling information.
     91   */
     92  _Scheduler_Thread_scheduler_free( &_Scheduler, the_thread );
     93
     94  /*
    8995   *  The thread might have been FP.  So deal with that.
    9096   */
  • cpukit/score/src/threadinitialize.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    6162    void              *fp_area;
    6263  #endif
     64  void                *sched = NULL;
    6365  void                *extensions_area;
    6466  bool                 extension_status;
     
    193195  the_thread->real_priority           = priority;
    194196  the_thread->Start.initial_priority  = priority;
     197  sched =_Scheduler_Thread_scheduler_allocate( &_Scheduler, the_thread );
     198  if ( !sched )
     199    goto failed;
    195200  _Thread_Set_priority( the_thread, priority );
    196201
     
    236241  #endif
    237242
     243  if ( sched )
     244    (void) _Workspace_Free( sched );
     245
    238246   _Thread_Stack_Free( the_thread );
    239247  return false;
  • cpukit/score/src/threadready.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    5657{
    5758  ISR_Level              level;
    58   Thread_Control *heir;
    5959
    6060  _ISR_Disable( level );
     
    6262  the_thread->current_state = STATES_READY;
    6363
    64   _Priority_bit_map_Add( &the_thread->Priority_map );
    65 
    66   _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
    67 
    68   _ISR_Flash( level );
    69 
    70   _Thread_Calculate_heir();
    71 
    72   heir = _Thread_Heir;
    73 
    74   if ( !_Thread_Is_executing( heir ) && _Thread_Executing->is_preemptible )
    75     _Thread_Dispatch_necessary = true;
     64  _Scheduler_Unblock( &_Scheduler, the_thread );
    7665
    7766  _ISR_Enable( level );
  • cpukit/score/src/threadresume.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    6970
    7071    if ( _States_Is_ready( current_state ) ) {
    71 
    72       _Priority_bit_map_Add( &the_thread->Priority_map );
    73 
    74       _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
    75 
    76       _ISR_Flash( level );
    77 
    78       if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
    79         _Thread_Heir = the_thread;
    80         if ( _Thread_Executing->is_preemptible ||
    81              the_thread->current_priority == 0 )
    82           _Thread_Dispatch_necessary = true;
    83       }
     72      _Scheduler_Unblock( &_Scheduler, the_thread );
    8473    }
    8574  }
  • cpukit/score/src/threadsetpriority.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    5152{
    5253  the_thread->current_priority = new_priority;
    53   the_thread->ready            = &_Thread_Ready_chain[ new_priority ];
    5454
    55   _Priority_bit_map_Initialize_information(
    56       &the_thread->Priority_map,
    57       new_priority
    58   );
     55  _Scheduler_Thread_scheduler_update(&_Scheduler, the_thread);
    5956}
  • cpukit/score/src/threadsetstate.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    5556{
    5657  ISR_Level      level;
    57   Chain_Control *ready;
    58 
    59   ready = the_thread->ready;
     58 
    6059  _ISR_Disable( level );
    6160  if ( !_States_Is_ready( the_thread->current_state ) ) {
     
    6867  the_thread->current_state = state;
    6968
    70   if ( _Chain_Has_only_one_node( ready ) ) {
    71 
    72     _Chain_Initialize_empty( ready );
    73     _Priority_bit_map_Remove( &the_thread->Priority_map );
    74 
    75   } else
    76     _Chain_Extract_unprotected( &the_thread->Object.Node );
    77 
    78   _ISR_Flash( level );
    79 
    80   if ( _Thread_Is_heir( the_thread ) )
    81      _Thread_Calculate_heir();
    82 
    83   if ( _Thread_Is_executing( the_thread ) )
    84     _Thread_Dispatch_necessary = true;
     69  _Scheduler_Block( &_Scheduler, the_thread);
    8570
    8671  _ISR_Enable( level );
  • cpukit/score/src/threadsettransient.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
     27#include <rtems/score/schedulerpriority.h>
    2628#include <rtems/score/states.h>
    2729#include <rtems/score/sysstate.h>
     
    5557  ISR_Level             level;
    5658  uint32_t              old_state;
    57   Chain_Control *ready;
    58 
    59   ready = the_thread->ready;
     59 
    6060  _ISR_Disable( level );
    6161
     
    6363  the_thread->current_state = _States_Set( STATES_TRANSIENT, old_state );
    6464
     65  /* FIXME: need to check which scheduler to use? */
    6566  if ( _States_Is_ready( old_state ) ) {
    66     if ( _Chain_Has_only_one_node( ready ) ) {
    67 
    68       _Chain_Initialize_empty( ready );
    69       _Priority_bit_map_Remove( &the_thread->Priority_map );
    70 
    71     } else
    72       _Chain_Extract_unprotected( &the_thread->Object.Node );
     67    _Scheduler_priority_Ready_queue_extract( the_thread);
    7368  }
    7469
  • cpukit/score/src/threadsuspend.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    5354{
    5455  ISR_Level      level;
    55   Chain_Control *ready;
    56 
    57   ready = the_thread->ready;
     56 
    5857  _ISR_Disable( level );
    5958  if ( !_States_Is_ready( the_thread->current_state ) ) {
     
    6665  the_thread->current_state = STATES_SUSPENDED;
    6766
    68   if ( _Chain_Has_only_one_node( ready ) ) {
    69 
    70     _Chain_Initialize_empty( ready );
    71     _Priority_bit_map_Remove( &the_thread->Priority_map );
    72 
    73   } else
    74     _Chain_Extract_unprotected( &the_thread->Object.Node );
    75 
    76   _ISR_Flash( level );
    77 
    78   if ( _Thread_Is_heir( the_thread ) )
    79      _Thread_Calculate_heir();
    80 
    81   if ( _Thread_Is_executing( the_thread ) )
    82     _Thread_Dispatch_necessary = true;
     67  _Scheduler_Block(&_Scheduler, the_thread);
    8368
    8469  _ISR_Enable( level );
  • cpukit/score/src/threadtickletimeslice.c

    r505866a0 r0faa9dad  
    2424#include <rtems/score/object.h>
    2525#include <rtems/score/priority.h>
     26#include <rtems/score/scheduler.h>
    2627#include <rtems/score/states.h>
    2728#include <rtems/score/sysstate.h>
     
    9091         *  FIFO for this priority and a new heir is selected.
    9192         */
    92         _Thread_Yield_processor();
     93        _Scheduler_Yield( );
    9394        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
    9495      }
Note: See TracChangeset for help on using the changeset viewer.