change log for rtems (2010-11-24)

rtems-vc at rtems.org rtems-vc at rtems.org
Wed Nov 24 16:10:46 UTC 2010


 *joel*:
2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>

	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.

M 1.2655  cpukit/ChangeLog
M   1.12  cpukit/posix/src/nanosleep.c
M    1.2  cpukit/posix/src/sched_yield.c
M    1.5  cpukit/rtems/src/taskwakeafter.c
M  1.151  cpukit/sapi/include/confdefs.h
M   1.54  cpukit/sapi/include/rtems/config.h
M   1.56  cpukit/sapi/src/exinit.c
M   1.89  cpukit/score/Makefile.am
M    1.2  cpukit/score/include/rtems/score/prioritybitmap.h
A    1.1  cpukit/score/include/rtems/score/scheduler.h
A    1.1  cpukit/score/include/rtems/score/schedulerpriority.h
M   1.98  cpukit/score/include/rtems/score/thread.h
A    1.1  cpukit/score/inline/rtems/score/scheduler.inl
A    1.1  cpukit/score/inline/rtems/score/schedulerpriority.inl
M   1.44  cpukit/score/inline/rtems/score/thread.inl
M   1.25  cpukit/score/preinstall.am
A    1.1  cpukit/score/src/scheduler.c
A    1.1  cpukit/score/src/schedulerpriority.c
A    1.1  cpukit/score/src/schedulerpriorityblock.c
A    1.1  cpukit/score/src/schedulerpriorityschedule.c
A    1.1  cpukit/score/src/schedulerprioritythreadschedulerallocate.c
A    1.1  cpukit/score/src/schedulerprioritythreadschedulerfree.c
A    1.1  cpukit/score/src/schedulerprioritythreadschedulerupdate.c
A    1.1  cpukit/score/src/schedulerpriorityunblock.c
A    1.1  cpukit/score/src/schedulerpriorityyield.c
M   1.65  cpukit/score/src/thread.c
M   1.15  cpukit/score/src/threadchangepriority.c
M   1.13  cpukit/score/src/threadclearstate.c
M   1.13  cpukit/score/src/threadclose.c
M   1.40  cpukit/score/src/threadinitialize.c
M   1.10  cpukit/score/src/threadready.c
M   1.13  cpukit/score/src/threadresume.c
M    1.6  cpukit/score/src/threadsetpriority.c
M    1.9  cpukit/score/src/threadsetstate.c
M    1.7  cpukit/score/src/threadsettransient.c
M   1.10  cpukit/score/src/threadsuspend.c
M   1.13  cpukit/score/src/threadtickletimeslice.c

diff -u rtems/cpukit/ChangeLog:1.2654 rtems/cpukit/ChangeLog:1.2655
--- rtems/cpukit/ChangeLog:1.2654	Tue Nov 23 17:44:06 2010
+++ rtems/cpukit/ChangeLog	Wed Nov 24 09:51:26 2010
@@ -1,3 +1,31 @@
+2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>
+
+	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.
+
 2010-11-23	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
 	* score/src/iterateoverthreads.c, libmisc/cpuuse/cpuusagereport.c:

diff -u rtems/cpukit/posix/src/nanosleep.c:1.11 rtems/cpukit/posix/src/nanosleep.c:1.12
--- rtems/cpukit/posix/src/nanosleep.c:1.11	Tue Jun 22 10:36:06 2010
+++ rtems/cpukit/posix/src/nanosleep.c	Wed Nov 24 09:51:27 2010
@@ -18,6 +18,7 @@
 
 #include <rtems/system.h>
 #include <rtems/score/isr.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/thread.h>
 #include <rtems/score/tod.h>
 
@@ -56,7 +57,7 @@
 
   if ( !ticks ) {
     _Thread_Disable_dispatch();
-      _Thread_Yield_processor();
+      _Scheduler_Yield();
     _Thread_Enable_dispatch();
     if ( rmtp ) {
        rmtp->tv_sec = 0;

diff -u rtems/cpukit/posix/src/sched_yield.c:1.1 rtems/cpukit/posix/src/sched_yield.c:1.2
--- rtems/cpukit/posix/src/sched_yield.c:1.1	Thu Dec 13 10:52:21 2007
+++ rtems/cpukit/posix/src/sched_yield.c	Wed Nov 24 09:51:27 2010
@@ -19,6 +19,7 @@
 #include <errno.h>
 
 #include <rtems/system.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/tod.h>
 #include <rtems/score/thread.h>
 #include <rtems/seterr.h>
@@ -28,7 +29,7 @@
 int sched_yield( void )
 {
   _Thread_Disable_dispatch();
-    _Thread_Yield_processor();
+    _Scheduler_Yield();
   _Thread_Enable_dispatch();
   return 0;
 }

diff -u rtems/cpukit/rtems/src/taskwakeafter.c:1.4 rtems/cpukit/rtems/src/taskwakeafter.c:1.5
--- rtems/cpukit/rtems/src/taskwakeafter.c:1.4	Tue Jan 18 03:03:45 2005
+++ rtems/cpukit/rtems/src/taskwakeafter.c	Wed Nov 24 09:51:27 2010
@@ -21,6 +21,7 @@
 #include <rtems/rtems/support.h>
 #include <rtems/rtems/modes.h>
 #include <rtems/score/object.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/stack.h>
 #include <rtems/score/states.h>
 #include <rtems/rtems/tasks.h>
@@ -52,7 +53,7 @@
 {
   _Thread_Disable_dispatch();
     if ( ticks == 0 ) {
-      _Thread_Yield_processor();
+      _Scheduler_Yield();
     } else {
       _Thread_Set_state( _Thread_Executing, STATES_DELAYING );
       _Watchdog_Initialize(

diff -u rtems/cpukit/sapi/include/confdefs.h:1.150 rtems/cpukit/sapi/include/confdefs.h:1.151
--- rtems/cpukit/sapi/include/confdefs.h:1.150	Tue Nov 16 13:14:10 2010
+++ rtems/cpukit/sapi/include/confdefs.h	Wed Nov 24 09:51:27 2010
@@ -535,6 +535,116 @@
 #endif
 
 /*
+ * Scheduler configuration.
+ *
+ * The scheduler configuration allows an application to select the 
+ * scheduling policy to use.  The supported configurations are:
+ *  CONFIGURE_SCHEDULER_USER
+ *  CONFIGURE_SCHEDULER_PRIORITY
+ * 
+ * If no configuration is specified by the application, then 
+ * CONFIGURE_SCHEDULER_PRIORITY is assumed to be the default.
+ *
+ * An application can define its own scheduling policy by defining
+ * CONFIGURE_SCHEDULER_USER and CONFIGURE_SCHEDULER_ENTRY_USER to point
+ * to an initialization routine.  Note: CONFIGURE_SCHEDULER_USER is not 
+ * fully supported, since it has no per-thread field.
+ *
+ * To add a new scheduler:
+ */
+#include <rtems/score/scheduler.h>
+
+#if defined(CONFIGURE_SCHEDULER_USER) && \
+    !defined(CONFIGURE_SCHEDULER_ENTRY_USER)
+  #error "CONFIGURE_ERROR: CONFIGURE_SCHEDULER_USER without CONFIGURE_SCHEDULER_ENTRY_USER"
+#endif
+
+/* enable all RTEMS-provided schedulers */
+#if defined(CONFIGURE_SCHEDULER_ALL)
+  #define CONFIGURE_SCHEDULER_PRIORITY
+#endif
+
+/* If no scheduler is specified, the priority scheduler is default. */
+#if !defined(CONFIGURE_SCHEDULER_USER) && \
+    !defined(CONFIGURE_SCHEDULER_PRIORITY)
+  #define CONFIGURE_SCHEDULER_PRIORITY
+  #define CONFIGURE_SCHEDULER_POLICY _Scheduler_PRIORITY
+#endif
+
+/*
+ * If a user scheduler is specified and no policy is set, 
+ * the user scheduler is the default policy.
+ */
+#if defined(CONFIGURE_SCHEDULER_USER) && \
+    !defined(CONFIGURE_SCHEDULER_POLICY)
+  #define CONFIGURE_SCHEDULER_POLICY _Scheduler_USER
+#endif
+
+/* 
+ * Check for priority scheduler next, as it is the default policy if there
+ * is no CONFIGURE_SCHEDULER_POLICY set and no USER scheduler provided.
+ */
+#if defined(CONFIGURE_SCHEDULER_PRIORITY)
+  #include <rtems/score/schedulerpriority.h>
+  #define CONFIGURE_SCHEDULER_ENTRY_PRIORITY { _Scheduler_priority_Initialize }
+  #if !defined(CONFIGURE_SCHEDULER_POLICY)
+    #define CONFIGURE_SCHEDULER_POLICY _Scheduler_PRIORITY
+  #endif
+
+  /**
+   * define the memory used by the priority scheduler
+   */
+  #define CONFIGURE_MEMORY_SCHEDULER_PRIORITY ( \
+    _Configure_From_workspace( \
+      ((CONFIGURE_MAXIMUM_PRIORITY+1) * sizeof(Chain_Control)) ) \
+  )
+  #define CONFIGURE_MEMORY_PER_TASK_SCHEDULER_PRIORITY ( \
+    _Configure_From_workspace(sizeof(Scheduler_priority_Per_thread)) )
+#endif
+
+/* 
+ * Set up the scheduler table.  The scheduling code indexes this table to 
+ * invoke the correct scheduling implementation. The scheduler to use is 
+ * determined by the Configuration.scheduler_policy field, which is set
+ * by CONFIGURE_SCHEDULER_POLICY.  If a particular scheduler is not enabled,
+ * an empty entry is included in its entry in the scheduler table.
+ */
+
+  /**
+   * An empty scheduler entry
+   */
+  #define CONFIGURE_SCHEDULER_NULL { NULL }
+
+#ifdef CONFIGURE_INIT
+  /* the table of available schedulers. */
+  const Scheduler_Table_t _Scheduler_Table[] = {
+    #if defined(CONFIGURE_SCHEDULER_USER) && \
+        defined(CONFIGURE_SCHEDULER_ENTRY_USER)
+      CONFIGURE_SCHEDULER_ENTRY_USER,
+    #else
+      CONFIGURE_SCHEDULER_NULL,
+    #endif
+    #if defined(CONFIGURE_SCHEDULER_PRIORITY) && \
+        defined(CONFIGURE_SCHEDULER_ENTRY_PRIORITY)
+      CONFIGURE_SCHEDULER_ENTRY_PRIORITY,
+    #else
+      CONFIGURE_SCHEDULER_NULL,
+    #endif
+  };
+#endif
+
+/**
+ * Define the memory overhead for the scheduler
+ */
+#define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
+    CONFIGURE_MEMORY_SCHEDULER_PRIORITY \
+  )
+
+#define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
+    CONFIGURE_MEMORY_PER_TASK_SCHEDULER_PRIORITY \
+  )
+
+/*
  *  If you said the IDLE task was going to do application initialization
  *  and didn't override the IDLE body, then something is amiss.
  */
@@ -1607,7 +1717,8 @@
    (_Configure_From_workspace(CONFIGURE_MINIMUM_TASK_STACK_SIZE) + \
     CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API + \
     CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB + \
-    CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API))  + \
+    CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API + \
+    CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER))  + \
   _Configure_From_workspace( \
     _Configure_Max_Objects(_number_FP_tasks) * CONTEXT_FP_SIZE) + \
   _Configure_From_workspace( \
@@ -1705,13 +1816,6 @@
   _Configure_Object_RAM(1, sizeof(API_Mutex_Control))
 
 /**
- *  This defines the memory used by the thread ready chains.  There is
- *  one chain per priority.
- */
-#define CONFIGURE_MEMORY_FOR_THREAD_READY_CHAINS \
-    _Configure_From_workspace( \
-        ((CONFIGURE_MAXIMUM_PRIORITY+1) * sizeof(Chain_Control)) )
-/**
  *  This defines the amount of memory reserved for the IDLE task
  *  control structures and stack.
  */
@@ -1724,7 +1828,7 @@
  */
 #define CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \
   ( CONFIGURE_MEMORY_FOR_IDLE_TASK +                /* IDLE and stack */ \
-    CONFIGURE_MEMORY_FOR_THREAD_READY_CHAINS +     /* Ready chains */ \
+    CONFIGURE_MEMORY_FOR_SCHEDULER +                /* Scheduler */ \
     CONFIGURE_INTERRUPT_VECTOR_TABLE +             /* interrupt vectors */ \
     CONFIGURE_INTERRUPT_STACK_MEMORY +             /* interrupt stack */ \
     CONFIGURE_API_MUTEX_MEMORY                     /* allocation mutex */ \
@@ -2005,6 +2109,7 @@
     CONFIGURE_MAXIMUM_USER_EXTENSIONS,        /* maximum dynamic extensions */
     CONFIGURE_MICROSECONDS_PER_TICK,          /* microseconds per clock tick */
     CONFIGURE_TICKS_PER_TIMESLICE,            /* ticks per timeslice quantum */
+    CONFIGURE_SCHEDULER_POLICY,               /* scheduling policy */
     CONFIGURE_IDLE_TASK_BODY,                 /* user's IDLE task */
     CONFIGURE_IDLE_TASK_STACK_SIZE,           /* IDLE task stack size */
     CONFIGURE_INTERRUPT_STACK_SIZE,           /* interrupt stack size */

diff -u rtems/cpukit/sapi/include/rtems/config.h:1.53 rtems/cpukit/sapi/include/rtems/config.h:1.54
--- rtems/cpukit/sapi/include/rtems/config.h:1.53	Thu Jun 17 23:04:05 2010
+++ rtems/cpukit/sapi/include/rtems/config.h	Wed Nov 24 09:51:27 2010
@@ -118,6 +118,10 @@
    */
   uint32_t                       ticks_per_timeslice;
 
+  /** This field specifies the scheduling policy to use.
+   */
+  uint32_t                       scheduler_policy;
+
   /** This element points to the BSP's optional idle task which may override
    *  the default one provided with RTEMS.
    */

diff -u rtems/cpukit/sapi/src/exinit.c:1.55 rtems/cpukit/sapi/src/exinit.c:1.56
--- rtems/cpukit/sapi/src/exinit.c:1.55	Thu Jul 29 12:52:09 2010
+++ rtems/cpukit/sapi/src/exinit.c	Wed Nov 24 09:51:27 2010
@@ -42,7 +42,7 @@
 #include <rtems/score/mpci.h>
 #endif
 #include <rtems/score/priority.h>
-#include <rtems/score/prioritybitmap.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/thread.h>
 #include <rtems/score/tod.h>
 #include <rtems/score/userext.h>
@@ -131,6 +131,8 @@
 
   _Thread_Handler_initialization();
 
+  _Scheduler_Handler_initialization();
+
   #if defined(RTEMS_MULTIPROCESSING)
     _Objects_MP_Handler_initialization();
     _MPCI_Handler_initialization( RTEMS_TIMEOUT );

diff -u rtems/cpukit/score/Makefile.am:1.88 rtems/cpukit/score/Makefile.am:1.89
--- rtems/cpukit/score/Makefile.am:1.88	Mon Aug 23 11:10:53 2010
+++ rtems/cpukit/score/Makefile.am	Wed Nov 24 09:51:27 2010
@@ -26,6 +26,7 @@
     include/rtems/score/interr.h include/rtems/score/isr.h \
     include/rtems/score/object.h include/rtems/score/percpu.h \
     include/rtems/score/priority.h include/rtems/score/prioritybitmap.h \
+    include/rtems/score/scheduler.h include/rtems/score/schedulerpriority.h \
     include/rtems/score/stack.h include/rtems/score/states.h \
     include/rtems/score/sysstate.h include/rtems/score/thread.h \
     include/rtems/score/threadq.h include/rtems/score/threadsync.h \
@@ -54,6 +55,7 @@
     inline/rtems/score/coresem.inl inline/rtems/score/heap.inl \
     inline/rtems/score/isr.inl inline/rtems/score/object.inl \
     inline/rtems/score/priority.inl inline/rtems/score/prioritybitmap.inl \
+    inline/rtems/score/scheduler.inl inline/rtems/score/schedulerpriority.inl \
     inline/rtems/score/stack.inl inline/rtems/score/states.inl \
     inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
     inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \
@@ -137,6 +139,19 @@
     src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
     src/objectnamespaceremove.c
 
+## SCHEDULER_C_FILES
+libscore_a_SOURCES += src/scheduler.c
+
+## SCHEDULERPRIORITY_C_FILES
+libscore_a_SOURCES += src/schedulerpriority.c \
+											src/schedulerpriorityblock.c \
+                      src/schedulerprioritythreadschedulerallocate.c \
+                      src/schedulerprioritythreadschedulerfree.c \
+                      src/schedulerprioritythreadschedulerupdate.c \
+											src/schedulerpriorityschedule.c \
+											src/schedulerpriorityunblock.c \
+											src/schedulerpriorityyield.c
+
 ## PROTECTED_HEAP_C_FILES
 libscore_a_SOURCES += src/pheapallocate.c \
     src/pheapextend.c src/pheapfree.c src/pheapgetsize.c \
@@ -153,7 +168,7 @@
     src/threadsetstate.c src/threadsettransient.c \
     src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \
     src/threadstartmultitasking.c src/threadsuspend.c \
-    src/threadtickletimeslice.c src/threadyieldprocessor.c \
+    src/threadtickletimeslice.c \
     src/iterateoverthreads.c src/threadblockingoperationcancel.c
 
 ## THREADQ_C_FILES

diff -u rtems/cpukit/score/include/rtems/score/prioritybitmap.h:1.1 rtems/cpukit/score/include/rtems/score/prioritybitmap.h:1.2
--- rtems/cpukit/score/include/rtems/score/prioritybitmap.h:1.1	Thu Jul 29 12:52:10 2010
+++ rtems/cpukit/score/include/rtems/score/prioritybitmap.h	Wed Nov 24 09:51:27 2010
@@ -37,18 +37,17 @@
 
 #include <rtems/score/priority.h>
 
+
 /* 
- * TODO: 
- * These should only be instantiated if using the bit map handler.  The 
- * logical place for this is in confdefs.h when a scheduler that uses the 
- * bit map handler is configured.
+ * The Priority_bit_map_Control variables are instantiated only 
+ * if using the bit map handler.
  */
 
 /**
  *  Each sixteen bit entry in this array is associated with one of
  *  the sixteen entries in the Priority Bit map.
  */
-SCORE_EXTERN volatile Priority_bit_map_Control _Priority_Major_bit_map;
+extern volatile Priority_bit_map_Control _Priority_Major_bit_map;
 
 /** Each bit in the Priority Bitmap indicates whether or not there are
  *  threads ready at a particular priority.  The mapping of
@@ -56,7 +55,7 @@
  *  dependent as is the value of each bit used to indicate that
  *  threads are ready at that priority.
  */
-SCORE_EXTERN Priority_bit_map_Control
+extern Priority_bit_map_Control
                _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
 
 /*

diff -u /dev/null rtems/cpukit/score/include/rtems/score/scheduler.h:1.1
--- /dev/null	Wed Nov 24 10:10:42 2010
+++ rtems/cpukit/score/include/rtems/score/scheduler.h	Wed Nov 24 09:51:27 2010
@@ -0,0 +1,156 @@
+/**
+ *  @file  rtems/score/scheduler.h
+ *
+ *  This include file contains all the constants and structures associated
+ *  with the scheduler.
+ */
+
+/*
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#ifndef _RTEMS_SCORE_SCHEDULER_H
+#define _RTEMS_SCORE_SCHEDULER_H
+
+/**
+ *  @defgroup ScoreScheduler Scheduler Handler
+ *
+ *  This handler encapsulates functionality related to managing sets of threads
+ *  that are ready for execution.
+ */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/percpu.h>
+#include <rtems/score/chain.h>
+#include <rtems/score/priority.h>
+#include <rtems/score/prioritybitmap.h>
+
+/* 
+ * These defines are used to set the scheduler_policy value. The values 
+ * must correspond directly with the order of the fields in the scheduler
+ * table (Scheduler_Table_t), because the Configuration.scheduler_policy 
+ * field is used to index the scheduler table.
+ */
+#define _Scheduler_USER     (0)
+#define _Scheduler_PRIORITY (1)
+
+typedef struct Scheduler_Control_struct Scheduler_Control;
+
+/*
+ * The Scheduler_Table_t type defines the scheduler initialization table, 
+ * which is set up by confdefs.h based on the user's choice of scheduler 
+ * policy.
+ */
+typedef struct {
+  void ( *scheduler_init )( Scheduler_Control * );
+} Scheduler_Table_t;
+
+/* instantiated and initialized in confdefs.h */
+extern const Scheduler_Table_t          _Scheduler_Table[]; 
+
+/**
+ * The following Scheduler_Per_thread_xxx structures are used to 
+ * hold per-thread data used by the scheduler.  Thread_Control->scheduler is a 
+ * union of pointers, one for each of the following structures.  The
+ * scheduler->xxx field points to an instantion of one of these structures, 
+ * which is allocated from the workspace during _Thread_Start.
+ */
+
+/**
+ * Per-thread data related to the _Scheduler_PRIORITY scheduling policy.
+ */
+typedef struct {
+  /** This field points to the Ready FIFO for this thread's priority. */
+  Chain_Control                        *ready_chain;
+
+  /** This field contains precalculated priority map indices. */
+  Priority_bit_map_Information          Priority_map;
+} Scheduler_priority_Per_thread;
+
+/**
+ * function jump table that holds pointers to the functions that 
+ * implement specific schedulers.
+ */
+typedef struct {
+  /** Implements the scheduling decision logic (policy). */
+  void ( *schedule ) ( Scheduler_Control * );
+
+  /** Voluntarily yields the processor per the scheduling policy. */
+  void ( *yield ) ( Scheduler_Control * );
+
+  /** Removes the given thread from scheduling decisions. */
+  void ( *block ) ( Scheduler_Control *, Thread_Control * );
+
+  /** Adds the given thread to scheduling decisions. */
+  void ( *unblock ) ( Scheduler_Control *, Thread_Control * );
+
+  /** allocates the scheduler field of the given thread */
+  void * ( *scheduler_allocate ) ( Scheduler_Control *, Thread_Control * );
+
+  /** frees the scheduler field of the given thread */
+  void ( *scheduler_free ) ( Scheduler_Control *, Thread_Control * );
+  
+  /** updates the scheduler field of the given thread -- primarily used 
+   * when changing the thread's priority. */
+  void ( *scheduler_update ) ( Scheduler_Control *, Thread_Control * );
+} Scheduler_Operations;
+
+/**
+ * This is the structure used to manage the scheduler.
+ */
+struct Scheduler_Control_struct {
+  /** 
+   *  This union contains the pointer to the data structure used to manage 
+   *  the ready set of tasks. The pointer varies based upon the type of 
+   *  ready queue required by the scheduler.
+   */
+  union {
+    /** 
+     * This is the set of lists (an array of Chain_Control) for 
+     * priority scheduling. 
+     */
+    Chain_Control            *Priority;
+
+  } ready_queues;
+
+  /** The jump table for scheduler-specific functions */
+  Scheduler_Operations                  operations;
+};
+
+/**
+ *  The _Scheduler holds the structures used to manage the
+ *  scheduler.
+ *
+ * @note Can we make this per-cpu? then _Scheduler will be a macro.
+ */
+SCORE_EXTERN Scheduler_Control          _Scheduler;
+
+/**
+ *  This routine initializes the scheduler to the policy chosen by the user 
+ *  through confdefs, or to the priority scheduler with ready chains by
+ *  default.
+ */
+void _Scheduler_Handler_initialization( void );
+
+#ifndef __RTEMS_APPLICATION__
+#include <rtems/score/scheduler.inl>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif
+/* end of include file */

diff -u /dev/null rtems/cpukit/score/include/rtems/score/schedulerpriority.h:1.1
--- /dev/null	Wed Nov 24 10:10:42 2010
+++ rtems/cpukit/score/include/rtems/score/schedulerpriority.h	Wed Nov 24 09:51:27 2010
@@ -0,0 +1,117 @@
+/**
+ *  @file  rtems/score/schedulerpriority.h
+ *
+ *  This include file contains all the constants and structures associated
+ *  with the manipulation of threads for the priority-based scheduler.
+ */
+
+/*
+ *  Copryight (c) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H
+#define _RTEMS_SCORE_SCHEDULERPRIORITY_H
+
+/**
+ *  @addtogroup ScoreScheduler
+ *
+ */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/chain.h>
+#include <rtems/score/priority.h>
+#include <rtems/score/percpu.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/wkspace.h>
+
+/**
+ * This routine initializes the priority scheduler.
+ */
+void _Scheduler_priority_Initialize(
+    Scheduler_Control    *the_scheduler
+);
+
+/**
+ *  This routine removes @a the_thread from the scheduling decision, 
+ *  that is, removes it from the ready queue.  It performs
+ *  any necessary scheduling operations including the selection of
+ *  a new heir thread.
+ */
+void _Scheduler_priority_Block( 
+    Scheduler_Control *the_scheduler,
+    Thread_Control    *the_thread 
+);
+
+/**
+ *  This kernel routine sets the heir thread to be the next ready thread 
+ *  by invoking the_scheduler->ready_queue->operations->first().
+ */
+void _Scheduler_priority_Schedule(
+    Scheduler_Control *the_scheduler
+);
+
+/**
+ * This routine allocates @a the_thread->scheduler.
+ */
+void * _Scheduler_priority_Thread_scheduler_allocate(
+    Scheduler_Control   *the_scheduler,
+    Thread_Control      *the_thread
+);
+
+/**
+ * This routine frees @a the_thread->scheduler.
+ */
+void _Scheduler_priority_Thread_scheduler_free(
+    Scheduler_Control   *the_scheduler,
+    Thread_Control      *the_thread
+);
+
+/**
+ * This routine updates @a the_thread->scheduler based on @a the_scheduler 
+ * structures and thread state
+ */
+void _Scheduler_priority_Thread_scheduler_update(
+    Scheduler_Control   *the_scheduler,
+    Thread_Control      *the_thread
+);
+
+/**
+ *  This routine adds @a the_thread to the scheduling decision, 
+ *  that is, adds it to the ready queue and 
+ *  updates any appropriate scheduling variables, for example the heir thread.
+ */
+void _Scheduler_priority_Unblock(
+    Scheduler_Control *the_scheduler,
+    Thread_Control    *the_thread 
+);
+
+/**
+ *  This routine is invoked when a thread wishes to voluntarily
+ *  transfer control of the processor to another thread in the queue.
+ */
+void _Scheduler_priority_Yield(
+    Scheduler_Control *the_scheduler
+);
+
+#ifndef __RTEMS_APPLICATION__
+#include <rtems/score/schedulerpriority.inl>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif
+/* end of include file */

diff -u rtems/cpukit/score/include/rtems/score/thread.h:1.97 rtems/cpukit/score/include/rtems/score/thread.h:1.98
--- rtems/cpukit/score/include/rtems/score/thread.h:1.97	Thu Jul 29 12:52:10 2010
+++ rtems/cpukit/score/include/rtems/score/thread.h	Wed Nov 24 09:51:27 2010
@@ -70,7 +70,7 @@
 #endif
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
-#include <rtems/score/prioritybitmap.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/stack.h>
 #include <rtems/score/states.h>
 #include <rtems/score/tod.h>
@@ -390,10 +390,10 @@
    *  since it was created.
    */
   Thread_CPU_usage_t                    cpu_time_used;
-  /** This field points to the Ready FIFO for this priority. */
-  Chain_Control                        *ready;
-  /** This field contains precalculated priority map indices. */
-  Priority_bit_map_Information          Priority_map;
+  /** This union holds per-thread data for the scheduler and ready queue. */
+  union {
+    Scheduler_priority_Per_thread      *priority;
+  } scheduler;
   /** This field contains information about the starting state of
    *  this thread.
    */
@@ -456,12 +456,6 @@
 SCORE_EXTERN uint32_t   _Thread_Ticks_per_timeslice;
 
 /**
- *  The following points to the array of FIFOs used to manage the
- *  set of ready threads.
- */
-SCORE_EXTERN Chain_Control *_Thread_Ready_chain;
-
-/**
  *  The following points to the thread whose floating point
  *  context is currently loaded.
  */
@@ -654,13 +648,6 @@
 void _Thread_Tickle_timeslice( void );
 
 /**
- *  This routine is invoked when a thread wishes to voluntarily
- *  transfer control of the processor to another thread of equal
- *  or greater priority.
- */
-void _Thread_Yield_processor( void );
-
-/**
  *  This routine initializes the context of the_thread to its
  *  appropriate starting state.
  */

diff -u /dev/null rtems/cpukit/score/inline/rtems/score/scheduler.inl:1.1
--- /dev/null	Wed Nov 24 10:10:42 2010
+++ rtems/cpukit/score/inline/rtems/score/scheduler.inl	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,139 @@
+/** 
+ *  @file  rtems/score/scheduler.inl
+ *
+ *  This inline file contains all of the inlined routines associated with
+ *  the manipulation of the scheduler.
+ */
+
+/*
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#ifndef _RTEMS_SCORE_SCHEDULER_H
+# error "Never use <rtems/score/scheduler.inl> directly; include <rtems/score/scheduler.h> instead."
+#endif
+
+#ifndef _RTEMS_SCORE_SCHEDULER_INL
+#define _RTEMS_SCORE_SCHEDULER_INL
+
+/**
+ *  @addtogroup ScoreScheduler
+ * @{
+ */
+
+/**
+ * The preferred method to add a new scheduler is to define the jump table 
+ * entries and add a case to the _Scheduler_Initialize routine. 
+ *
+ * Generic scheduling implementations that rely on the ready queue only can 
+ * be found in the _Scheduler_queue_XXX functions.
+ *
+ */
+
+/* Passing the Scheduler_Control* to these functions allows for multiple 
+ * scheduler's to exist simultaneously, which could be useful on an SMP 
+ * system.  Then remote Schedulers may be accessible.  How to protect such 
+ * accesses remains an open problem.
+ */
+
+/** @brief _Scheduler_Schedule
+ *
+ *  This kernel routine implements the scheduling decision logic for 
+ *  @a the_scheduler. It does NOT dispatch.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Schedule(
+    Scheduler_Control *the_scheduler 
+)
+{
+  the_scheduler->operations.schedule( the_scheduler );
+}
+
+/** @brief _Scheduler_Yield
+ *
+ *  This routine is invoked when a thread wishes to voluntarily
+ *  transfer control of the processor to another thread. This routine
+ *  always operates on the scheduler that 'owns' the currently executing
+ *  thread.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Yield( void )
+{
+  _Scheduler.operations.yield( &_Scheduler );
+}
+
+/** @brief _Scheduler_Block
+ *
+ *  This routine removes @a the_thread from the scheduling decision for 
+ *  @a the_scheduler. The primary task is to remove the thread from the 
+ *  ready queue.  It performs any necessary schedulering operations 
+ *  including the selection of a new heir thread.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Block( 
+    Scheduler_Control *the_scheduler,
+    Thread_Control    *the_thread 
+)
+{
+  the_scheduler->operations.block( the_scheduler, the_thread );
+}
+
+/** @brief _Scheduler_Unblock
+ *
+ *  This routine adds @a the_thread to the scheduling decision for 
+ *  @a the_scheduler.  The primary task is to add the thread to the
+ *  ready queue per the schedulering policy and update any appropriate 
+ *  scheduling variables, for example the heir thread.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
+    Scheduler_Control *the_scheduler,
+    Thread_Control    *the_thread 
+)
+{
+  the_scheduler->operations.unblock( the_scheduler, the_thread );
+}
+
+/** @brief _Scheduler_Thread_scheduler_allocate
+ *
+ * This routine allocates @a the_thread->scheduler
+ */
+RTEMS_INLINE_ROUTINE void* _Scheduler_Thread_scheduler_allocate( 
+  Scheduler_Control *the_scheduler,
+  Thread_Control    *the_thread
+)
+{
+  return 
+    the_scheduler->operations.scheduler_allocate( the_scheduler, the_thread );
+}
+
+/** @brief _Scheduler_Thread_scheduler_free
+ *
+ * This routine frees @a the_thread->scheduler
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Thread_scheduler_free( 
+  Scheduler_Control *the_scheduler,
+  Thread_Control    *the_thread
+)
+{
+  return the_scheduler->operations.scheduler_free( the_scheduler, the_thread );
+}
+
+/** @brief _Scheduler_Thread_scheduler_update
+ *
+ * This routine updates @a the_thread->scheduler
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Thread_scheduler_update( 
+  Scheduler_Control *the_scheduler,
+  Thread_Control    *the_thread
+)
+{
+  the_scheduler->operations.scheduler_update( the_scheduler, the_thread );
+}
+
+/**@}*/
+
+#endif
+/* end of include file */

diff -u /dev/null rtems/cpukit/score/inline/rtems/score/schedulerpriority.inl:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/inline/rtems/score/schedulerpriority.inl	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,286 @@
+/** 
+ *  @file  rtems/score/schedulerpriority.inl
+ *
+ *  This inline file contains all of the inlined routines associated with
+ *  the manipulation of the priority-based scheduling structures.
+ */
+
+/*
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H
+# error "Never use <rtems/score/schedulerpriority.inl> directly; include <rtems/score/schedulerpriority.h> instead."
+#endif
+
+#ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_INL
+#define _RTEMS_SCORE_SCHEDULERPRIORITY_INL
+
+/**
+ *  @addtogroup ScoreScheduler
+ * @{
+ */
+
+/** @brief  Scheduler priority Ready queue initialize
+ *
+ *  This routine initializes @a the_ready_queue for priority-based scheduling.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(
+  Scheduler_Control         *the_scheduler
+) {
+  uint32_t index;
+
+  /* allocate ready queue structures */
+  the_scheduler->ready_queues.Priority = (Chain_Control *) 
+    _Workspace_Allocate_or_fatal_error(
+      (PRIORITY_MAXIMUM + 1) * sizeof(Chain_Control)
+    );
+
+  /* initialize ready queue structures */
+  for( index=0; index <= PRIORITY_MAXIMUM; index++)
+    _Chain_Initialize_empty( &the_scheduler->ready_queues.Priority[index] );
+}
+
+/* 
+ *  _Scheduler_priority_Ready_queue_enqueue
+ *
+ *  This routine puts @a the_thread on to the priority-based ready queue.
+ *  
+ *  Input parameters:
+ *    the_thread  - pointer to thread
+ *
+ *  Output parameters: NONE
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(
+  Thread_Control                  *the_thread
+)
+{
+  _Priority_bit_map_Add( &the_thread->scheduler.priority->Priority_map );
+  
+  _Chain_Append_unprotected( the_thread->scheduler.priority->ready_chain, 
+      &the_thread->Object.Node );
+}
+
+/*
+ *  _Scheduler_priority_Ready_queue_Enqueue_first
+ *
+ *  This routine puts @a the_thread to the head of the ready queue. 
+ *  For priority-based ready queues, the thread will be the first thread
+ *  at its priority level.
+ *  
+ *  Input parameters:
+ *    the_thread      - pointer to thread
+ *
+ *  Output parameters: NONE
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(
+  Thread_Control                   *the_thread
+)
+{
+  _Priority_bit_map_Add( &the_thread->scheduler.priority->Priority_map );
+
+  _Chain_Prepend_unprotected( the_thread->scheduler.priority->ready_chain, 
+      &the_thread->Object.Node );
+}
+
+/*
+ *  _Scheduler_priority_Ready_queue_extract
+ *
+ *  This routine removes a specific thread from the specified 
+ *  priority-based ready queue.
+ *
+ *  Input parameters:
+ *    the_thread       - pointer to a thread control block
+ *
+ *  Output parameters: NONE
+ *
+ *  INTERRUPT LATENCY: NONE
+ */
+
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
+  Thread_Control        *the_thread
+)
+{
+  Chain_Control         *ready  = the_thread->scheduler.priority->ready_chain;
+
+  if ( _Chain_Has_only_one_node( ready ) ) {
+    _Chain_Initialize_empty( ready );
+    _Priority_bit_map_Remove( &the_thread->scheduler.priority->Priority_map );
+  } else
+    _Chain_Extract_unprotected( &the_thread->Object.Node );
+}
+
+/*
+ *  _Scheduler_priority_Ready_queue_first
+ *
+ *  This routines returns a pointer to the first thread on @a the_ready_queue.
+ *
+ *  Input parameters:
+ *    the_ready_queue - pointer to thread queue
+ *
+ *  Output parameters:
+ *    returns - first thread or NULL
+ */
+
+RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_priority_Ready_queue_first(
+  Chain_Control       *the_ready_queue
+)
+{
+  uint32_t    index = _Priority_bit_map_Get_highest();
+
+  if ( !_Chain_Is_empty( &the_ready_queue[ index ] ) )
+    return (Thread_Control *) the_ready_queue[ index ].first;
+
+  return NULL;
+}
+
+/*
+ *  _Scheduler_priority_Ready_queue_requeue
+ *
+ *  This routine is invoked when a thread changes priority and should be
+ *  moved to a different position on the ready queue.
+ *
+ *  Input parameters:
+ *    the_thread        - pointer to a thread control block
+ *
+ *  Output parameters: NONE
+ *
+ *  INTERRUPT LATENCY: NONE
+ */
+
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue(
+  Thread_Control            *the_thread
+)
+{
+  if ( !_Chain_Has_only_one_node(
+        the_thread->scheduler.priority->ready_chain
+        ) ) {
+    _Chain_Extract_unprotected( &the_thread->Object.Node );
+
+    _Chain_Append_unprotected( the_thread->scheduler.priority->ready_chain, 
+      &the_thread->Object.Node );
+  }
+}
+
+/*
+ * _Scheduler_priority_Schedule_body
+ *
+ * This kernel routine implements scheduling decision logic for priority-based
+ * scheduling.  
+ *
+ * Input parameters:
+ *   the_scheduler  - pointer to scheduler control
+ *   the_thread     - pointer to thread control block
+ *
+ * Output parameters:  NONE
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(
+  Scheduler_Control     *the_scheduler
+)
+{
+  _Thread_Heir = _Scheduler_priority_Ready_queue_first(
+      the_scheduler->ready_queues.Priority
+  );
+}
+
+/*
+ * _Scheduler_priority_Block_body
+ *
+ * This kernel routine removes the_thread from scheduling decisions based 
+ * on simple queue extraction.
+ *
+ * Input parameters:
+ *   the_scheduler  - pointer to scheduler control
+ *   the_thread     - pointer to thread control block
+ *
+ * Output parameters:  NONE
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Block_body(
+  Scheduler_Control *the_scheduler,
+  Thread_Control   *the_thread
+)
+{
+  _Scheduler_priority_Ready_queue_extract(the_thread);
+
+  /* TODO: flash critical section */
+
+  if ( _Thread_Is_heir( the_thread ) )
+     _Scheduler_priority_Schedule_body(the_scheduler);
+
+  if ( _Thread_Is_executing( the_thread ) )
+    _Thread_Dispatch_necessary = true;
+
+  return;
+}
+
+/*
+ *  _Scheduler_priority_Unblock_body
+ *
+ *  This kernel routine readies the requested thread according to the queuing 
+ *  discipline. A new heir thread may be selected.
+ *
+ *  Input parameters:
+ *    the_scheduler - pointer to scheduler control
+ *    the_thread    - pointer to thread control block
+ *
+ *  Output parameters:  NONE
+ *
+ *  NOTE:  This routine uses the "blocking" heir selection mechanism.
+ *         This ensures the correct heir after a thread restart.
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+RTEMS_INLINE_ROUTINE void _Scheduler_priority_Unblock_body (
+  Scheduler_Control       *the_scheduler,
+  Thread_Control          *the_thread
+)
+{
+  _Scheduler_priority_Ready_queue_enqueue(
+      the_thread
+  );
+
+  /* TODO: flash critical section */
+
+  /*
+   *  If the thread that was unblocked is more important than the heir,
+   *  then we have a new heir.  This may or may not result in a
+   *  context switch.
+   *
+   *  Normal case:
+   *    If the current thread is preemptible, then we need to do
+   *    a context switch.
+   *  Pseudo-ISR case:
+   *    Even if the thread isn't preemptible, if the new heir is
+   *    a pseudo-ISR system task, we need to do a context switch.
+   */
+  if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
+    _Thread_Heir = the_thread;
+    if ( _Thread_Executing->is_preemptible ||
+        the_thread->current_priority == 0 )
+      _Thread_Dispatch_necessary = true;
+  }
+}
+
+/**@}*/
+
+#endif
+/* end of include file */

diff -u rtems/cpukit/score/inline/rtems/score/thread.inl:1.43 rtems/cpukit/score/inline/rtems/score/thread.inl:1.44
--- rtems/cpukit/score/inline/rtems/score/thread.inl:1.43	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/inline/rtems/score/thread.inl	Wed Nov 24 09:51:28 2010
@@ -120,17 +120,6 @@
 }
 
 /**
- *  This function returns a pointer to the highest priority
- *  ready thread.
- */
-
-RTEMS_INLINE_ROUTINE void _Thread_Calculate_heir( void )
-{
-  _Thread_Heir = (Thread_Control *)
-    _Thread_Ready_chain[ _Priority_bit_map_Get_highest() ].first;
-}
-
-/**
  *  This function returns true if the floating point context of
  *  the_thread is currently loaded in the floating point unit, and
  *  false otherwise.

diff -u rtems/cpukit/score/preinstall.am:1.24 rtems/cpukit/score/preinstall.am:1.25
--- rtems/cpukit/score/preinstall.am:1.24	Thu Jul 29 12:52:10 2010
+++ rtems/cpukit/score/preinstall.am	Wed Nov 24 09:51:27 2010
@@ -111,6 +111,14 @@
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h
 
+$(PROJECT_INCLUDE)/rtems/score/scheduler.h: include/rtems/score/scheduler.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduler.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduler.h
+
+$(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h: include/rtems/score/schedulerpriority.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h
+
 $(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.h
@@ -245,6 +253,14 @@
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl
 
+$(PROJECT_INCLUDE)/rtems/score/scheduler.inl: inline/rtems/score/scheduler.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduler.inl
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduler.inl
+
+$(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl: inline/rtems/score/schedulerpriority.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl
+
 $(PROJECT_INCLUDE)/rtems/score/stack.inl: inline/rtems/score/stack.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.inl

diff -u /dev/null rtems/cpukit/score/src/scheduler.c:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/src/scheduler.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,45 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/chain.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/states.h>
+#include <rtems/score/thread.h>
+
+/*
+ *  _Scheduler_Handler_initialization
+ *
+ *  This routine initializes the scheduler by calling the scheduler_init 
+ *  function registered in the Configuration Scheduler Table.
+ *
+ *  Input parameters: NONE
+ *
+ *  Output parameters: NONE
+ */
+
+void _Scheduler_Handler_initialization( )
+{
+  Scheduler_Control *the_scheduler = &_Scheduler;
+
+  (*(_Scheduler_Table[Configuration.scheduler_policy].scheduler_init))(
+      the_scheduler
+  );
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerpriority.c:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/src/schedulerpriority.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,66 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/chain.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/states.h>
+#include <rtems/score/thread.h>
+
+/* Instantiate any global variables needed by the priority scheduler */
+volatile Priority_bit_map_Control _Priority_Major_bit_map;
+
+Priority_bit_map_Control          _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
+
+/*
+ *  _Scheduler_priority_Initialize
+ *
+ * Initializes the scheduler for priority scheduling.
+ *
+ *  Input parameters:
+ *    the_scheduler - pointer to scheduler control
+ *
+ *  Output parameters: NONE
+ */
+
+void _Scheduler_priority_Initialize (
+    Scheduler_Control       *the_scheduler
+)
+{
+  /* the operations table is a jump table to redirect generic scheduler 
+   * function calls to scheduler implementation specific functions.  The 
+   * main purpose of scheduler initialization is to set up the jump table 
+   * for the scheduler.  Every scheduler implementation provides its own
+   * scheduler operations table.
+   */
+  the_scheduler->operations.schedule           = &_Scheduler_priority_Schedule;
+  the_scheduler->operations.yield              = &_Scheduler_priority_Yield;
+  the_scheduler->operations.block              = &_Scheduler_priority_Block;
+  the_scheduler->operations.unblock            = &_Scheduler_priority_Unblock;
+  the_scheduler->operations.scheduler_allocate = 
+      &_Scheduler_priority_Thread_scheduler_allocate;
+  the_scheduler->operations.scheduler_free     = 
+      &_Scheduler_priority_Thread_scheduler_free;
+  the_scheduler->operations.scheduler_update   = 
+      &_Scheduler_priority_Thread_scheduler_update;
+
+  _Scheduler_priority_Ready_queue_initialize( the_scheduler );
+  _Priority_bit_map_Handler_initialization( );
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerpriorityblock.c:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/src/schedulerpriorityblock.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,48 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/context.h>
+#include <rtems/score/interr.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/thread.h>
+
+/*
+ * _Scheduler_priority_Block
+ *
+ * This kernel routine removes the_thread from scheduling decisions based 
+ * on simple queue extraction.
+ *
+ * Input parameters:
+ *   the_scheduler  - pointer to scheduler control
+ *   the_thread     - pointer to thread control block
+ *
+ * Output parameters:  NONE
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+void _Scheduler_priority_Block(
+  Scheduler_Control *the_scheduler,
+  Thread_Control   *the_thread
+)
+{
+  _Scheduler_priority_Block_body(the_scheduler, the_thread);
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerpriorityschedule.c:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/src/schedulerpriorityschedule.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,48 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/context.h>
+#include <rtems/score/interr.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/priority.h>
+#include <rtems/score/percpu.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/thread.h>
+
+/*
+ * _Scheduler_priority_Schedule
+ *
+ * This kernel routine implements scheduling decision logic for priority-based
+ * scheduling.  
+ *
+ * Input parameters:
+ *   the_scheduler  - pointer to scheduler control
+ *   the_thread     - pointer to thread control block
+ *
+ * Output parameters:  NONE
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+void _Scheduler_priority_Schedule(
+  Scheduler_Control     *the_scheduler
+)
+{
+  _Scheduler_priority_Schedule_body( the_scheduler );
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerprioritythreadschedulerallocate.c:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/src/schedulerprioritythreadschedulerallocate.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,53 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/chain.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/states.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/wkspace.h>
+
+/*
+ *  _Scheduler_priority_Thread_scheduler_allocate
+ *
+ * Allocates @a the_thread->scheduler
+ *
+ *  Input parameters:
+ *    the_scheduler - pointer to scheduler control
+ *    the_thread    - pointer to thread control block
+ *
+ *  Output parameters: 
+ *    Returns pointer to allocated space.
+ */
+
+void* _Scheduler_priority_Thread_scheduler_allocate (
+  Scheduler_Control     *the_scheduler,
+  Thread_Control        *the_thread
+)
+{
+  void                  *sched;
+
+  sched = _Workspace_Allocate( sizeof(Scheduler_priority_Per_thread) );
+
+  the_thread->scheduler.priority = (Scheduler_priority_Per_thread*) sched;
+
+  return sched;
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerprioritythreadschedulerfree.c:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/src/schedulerprioritythreadschedulerfree.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,46 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/chain.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/states.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/wkspace.h>
+
+/*
+ *  _Scheduler_priority_Thread_scheduler_free
+ *
+ * Frees @a the_thread->scheduler
+ *
+ *  Input parameters:
+ *    the_scheduler - pointer to scheduler control
+ *    the_thread    - pointer to thread control block
+ *
+ *  Output parameters: NONE
+ */
+
+void _Scheduler_priority_Thread_scheduler_free (
+    Scheduler_Control *the_scheduler,
+    Thread_Control    *the_thread
+)
+{
+  _Workspace_Free( the_thread->scheduler.priority );
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerprioritythreadschedulerupdate.c:1.1
--- /dev/null	Wed Nov 24 10:10:43 2010
+++ rtems/cpukit/score/src/schedulerprioritythreadschedulerupdate.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,55 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/chain.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/priority.h>
+#include <rtems/score/prioritybitmap.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/states.h>
+#include <rtems/score/thread.h>
+
+/*
+ *  _Scheduler_priority_Thread_scheduler_update
+ *
+ * Updates @a the_thread->scheduler
+ *
+ *  Input parameters:
+ *    the_scheduler - pointer to scheduler control
+ *    the_thread    - pointer to thread control block
+ *
+ *  Output parameters: NONE
+ */
+
+void _Scheduler_priority_Thread_scheduler_update (
+    Scheduler_Control *the_scheduler,
+    Thread_Control    *the_thread
+)
+{
+  Chain_Control *rq = the_scheduler->ready_queues.Priority;
+  the_thread->scheduler.priority->ready_chain = &rq[
+    the_thread->current_priority 
+  ];
+
+  _Priority_bit_map_Initialize_information( 
+      &the_thread->scheduler.priority->Priority_map, 
+      the_thread->current_priority 
+  );
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerpriorityunblock.c:1.1
--- /dev/null	Wed Nov 24 10:10:44 2010
+++ rtems/cpukit/score/src/schedulerpriorityunblock.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,57 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/apiext.h>
+#include <rtems/score/context.h>
+#include <rtems/score/interr.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/score/states.h>
+#include <rtems/score/sysstate.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/threadq.h>
+#include <rtems/score/userext.h>
+#include <rtems/score/wkspace.h>
+
+/*
+ *  _Scheduler_priority_Unblock
+ *
+ *  This kernel routine readies the requested thread according to the queuing 
+ *  discipline. A new heir thread may be selected.
+ *
+ *  Input parameters:
+ *    the_scheduler - pointer to scheduler control
+ *    the_thread    - pointer to thread control block
+ *
+ *  Output parameters:  NONE
+ *
+ *  NOTE:  This routine uses the "blocking" heir selection mechanism.
+ *         This ensures the correct heir after a thread restart.
+ *
+ *  INTERRUPT LATENCY:
+ */
+
+void _Scheduler_priority_Unblock (
+  Scheduler_Control       *the_scheduler,
+  Thread_Control          *the_thread
+)
+{
+  _Scheduler_priority_Unblock_body(the_scheduler, the_thread);
+}

diff -u /dev/null rtems/cpukit/score/src/schedulerpriorityyield.c:1.1
--- /dev/null	Wed Nov 24 10:10:44 2010
+++ rtems/cpukit/score/src/schedulerpriorityyield.c	Wed Nov 24 09:51:28 2010
@@ -0,0 +1,77 @@
+/*
+ *  Scheduler Handler
+ *
+ *  Copyright (C) 2010 Gedare Bloom.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/apiext.h>
+#include <rtems/score/context.h>
+#include <rtems/score/interr.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/object.h>
+#include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/states.h>
+#include <rtems/score/sysstate.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/threadq.h>
+#include <rtems/score/userext.h>
+#include <rtems/score/wkspace.h>
+
+/*
+ *  _Scheduler_priority_Yield
+ *
+ *  This kernel routine will remove the running THREAD from the ready queue
+ *  and place it immediately at the rear of this chain.  Reset timeslice
+ *  and yield the processor functions both use this routine, therefore if
+ *  reset is true and this is the only thread on the queue then the
+ *  timeslice counter is reset.  The heir THREAD will be updated if the
+ *  running is also the currently the heir.
+ *
+ *  Input parameters:
+ *    the_scheduler - pointer to scheduler control
+ *
+ *  Output parameters:  NONE
+ *
+ *  INTERRUPT LATENCY:
+ *    ready chain
+ *    select heir
+ */
+
+void _Scheduler_priority_Yield( 
+    Scheduler_Control   *the_scheduler
+)
+{
+  ISR_Level       level;
+  Thread_Control *executing;
+  Chain_Control  *ready;
+
+  executing = _Thread_Executing;
+  ready = executing->scheduler.priority->ready_chain;
+  _ISR_Disable( level );
+    if ( !_Chain_Has_only_one_node( ready ) ) {
+      _Chain_Extract_unprotected( &executing->Object.Node );
+      _Chain_Append_unprotected( ready, &executing->Object.Node );
+
+      _ISR_Flash( level );
+
+      if ( _Thread_Is_heir( executing ) )
+        _Thread_Heir = (Thread_Control *) ready->first;
+      _Thread_Dispatch_necessary = true;
+    }
+    else if ( !_Thread_Is_heir( executing ) )
+      _Thread_Dispatch_necessary = true;
+
+  _ISR_Enable( level );
+}

diff -u rtems/cpukit/score/src/thread.c:1.64 rtems/cpukit/score/src/thread.c:1.65
--- rtems/cpukit/score/src/thread.c:1.64	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/src/thread.c	Wed Nov 24 09:51:28 2010
@@ -24,6 +24,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -45,7 +46,6 @@
 
 void _Thread_Handler_initialization(void)
 {
-  uint32_t     index;
   uint32_t     ticks_per_timeslice;
   uint32_t     maximum_extensions;
   #if defined(RTEMS_MULTIPROCESSING)
@@ -80,13 +80,6 @@
 
   _Thread_Ticks_per_timeslice  = ticks_per_timeslice;
 
-  _Thread_Ready_chain = (Chain_Control *) _Workspace_Allocate_or_fatal_error(
-    (PRIORITY_MAXIMUM + 1) * sizeof(Chain_Control)
-  );
-
-  for ( index=0; index <= PRIORITY_MAXIMUM ; index++ )
-    _Chain_Initialize_empty( &_Thread_Ready_chain[ index ] );
-
 #if defined(RTEMS_MULTIPROCESSING)
   _Thread_MP_Handler_initialization( maximum_proxies );
 #endif

diff -u rtems/cpukit/score/src/threadchangepriority.c:1.14 rtems/cpukit/score/src/threadchangepriority.c:1.15
--- rtems/cpukit/score/src/threadchangepriority.c:1.14	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/src/threadchangepriority.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,8 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -117,14 +119,16 @@
      *  We now know the thread will be in the READY state when we remove
      *  the TRANSIENT state.  So we have to place it on the appropriate
      *  Ready Queue with interrupts off.
+     *
+     *  FIXME: hard-coded for priority scheduling. Might be ok since this 
+     *  function is specific to priority scheduling?
      */
     the_thread->current_state = _States_Clear( STATES_TRANSIENT, state );
 
-    _Priority_bit_map_Add( &the_thread->Priority_map );
     if ( prepend_it )
-      _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node );
+      _Scheduler_priority_Ready_queue_enqueue_first( the_thread );
     else
-      _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
+      _Scheduler_priority_Ready_queue_enqueue( the_thread );
   }
 
   _ISR_Flash( level );
@@ -133,7 +137,7 @@
    *  We altered the set of thread priorities.  So let's figure out
    *  who is the heir and if we need to switch to them.
    */
-  _Thread_Calculate_heir();
+  _Scheduler_Schedule(&_Scheduler);
 
   if ( !_Thread_Is_executing_also_the_heir() &&
        _Thread_Executing->is_preemptible )

diff -u rtems/cpukit/score/src/threadclearstate.c:1.12 rtems/cpukit/score/src/threadclearstate.c:1.13
--- rtems/cpukit/score/src/threadclearstate.c:1.12	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/src/threadclearstate.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -66,31 +67,7 @@
       the_thread->current_state = _States_Clear( state, current_state );
 
       if ( _States_Is_ready( current_state ) ) {
-
-        _Priority_bit_map_Add( &the_thread->Priority_map );
-
-        _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
-
-        _ISR_Flash( level );
-
-        /*
-         *  If the thread that was unblocked is more important than the heir,
-         *  then we have a new heir.  This may or may not result in a
-         *  context switch.
-         *
-         *  Normal case:
-         *    If the current thread is preemptible, then we need to do
-         *    a context switch.
-         *  Pseudo-ISR case:
-         *    Even if the thread isn't preemptible, if the new heir is
-         *    a pseudo-ISR system task, we need to do a context switch.
-         */
-        if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
-          _Thread_Heir = the_thread;
-          if ( _Thread_Executing->is_preemptible ||
-               the_thread->current_priority == 0 )
-            _Thread_Dispatch_necessary = true;
-        }
+        _Scheduler_Unblock( &_Scheduler, the_thread);
       }
   }
   _ISR_Enable( level );

diff -u rtems/cpukit/score/src/threadclose.c:1.12 rtems/cpukit/score/src/threadclose.c:1.13
--- rtems/cpukit/score/src/threadclose.c:1.12	Thu May 22 15:38:03 2008
+++ rtems/cpukit/score/src/threadclose.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -86,6 +87,11 @@
   }
 
   /*
+   * Free the per-thread scheduling information.
+   */
+  _Scheduler_Thread_scheduler_free( &_Scheduler, the_thread );
+
+  /*
    *  The thread might have been FP.  So deal with that.
    */
 #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )

diff -u rtems/cpukit/score/src/threadinitialize.c:1.39 rtems/cpukit/score/src/threadinitialize.c:1.40
--- rtems/cpukit/score/src/threadinitialize.c:1.39	Thu Jun 17 21:56:26 2010
+++ rtems/cpukit/score/src/threadinitialize.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -60,6 +61,7 @@
   #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
     void              *fp_area;
   #endif
+  void                *sched = NULL;
   void                *extensions_area;
   bool                 extension_status;
   int                  i;
@@ -192,6 +194,9 @@
   the_thread->resource_count          = 0;
   the_thread->real_priority           = priority;
   the_thread->Start.initial_priority  = priority;
+  sched =_Scheduler_Thread_scheduler_allocate( &_Scheduler, the_thread );
+  if ( !sched )
+    goto failed;
   _Thread_Set_priority( the_thread, priority );
 
   /*
@@ -235,6 +240,9 @@
       (void) _Workspace_Free( fp_area );
   #endif
 
+  if ( sched )
+    (void) _Workspace_Free( sched );
+
    _Thread_Stack_Free( the_thread );
   return false;
 

diff -u rtems/cpukit/score/src/threadready.c:1.9 rtems/cpukit/score/src/threadready.c:1.10
--- rtems/cpukit/score/src/threadready.c:1.9	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/src/threadready.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -55,24 +56,12 @@
 )
 {
   ISR_Level              level;
-  Thread_Control *heir;
 
   _ISR_Disable( level );
 
   the_thread->current_state = STATES_READY;
 
-  _Priority_bit_map_Add( &the_thread->Priority_map );
-
-  _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
-
-  _ISR_Flash( level );
-
-  _Thread_Calculate_heir();
-
-  heir = _Thread_Heir;
-
-  if ( !_Thread_Is_executing( heir ) && _Thread_Executing->is_preemptible )
-    _Thread_Dispatch_necessary = true;
+  _Scheduler_Unblock( &_Scheduler, the_thread );
 
   _ISR_Enable( level );
 }

diff -u rtems/cpukit/score/src/threadresume.c:1.12 rtems/cpukit/score/src/threadresume.c:1.13
--- rtems/cpukit/score/src/threadresume.c:1.12	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/src/threadresume.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -68,19 +69,7 @@
     the_thread->current_state = _States_Clear(STATES_SUSPENDED, current_state);
 
     if ( _States_Is_ready( current_state ) ) {
-
-      _Priority_bit_map_Add( &the_thread->Priority_map );
-
-      _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
-
-      _ISR_Flash( level );
-
-      if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
-        _Thread_Heir = the_thread;
-        if ( _Thread_Executing->is_preemptible ||
-             the_thread->current_priority == 0 )
-          _Thread_Dispatch_necessary = true;
-      }
+      _Scheduler_Unblock( &_Scheduler, the_thread );
     }
   }
 

diff -u rtems/cpukit/score/src/threadsetpriority.c:1.5 rtems/cpukit/score/src/threadsetpriority.c:1.6
--- rtems/cpukit/score/src/threadsetpriority.c:1.5	Thu Jul 29 12:52:10 2010
+++ rtems/cpukit/score/src/threadsetpriority.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -50,10 +51,6 @@
 )
 {
   the_thread->current_priority = new_priority;
-  the_thread->ready            = &_Thread_Ready_chain[ new_priority ];
 
-  _Priority_bit_map_Initialize_information( 
-      &the_thread->Priority_map, 
-      new_priority 
-  );
+  _Scheduler_Thread_scheduler_update(&_Scheduler, the_thread);
 }

diff -u rtems/cpukit/score/src/threadsetstate.c:1.8 rtems/cpukit/score/src/threadsetstate.c:1.9
--- rtems/cpukit/score/src/threadsetstate.c:1.8	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/src/threadsetstate.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -54,9 +55,7 @@
 )
 {
   ISR_Level      level;
-  Chain_Control *ready;
-
-  ready = the_thread->ready;
+  
   _ISR_Disable( level );
   if ( !_States_Is_ready( the_thread->current_state ) ) {
     the_thread->current_state =
@@ -67,21 +66,7 @@
 
   the_thread->current_state = state;
 
-  if ( _Chain_Has_only_one_node( ready ) ) {
-
-    _Chain_Initialize_empty( ready );
-    _Priority_bit_map_Remove( &the_thread->Priority_map );
-
-  } else
-    _Chain_Extract_unprotected( &the_thread->Object.Node );
-
-  _ISR_Flash( level );
-
-  if ( _Thread_Is_heir( the_thread ) )
-     _Thread_Calculate_heir();
-
-  if ( _Thread_Is_executing( the_thread ) )
-    _Thread_Dispatch_necessary = true;
+  _Scheduler_Block( &_Scheduler, the_thread);
 
   _ISR_Enable( level );
 }

diff -u rtems/cpukit/score/src/threadsettransient.c:1.6 rtems/cpukit/score/src/threadsettransient.c:1.7
--- rtems/cpukit/score/src/threadsettransient.c:1.6	Thu Jul 29 12:52:10 2010
+++ rtems/cpukit/score/src/threadsettransient.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,8 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -54,22 +56,15 @@
 {
   ISR_Level             level;
   uint32_t              old_state;
-  Chain_Control *ready;
-
-  ready = the_thread->ready;
+  
   _ISR_Disable( level );
 
   old_state = the_thread->current_state;
   the_thread->current_state = _States_Set( STATES_TRANSIENT, old_state );
 
+  /* FIXME: need to check which scheduler to use? */
   if ( _States_Is_ready( old_state ) ) {
-    if ( _Chain_Has_only_one_node( ready ) ) {
-
-      _Chain_Initialize_empty( ready );
-      _Priority_bit_map_Remove( &the_thread->Priority_map );
-
-    } else
-      _Chain_Extract_unprotected( &the_thread->Object.Node );
+    _Scheduler_priority_Ready_queue_extract( the_thread);
   }
 
   _ISR_Enable( level );

diff -u rtems/cpukit/score/src/threadsuspend.c:1.9 rtems/cpukit/score/src/threadsuspend.c:1.10
--- rtems/cpukit/score/src/threadsuspend.c:1.9	Fri Jul 30 13:53:06 2010
+++ rtems/cpukit/score/src/threadsuspend.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -52,9 +53,7 @@
 )
 {
   ISR_Level      level;
-  Chain_Control *ready;
-
-  ready = the_thread->ready;
+  
   _ISR_Disable( level );
   if ( !_States_Is_ready( the_thread->current_state ) ) {
     the_thread->current_state =
@@ -65,21 +64,7 @@
 
   the_thread->current_state = STATES_SUSPENDED;
 
-  if ( _Chain_Has_only_one_node( ready ) ) {
-
-    _Chain_Initialize_empty( ready );
-    _Priority_bit_map_Remove( &the_thread->Priority_map );
-
-  } else
-    _Chain_Extract_unprotected( &the_thread->Object.Node );
-
-  _ISR_Flash( level );
-
-  if ( _Thread_Is_heir( the_thread ) )
-     _Thread_Calculate_heir();
-
-  if ( _Thread_Is_executing( the_thread ) )
-    _Thread_Dispatch_necessary = true;
+  _Scheduler_Block(&_Scheduler, the_thread);
 
   _ISR_Enable( level );
 }

diff -u rtems/cpukit/score/src/threadtickletimeslice.c:1.12 rtems/cpukit/score/src/threadtickletimeslice.c:1.13
--- rtems/cpukit/score/src/threadtickletimeslice.c:1.12	Thu Jun 24 16:27:30 2010
+++ rtems/cpukit/score/src/threadtickletimeslice.c	Wed Nov 24 09:51:28 2010
@@ -23,6 +23,7 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/states.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
@@ -89,7 +90,7 @@
          *  currently executing thread is placed at the rear of the
          *  FIFO for this priority and a new heir is selected.
          */
-        _Thread_Yield_processor();
+        _Scheduler_Yield( );
         executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
       }
       break;


 *joel*:
2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>

	PR 1647/cpukit
	* user/conf.t, user/schedule.t: Update documentation to reflect
	refactoring of SuperCore to add Scheduler and ability for user to
	configure a scheduler.

M  1.291  doc/ChangeLog
M   1.66  doc/user/conf.t
M   1.15  doc/user/schedule.t

diff -u rtems/doc/ChangeLog:1.290 rtems/doc/ChangeLog:1.291
--- rtems/doc/ChangeLog:1.290	Thu Nov 11 08:01:32 2010
+++ rtems/doc/ChangeLog	Wed Nov 24 09:52:21 2010
@@ -1,3 +1,10 @@
+2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>
+
+	PR 1647/cpukit
+	* user/conf.t, user/schedule.t: Update documentation to reflect
+	refactoring of SuperCore to add Scheduler and ability for user to
+	configure a scheduler.
+
 2010-11-11	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
 	PR 1716/doc

diff -u rtems/doc/user/conf.t:1.65 rtems/doc/user/conf.t:1.66
--- rtems/doc/user/conf.t:1.65	Thu Jun 17 13:45:36 2010
+++ rtems/doc/user/conf.t	Wed Nov 24 09:52:21 2010
@@ -24,6 +24,7 @@
 information encompasses a variety of information including 
 the length of each clock tick, the maximum number of each RTEMS
 object that can be created, the application initialization tasks,
+the task scheduling algorithm to be used, 
 and the device drivers in the application.  This information
 is placed in data structures that are given to RTEMS at
 system initialization time.  This chapter details the 
@@ -392,6 +393,54 @@
 @c
 @c
 @c
+ at subsection Scheduler Algorithm Configuration
+This section defines the configuration parameters related to selecting 
+a scheduling algorithm for an application.  Regardless of whether 
+ at code{CONFIGURE_SCHEDULER_POLICY} is defined, if none of the other 
+configuration parameters are set, then @code{rtems/confdefs.h} will define 
+ at code{CONFIGURE_SCHEDULER_PRIORITY} and will (re)define 
+ at code{CONFIGURE_SCHEDULER_POLICY} as @code{_Scheduler_Priority}. That is, 
+ at code{CONFIGURE_SCHEDULER_PRIORITY} is the default scheduling algorithm.
+
+ at itemize @bullet
+ at findex CONFIGURE_SCHEDULER_POLICY
+ at item @code{CONFIGURE_SCHEDULER_POLICY} is defined to specify which 
+scheduling algorithm an application will use.  If it is undefined, 
+then @code{rtems/confdefs.h} will define it based on the definition 
+of the following configuration parameters.
+Valid values for this configuration parameter are: 
+ at code{_Scheduler_USER},
+ at code{_Scheduler_Priority}.
+
+ at findex CONFIGURE_SCHEDULER_USER
+ at item @code{CONFIGURE_SCHEDULER_USER} is defined if the application 
+provides its own scheduling algorithm. If @code{CONFIGURE_SCHEDULER_USER} is 
+defined then @code{CONFIGURE_SCHEDULER_ENTRY_USER} must be defined with the 
+name of the application's initialization function.  If both 
+configuration parameters are defined and @code{CONFIGURE_SCHEDULER_POLICY} 
+is undefined, then @code{CONFIGURE_SCHEDULER_POLICY} will be be defined as 
+ at code{_Scheduler_USER}.
+
+ at findex CONFIGURE_SCHEDULER_ALL
+ at item @code{CONFIGURE_SCHEDULER_ALL} is defined if the application 
+chooses to include all of the RTEMS-provided schedulers.  
+ at code{CONFIGURE_SCHEDULER_ALL} will define all of the following configuration 
+parameters and will use @code{CONFIGURE_SCHEDULER_POLICY} to select the 
+algorithm to use. If @code{CONFIGURE_SCHEDULER_POLICY} is not defined, then 
+ at code{rtems/confdefs.h} will define it as @code{_Scheduler_Priority}.
+
+ at findex CONFIGURE_SCHEDULER_PRIORITY
+ at item @code{CONFIGURE_SCHEDULER_PRIORITY} is defined if the application 
+will use the Priority Scheduling algorithm.
+If none of the previous configuration parameters are defined by the 
+application, then @code{rtems/confdefs.h} will define 
+ at code{CONFIGURE_SCHEDULER_POLICY} as @code{_Scheduler_PRIORITY}.
+
+ at end itemize
+
+ at c
+ at c
+ at c
 @subsection Device Driver Table
 
 This section defines the configuration parameters related
@@ -816,6 +865,7 @@
   uint32_t                        maximum_extensions;
   uint32_t                        microseconds_per_tick;
   uint32_t                        ticks_per_timeslice;
+  uint32_t                        scheduler_policy;
   void                          (*idle_task)( void );
   uint32_t                        idle_task_stack_size;
   uint32_t                        interrupt_stack_size;
@@ -875,6 +925,12 @@
 an RTEMS application, the value for this field corresponds
 to the setting of the macro @code{CONFIGURE_TICKS_PER_TIMESLICE}.
 
+ at item scheduler_policy
+is the algorithm to use for task scheduling.
+When using the @code{rtems/confdefs.h} mechanism for configuring
+an RTEMS application, the value for this field corresponds
+to the setting of the macro @code{CONFIGURE_SCHEDULER_POLICY}.
+
 @item idle_task
 is the address of the optional user
 provided routine which is used as the system's IDLE task.  If

diff -u rtems/doc/user/schedule.t:1.14 rtems/doc/user/schedule.t:1.15
--- rtems/doc/user/schedule.t:1.14	Mon Nov  9 08:36:14 2009
+++ rtems/doc/user/schedule.t	Wed Nov 24 09:52:21 2010
@@ -30,7 +30,30 @@
 capability is appropriately called the scheduler.  The
 scheduler's sole purpose is to allocate the all important
 resource of processor time to the various tasks competing for
-attention.  The RTEMS scheduler allocates the processor using a
+attention.  
+
+ at section Scheduling Algorithms
+
+ at cindex scheduling algorithms
+
+RTEMS provides multiple possible scheduling algorithms, each 
+of which are appropriate to different use case scenarios. 
+The classic RTEMS scheduling algorithm -- the only 
+algorithm available in RTEMS 4.10 and earlier -- is the priority
+scheduling algorithm.  When not specified, the priority scheduling
+algorithm can be assumed.
+
+RTEMS currently supports the following scheduling algorithms:
+
+ at itemize @bullet
+ at item Priority scheduling
+ at end itemize
+
+ at subsection Priority Scheduling
+
+ at cindex priority scheduling
+
+The RTEMS scheduler allocates the processor using a
 priority-based, preemptive algorithm augmented to provide
 round-robin characteristics within individual priority groups.
 The goal of this algorithm is to guarantee that the task which
@@ -50,6 +73,11 @@
 the second method to guarantee faster response times to external
 events.
 
+Priority scheduling is the most commonly used scheduling algorithm.
+It should be used by applications in which multiple tasks contend for 
+CPU time or other resources and there is a need to ensure certain tasks
+are given priority over other tasks.
+
 @section Scheduling Mechanisms
 
 @cindex scheduling mechanisms
@@ -81,6 +109,11 @@
 
 @cindex task priority
 
+This mechanism affects the following scheduling algorithms:
+ at itemize @bullet
+ at item Priority scheduling
+ at end itemize
+
 The most significant of these mechanisms is the
 ability for the user to assign a priority level to each
 individual task when it is created and to alter a task's
@@ -104,6 +137,11 @@
 
 @cindex preemption
 
+This mechanism affects the following scheduling algorithms:
+ at itemize @bullet
+ at item Priority scheduling
+ at end itemize
+
 Another way the user can alter the basic scheduling
 algorithm is by manipulating the preemption mode flag
 (@code{@value{RPREFIX}PREEMPT_MASK}) of individual tasks.  If preemption is disabled
@@ -120,6 +158,11 @@
 @cindex timeslicing
 @cindex round robin scheduling
 
+This mechanism affects the following scheduling algorithms:
+ at itemize @bullet
+ at item Priority scheduling
+ at end itemize
+
 Timeslicing or round-robin scheduling is an
 additional method which can be used to alter the basic
 scheduling algorithm.  Like preemption, timeslicing is specified
@@ -141,6 +184,11 @@
 
 @cindex manual round robin
 
+This mechanism affects the following scheduling algorithms:
+ at itemize @bullet
+ at item Priority scheduling
+ at end itemize
+
 The final mechanism for altering the RTEMS scheduling
 algorithm is called manual round-robin.  Manual round-robin is
 invoked by using the @code{@value{DIRPREFIX}task_wake_after}
@@ -151,7 +199,7 @@
 priority are ready to run, then the task does not lose control
 of the processor.
 
- at subsection Dispatching Tasks
+ at section Dispatching Tasks
 
 @cindex dispatching
 


 *joel*:
2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>

	PR 1647/cpukit
	* spsize/size.c: Update documentation to reflect refactoring of
	SuperCore to add Scheduler Handler.

M  1.425  testsuites/sptests/ChangeLog
M   1.69  testsuites/sptests/spsize/size.c

diff -u rtems/testsuites/sptests/ChangeLog:1.424 rtems/testsuites/sptests/ChangeLog:1.425
--- rtems/testsuites/sptests/ChangeLog:1.424	Tue Nov 16 13:01:29 2010
+++ rtems/testsuites/sptests/ChangeLog	Wed Nov 24 10:06:22 2010
@@ -1,3 +1,9 @@
+2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>
+
+	PR 1647/cpukit
+	* spsize/size.c: Update documentation to reflect refactoring of
+	SuperCore to add Scheduler Handler.
+
 2010-11-16	Joel Sherrill <joel.sherrill at oarcorp.com>
 
 	* sp70/init.c, sp70/sp70.scn: Fix bug in test which lead to random

diff -u rtems/testsuites/sptests/spsize/size.c:1.68 rtems/testsuites/sptests/spsize/size.c:1.69
--- rtems/testsuites/sptests/spsize/size.c:1.68	Sun Oct  3 02:16:50 2010
+++ rtems/testsuites/sptests/spsize/size.c	Wed Nov 24 10:06:22 2010
@@ -37,6 +37,7 @@
 #include <rtems/rtems/region.h>
 #include <rtems/rtems/sem.h>
 #include <rtems/rtems/signal.h>
+#include <rtems/score/scheduler.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/thread.h>
 #include <rtems/rtems/timer.h>
@@ -49,6 +50,8 @@
 #include <unistd.h>
 #include <tmacros.h>
 
+#include "system.h"
+
 /* external function prototypes */
 int getint( void );
 void size_rtems(int mode);
@@ -64,12 +67,32 @@
  */
 #define  HEAP_OVHD        16    /* wasted heap space per task stack */
 #define  NAME_PTR_SIZE     8    /* size of name and pointer table entries */
-#define  READYCHAINS_SIZE  \
+
+#if CONFIGURE_SCHEDULER_POLICY == _Scheduler_PRIORITY
+  #include <rtems/score/prioritybitmap.h>
+
+  /* Priority scheduling uninitialized (globals) consumption */
+  #define SCHEDULER_OVHD          ((sizeof _Scheduler)              + \
+                                   (sizeof _Priority_Major_bit_map) + \
+                                   (sizeof _Priority_Bit_map))
+
+  /* Priority scheduling per-thread consumption. Gets 
+   * included in the PER_TASK consumption. */
+  #define SCHEDULER_TASK_WKSP     (sizeof(Scheduler_priority_Per_thread))
+
+  /* Priority scheduling workspace consumption 
+   *
+   * Include allocation of ready queue.  Pointers are already counted by 
+   * including _Scheduler in SCHEDULER_OVHD.
+   */
+  #define  SCHEDULER_WKSP_SIZE  \
     ((RTEMS_MAXIMUM_PRIORITY + 1) * sizeof(Chain_Control ))
+#endif
 
 #define PER_TASK      \
      (long) (sizeof (Thread_Control) + \
-      NAME_PTR_SIZE + HEAP_OVHD + sizeof( RTEMS_API_Control ))
+      NAME_PTR_SIZE + HEAP_OVHD + sizeof( RTEMS_API_Control ) + \
+      SCHEDULER_TASK_WKSP )
 #define PER_SEMAPHORE \
      (long) (sizeof (Semaphore_Control) + NAME_PTR_SIZE)
 #define PER_TIMER     \
@@ -159,10 +182,10 @@
  *
  *    + Object MP
  *      - Global Object CB's
- *    + Thread
- *      - Ready Chain
  *    + Thread MP
  *      - Proxies Chain
+ *    + Scheduler
+ *      - Ready queue
  *    + Interrupt Manager
  *      - Interrupt Stack
  *    + Timer Manager
@@ -195,18 +218,18 @@
  *  The following calculates the overhead needed by RTEMS from the
  *  Workspace Area.
  */
-sys_req = SYSTEM_TASKS     +     /* MPCI Receive Server and IDLE */
-          NAME_PTR_SIZE    +     /* Task Overhead */
-          READYCHAINS_SIZE +     /* Ready Chains */
-          NAME_PTR_SIZE    +     /* Timer Overhead */
-          NAME_PTR_SIZE    +     /* Semaphore Overhead */
-          NAME_PTR_SIZE    +     /* Message Queue Overhead */
-          NAME_PTR_SIZE    +     /* Region Overhead */
-          NAME_PTR_SIZE    +     /* Partition Overhead */
-          NAME_PTR_SIZE    +     /* Dual-Ported Memory Overhead */
-          NAME_PTR_SIZE    +     /* Rate Monotonic Overhead */
-          NAME_PTR_SIZE    +     /* Extension Overhead */
-          PER_NODE;              /* Extra Gobject Table */
+sys_req = SYSTEM_TASKS        +     /* MPCI Receive Server and IDLE */
+          NAME_PTR_SIZE       +     /* Task Overhead */
+          SCHEDULER_WKSP_SIZE +     /* Scheduler Overhead */
+          NAME_PTR_SIZE       +     /* Timer Overhead */
+          NAME_PTR_SIZE       +     /* Semaphore Overhead */
+          NAME_PTR_SIZE       +     /* Message Queue Overhead */
+          NAME_PTR_SIZE       +     /* Region Overhead */
+          NAME_PTR_SIZE       +     /* Partition Overhead */
+          NAME_PTR_SIZE       +     /* Dual-Ported Memory Overhead */
+          NAME_PTR_SIZE       +     /* Rate Monotonic Overhead */
+          NAME_PTR_SIZE       +     /* Extension Overhead */
+          PER_NODE;                 /* Extra Gobject Table */
 
 uninitialized =
 /*address.h*/   0                                         +
@@ -311,9 +334,6 @@
 
 /*percpu.h*/    (sizeof _Per_CPU_Information)             +
 
-/*priority.h*/  (sizeof _Priority_Major_bit_map)          +
-                (sizeof _Priority_Bit_map)                +
-
 /*ratemon.h*/   (sizeof _Rate_monotonic_Information)      +
 
 /*region.h*/    (sizeof _Region_Information)              +
@@ -324,6 +344,8 @@
 
 /*rtems.h*/     /* Not applicable */
 
+/*scheduler.h*/ SCHEDULER_OVHD                            + 
+
 /*sem.h*/       (sizeof _Semaphore_Information)           +
 
 #if defined(RTEMS_MULTIPROCESSING)
@@ -355,7 +377,6 @@
                 (sizeof _Thread_Dispatch_disable_level)   +
                 (sizeof _Thread_Maximum_extensions)       +
                 (sizeof _Thread_Ticks_per_timeslice)      +
-                (sizeof _Thread_Ready_chain)              +
                 (sizeof _Thread_Executing)                +
                 (sizeof _Thread_Heir)                     +
 #if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1)


 *joel*:
2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>

	PR 1647/cpukit
	* tm26/task1.c, tm27/task1.c: Update documentation to reflect
	refactoring of SuperCore to add Scheduler Handler.

M   1.91  testsuites/tmtests/ChangeLog
M   1.33  testsuites/tmtests/tm26/task1.c
M   1.30  testsuites/tmtests/tm27/task1.c

diff -u rtems/testsuites/tmtests/ChangeLog:1.90 rtems/testsuites/tmtests/ChangeLog:1.91
--- rtems/testsuites/tmtests/ChangeLog:1.90	Mon Oct 25 02:27:51 2010
+++ rtems/testsuites/tmtests/ChangeLog	Wed Nov 24 10:06:37 2010
@@ -1,3 +1,9 @@
+2010-11-24	Gedare Bloom <giddyup44 at yahoo.com>
+
+	PR 1647/cpukit
+	* tm26/task1.c, tm27/task1.c: Update documentation to reflect
+	refactoring of SuperCore to add Scheduler Handler.
+
 2010-10-25	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
 	* tm26/task1.c, tm27/task1.c: Do not violate chain API.

diff -u rtems/testsuites/tmtests/tm26/task1.c:1.32 rtems/testsuites/tmtests/tm26/task1.c:1.33
--- rtems/testsuites/tmtests/tm26/task1.c:1.32	Mon Oct 25 02:27:51 2010
+++ rtems/testsuites/tmtests/tm26/task1.c	Wed Nov 24 10:06:37 2010
@@ -242,7 +242,8 @@
   Middle_tcb   = _Thread_Executing;
 
   _Thread_Executing =
-        (Thread_Control *) _Chain_First(&_Thread_Ready_chain[LOW_PRIORITY]);
+        (Thread_Control *) 
+        _Chain_First(&_Scheduler.ready_queues.Priority[LOW_PRIORITY]);
 
   /* do not force context switch */
 
@@ -279,7 +280,8 @@
   context_switch_another_task_time = benchmark_timer_read();
 
   _Thread_Executing =
-        (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP1_PRIORITY]);
+        (Thread_Control *) 
+        _Chain_First(&_Scheduler.ready_queues.Priority[FP1_PRIORITY]);
 
   /* do not force context switch */
 
@@ -306,7 +308,8 @@
   executing = _Thread_Executing;
 
   _Thread_Executing =
-        (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP2_PRIORITY]);
+        (Thread_Control *) 
+        _Chain_First(&_Scheduler.ready_queues.Priority[FP2_PRIORITY]);
 
   /* do not force context switch */
 
@@ -329,7 +332,8 @@
   executing = _Thread_Executing;
 
   _Thread_Executing =
-       (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP2_PRIORITY]);
+       (Thread_Control *)
+       _Chain_First(&_Scheduler.ready_queues.Priority[FP2_PRIORITY]);
 
   /* do not force context switch */
 
@@ -358,7 +362,8 @@
   executing = _Thread_Executing;
 
   _Thread_Executing =
-       (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP1_PRIORITY]);
+       (Thread_Control *)
+       _Chain_First(&_Scheduler.ready_queues.Priority[FP1_PRIORITY]);
 
   FP_LOAD( 1.0 );
 

diff -u rtems/testsuites/tmtests/tm27/task1.c:1.29 rtems/testsuites/tmtests/tm27/task1.c:1.30
--- rtems/testsuites/tmtests/tm27/task1.c:1.29	Mon Oct 25 02:27:51 2010
+++ rtems/testsuites/tmtests/tm27/task1.c	Wed Nov 24 10:06:37 2010
@@ -170,7 +170,8 @@
 
   _Thread_Dispatch_disable_level = 0;
 
-  _Thread_Heir = (rtems_tcb *) _Chain_Last(&_Thread_Ready_chain[LOW_PRIORITY]);
+  _Thread_Heir = (rtems_tcb *) 
+        _Chain_Last(&_Scheduler.ready_queues.Priority[LOW_PRIORITY]);
 
   _Thread_Dispatch_necessary = 1;
 
@@ -227,7 +228,8 @@
 
   _Thread_Dispatch_disable_level = 0;
 
-  _Thread_Heir = (rtems_tcb *) _Chain_First(&_Thread_Ready_chain[LOW_PRIORITY]);
+  _Thread_Heir = (rtems_tcb *)
+      _Chain_First(&_Scheduler.ready_queues.Priority[LOW_PRIORITY]);
 
   _Thread_Dispatch_necessary = 1;
 



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20101124/0757c334/attachment.html>


More information about the vc mailing list