forked from Imagelibrary/rtems
2010-11-24 Gedare Bloom <giddyup44@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.
This commit is contained in:
@@ -1,3 +1,31 @@
|
|||||||
|
2010-11-24 Gedare Bloom <giddyup44@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@embedded-brains.de>
|
2010-11-23 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* score/src/iterateoverthreads.c, libmisc/cpuuse/cpuusagereport.c:
|
* score/src/iterateoverthreads.c, libmisc/cpuuse/cpuusagereport.c:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <rtems/system.h>
|
#include <rtems/system.h>
|
||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
#include <rtems/score/tod.h>
|
#include <rtems/score/tod.h>
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ int nanosleep(
|
|||||||
|
|
||||||
if ( !ticks ) {
|
if ( !ticks ) {
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
_Thread_Yield_processor();
|
_Scheduler_Yield();
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
if ( rmtp ) {
|
if ( rmtp ) {
|
||||||
rmtp->tv_sec = 0;
|
rmtp->tv_sec = 0;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <rtems/system.h>
|
#include <rtems/system.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/tod.h>
|
#include <rtems/score/tod.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
#include <rtems/seterr.h>
|
#include <rtems/seterr.h>
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
int sched_yield( void )
|
int sched_yield( void )
|
||||||
{
|
{
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
_Thread_Yield_processor();
|
_Scheduler_Yield();
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <rtems/rtems/support.h>
|
#include <rtems/rtems/support.h>
|
||||||
#include <rtems/rtems/modes.h>
|
#include <rtems/rtems/modes.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/stack.h>
|
#include <rtems/score/stack.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/rtems/tasks.h>
|
#include <rtems/rtems/tasks.h>
|
||||||
@@ -52,7 +53,7 @@ rtems_status_code rtems_task_wake_after(
|
|||||||
{
|
{
|
||||||
_Thread_Disable_dispatch();
|
_Thread_Disable_dispatch();
|
||||||
if ( ticks == 0 ) {
|
if ( ticks == 0 ) {
|
||||||
_Thread_Yield_processor();
|
_Scheduler_Yield();
|
||||||
} else {
|
} else {
|
||||||
_Thread_Set_state( _Thread_Executing, STATES_DELAYING );
|
_Thread_Set_state( _Thread_Executing, STATES_DELAYING );
|
||||||
_Watchdog_Initialize(
|
_Watchdog_Initialize(
|
||||||
|
|||||||
@@ -534,6 +534,116 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
|||||||
#define CONFIGURE_MAXIMUM_PRIORITY PRIORITY_DEFAULT_MAXIMUM
|
#define CONFIGURE_MAXIMUM_PRIORITY PRIORITY_DEFAULT_MAXIMUM
|
||||||
#endif
|
#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
|
* If you said the IDLE task was going to do application initialization
|
||||||
* and didn't override the IDLE body, then something is amiss.
|
* and didn't override the IDLE body, then something is amiss.
|
||||||
@@ -1607,7 +1717,8 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
|||||||
(_Configure_From_workspace(CONFIGURE_MINIMUM_TASK_STACK_SIZE) + \
|
(_Configure_From_workspace(CONFIGURE_MINIMUM_TASK_STACK_SIZE) + \
|
||||||
CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API + \
|
CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API + \
|
||||||
CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB + \
|
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_From_workspace( \
|
||||||
_Configure_Max_Objects(_number_FP_tasks) * CONTEXT_FP_SIZE) + \
|
_Configure_Max_Objects(_number_FP_tasks) * CONTEXT_FP_SIZE) + \
|
||||||
_Configure_From_workspace( \
|
_Configure_From_workspace( \
|
||||||
@@ -1704,13 +1815,6 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
|||||||
#define CONFIGURE_API_MUTEX_MEMORY \
|
#define CONFIGURE_API_MUTEX_MEMORY \
|
||||||
_Configure_Object_RAM(1, sizeof(API_Mutex_Control))
|
_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
|
* This defines the amount of memory reserved for the IDLE task
|
||||||
* control structures and stack.
|
* control structures and stack.
|
||||||
@@ -1724,7 +1828,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
|||||||
*/
|
*/
|
||||||
#define CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \
|
#define CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \
|
||||||
( CONFIGURE_MEMORY_FOR_IDLE_TASK + /* IDLE and stack */ \
|
( 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_VECTOR_TABLE + /* interrupt vectors */ \
|
||||||
CONFIGURE_INTERRUPT_STACK_MEMORY + /* interrupt stack */ \
|
CONFIGURE_INTERRUPT_STACK_MEMORY + /* interrupt stack */ \
|
||||||
CONFIGURE_API_MUTEX_MEMORY /* allocation mutex */ \
|
CONFIGURE_API_MUTEX_MEMORY /* allocation mutex */ \
|
||||||
@@ -2005,6 +2109,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
|||||||
CONFIGURE_MAXIMUM_USER_EXTENSIONS, /* maximum dynamic extensions */
|
CONFIGURE_MAXIMUM_USER_EXTENSIONS, /* maximum dynamic extensions */
|
||||||
CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */
|
CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */
|
||||||
CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */
|
CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */
|
||||||
|
CONFIGURE_SCHEDULER_POLICY, /* scheduling policy */
|
||||||
CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */
|
CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */
|
||||||
CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */
|
CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */
|
||||||
CONFIGURE_INTERRUPT_STACK_SIZE, /* interrupt stack size */
|
CONFIGURE_INTERRUPT_STACK_SIZE, /* interrupt stack size */
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
uint32_t ticks_per_timeslice;
|
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
|
/** This element points to the BSP's optional idle task which may override
|
||||||
* the default one provided with RTEMS.
|
* the default one provided with RTEMS.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <rtems/score/mpci.h>
|
#include <rtems/score/mpci.h>
|
||||||
#endif
|
#endif
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
#include <rtems/score/prioritybitmap.h>
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
#include <rtems/score/tod.h>
|
#include <rtems/score/tod.h>
|
||||||
#include <rtems/score/userext.h>
|
#include <rtems/score/userext.h>
|
||||||
@@ -131,6 +131,8 @@ void rtems_initialize_data_structures(void)
|
|||||||
|
|
||||||
_Thread_Handler_initialization();
|
_Thread_Handler_initialization();
|
||||||
|
|
||||||
|
_Scheduler_Handler_initialization();
|
||||||
|
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
_Objects_MP_Handler_initialization();
|
_Objects_MP_Handler_initialization();
|
||||||
_MPCI_Handler_initialization( RTEMS_TIMEOUT );
|
_MPCI_Handler_initialization( RTEMS_TIMEOUT );
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ include_rtems_score_HEADERS = include/rtems/score/address.h \
|
|||||||
include/rtems/score/interr.h include/rtems/score/isr.h \
|
include/rtems/score/interr.h include/rtems/score/isr.h \
|
||||||
include/rtems/score/object.h include/rtems/score/percpu.h \
|
include/rtems/score/object.h include/rtems/score/percpu.h \
|
||||||
include/rtems/score/priority.h include/rtems/score/prioritybitmap.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/stack.h include/rtems/score/states.h \
|
||||||
include/rtems/score/sysstate.h include/rtems/score/thread.h \
|
include/rtems/score/sysstate.h include/rtems/score/thread.h \
|
||||||
include/rtems/score/threadq.h include/rtems/score/threadsync.h \
|
include/rtems/score/threadq.h include/rtems/score/threadsync.h \
|
||||||
@@ -54,6 +55,7 @@ include_rtems_score_HEADERS += inline/rtems/score/address.inl \
|
|||||||
inline/rtems/score/coresem.inl inline/rtems/score/heap.inl \
|
inline/rtems/score/coresem.inl inline/rtems/score/heap.inl \
|
||||||
inline/rtems/score/isr.inl inline/rtems/score/object.inl \
|
inline/rtems/score/isr.inl inline/rtems/score/object.inl \
|
||||||
inline/rtems/score/priority.inl inline/rtems/score/prioritybitmap.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/stack.inl inline/rtems/score/states.inl \
|
||||||
inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
|
inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
|
||||||
inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \
|
inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \
|
||||||
@@ -137,6 +139,19 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
|
|||||||
src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
|
src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
|
||||||
src/objectnamespaceremove.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
|
## PROTECTED_HEAP_C_FILES
|
||||||
libscore_a_SOURCES += src/pheapallocate.c \
|
libscore_a_SOURCES += src/pheapallocate.c \
|
||||||
src/pheapextend.c src/pheapfree.c src/pheapgetsize.c \
|
src/pheapextend.c src/pheapfree.c src/pheapgetsize.c \
|
||||||
@@ -153,7 +168,7 @@ libscore_a_SOURCES += src/thread.c src/threadchangepriority.c \
|
|||||||
src/threadsetstate.c src/threadsettransient.c \
|
src/threadsetstate.c src/threadsettransient.c \
|
||||||
src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \
|
src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \
|
||||||
src/threadstartmultitasking.c src/threadsuspend.c \
|
src/threadstartmultitasking.c src/threadsuspend.c \
|
||||||
src/threadtickletimeslice.c src/threadyieldprocessor.c \
|
src/threadtickletimeslice.c \
|
||||||
src/iterateoverthreads.c src/threadblockingoperationcancel.c
|
src/iterateoverthreads.c src/threadblockingoperationcancel.c
|
||||||
|
|
||||||
## THREADQ_C_FILES
|
## THREADQ_C_FILES
|
||||||
|
|||||||
@@ -37,18 +37,17 @@ extern "C" {
|
|||||||
|
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* The Priority_bit_map_Control variables are instantiated only
|
||||||
* These should only be instantiated if using the bit map handler. The
|
* if using the bit map handler.
|
||||||
* logical place for this is in confdefs.h when a scheduler that uses the
|
|
||||||
* bit map handler is configured.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each sixteen bit entry in this array is associated with one of
|
* Each sixteen bit entry in this array is associated with one of
|
||||||
* the sixteen entries in the Priority Bit map.
|
* 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
|
/** Each bit in the Priority Bitmap indicates whether or not there are
|
||||||
* threads ready at a particular priority. The mapping of
|
* threads ready at a particular priority. The mapping of
|
||||||
@@ -56,7 +55,7 @@ SCORE_EXTERN volatile Priority_bit_map_Control _Priority_Major_bit_map;
|
|||||||
* dependent as is the value of each bit used to indicate that
|
* dependent as is the value of each bit used to indicate that
|
||||||
* threads are ready at that priority.
|
* threads are ready at that priority.
|
||||||
*/
|
*/
|
||||||
SCORE_EXTERN Priority_bit_map_Control
|
extern Priority_bit_map_Control
|
||||||
_Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
|
_Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
156
cpukit/score/include/rtems/score/scheduler.h
Normal file
156
cpukit/score/include/rtems/score/scheduler.h
Normal file
@@ -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 */
|
||||||
117
cpukit/score/include/rtems/score/schedulerpriority.h
Normal file
117
cpukit/score/include/rtems/score/schedulerpriority.h
Normal file
@@ -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 */
|
||||||
@@ -70,7 +70,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
#include <rtems/score/prioritybitmap.h>
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/stack.h>
|
#include <rtems/score/stack.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/tod.h>
|
#include <rtems/score/tod.h>
|
||||||
@@ -390,10 +390,10 @@ struct Thread_Control_struct {
|
|||||||
* since it was created.
|
* since it was created.
|
||||||
*/
|
*/
|
||||||
Thread_CPU_usage_t cpu_time_used;
|
Thread_CPU_usage_t cpu_time_used;
|
||||||
/** This field points to the Ready FIFO for this priority. */
|
/** This union holds per-thread data for the scheduler and ready queue. */
|
||||||
Chain_Control *ready;
|
union {
|
||||||
/** This field contains precalculated priority map indices. */
|
Scheduler_priority_Per_thread *priority;
|
||||||
Priority_bit_map_Information Priority_map;
|
} scheduler;
|
||||||
/** This field contains information about the starting state of
|
/** This field contains information about the starting state of
|
||||||
* this thread.
|
* this thread.
|
||||||
*/
|
*/
|
||||||
@@ -455,12 +455,6 @@ SCORE_EXTERN uint32_t _Thread_Maximum_extensions;
|
|||||||
*/
|
*/
|
||||||
SCORE_EXTERN uint32_t _Thread_Ticks_per_timeslice;
|
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
|
* The following points to the thread whose floating point
|
||||||
* context is currently loaded.
|
* context is currently loaded.
|
||||||
@@ -653,13 +647,6 @@ void _Thread_Set_transient(
|
|||||||
*/
|
*/
|
||||||
void _Thread_Tickle_timeslice( void );
|
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
|
* This routine initializes the context of the_thread to its
|
||||||
* appropriate starting state.
|
* appropriate starting state.
|
||||||
|
|||||||
139
cpukit/score/inline/rtems/score/scheduler.inl
Normal file
139
cpukit/score/inline/rtems/score/scheduler.inl
Normal file
@@ -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 */
|
||||||
286
cpukit/score/inline/rtems/score/schedulerpriority.inl
Normal file
286
cpukit/score/inline/rtems/score/schedulerpriority.inl
Normal file
@@ -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 */
|
||||||
@@ -119,17 +119,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Restart_self( void )
|
|||||||
_CPU_Context_Restart_self( &_Thread_Executing->Registers );
|
_CPU_Context_Restart_self( &_Thread_Executing->Registers );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* This function returns true if the floating point context of
|
||||||
* the_thread is currently loaded in the floating point unit, and
|
* the_thread is currently loaded in the floating point unit, and
|
||||||
|
|||||||
@@ -111,6 +111,14 @@ $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h: include/rtems/score/prioritybit
|
|||||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h
|
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h
|
||||||
PREINSTALL_FILES += $(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)
|
$(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
|
||||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h
|
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h
|
||||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.h
|
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.h
|
||||||
@@ -245,6 +253,14 @@ $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl: inline/rtems/score/prioritybi
|
|||||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl
|
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl
|
||||||
PREINSTALL_FILES += $(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)
|
$(PROJECT_INCLUDE)/rtems/score/stack.inl: inline/rtems/score/stack.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
|
||||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl
|
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl
|
||||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.inl
|
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.inl
|
||||||
|
|||||||
45
cpukit/score/src/scheduler.c
Normal file
45
cpukit/score/src/scheduler.c
Normal file
@@ -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
|
||||||
|
);
|
||||||
|
}
|
||||||
66
cpukit/score/src/schedulerpriority.c
Normal file
66
cpukit/score/src/schedulerpriority.c
Normal file
@@ -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( );
|
||||||
|
}
|
||||||
48
cpukit/score/src/schedulerpriorityblock.c
Normal file
48
cpukit/score/src/schedulerpriorityblock.c
Normal file
@@ -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);
|
||||||
|
}
|
||||||
48
cpukit/score/src/schedulerpriorityschedule.c
Normal file
48
cpukit/score/src/schedulerpriorityschedule.c
Normal file
@@ -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 );
|
||||||
|
}
|
||||||
53
cpukit/score/src/schedulerprioritythreadschedulerallocate.c
Normal file
53
cpukit/score/src/schedulerprioritythreadschedulerallocate.c
Normal file
@@ -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;
|
||||||
|
}
|
||||||
46
cpukit/score/src/schedulerprioritythreadschedulerfree.c
Normal file
46
cpukit/score/src/schedulerprioritythreadschedulerfree.c
Normal file
@@ -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 );
|
||||||
|
}
|
||||||
55
cpukit/score/src/schedulerprioritythreadschedulerupdate.c
Normal file
55
cpukit/score/src/schedulerprioritythreadschedulerupdate.c
Normal file
@@ -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
|
||||||
|
);
|
||||||
|
}
|
||||||
57
cpukit/score/src/schedulerpriorityunblock.c
Normal file
57
cpukit/score/src/schedulerpriorityunblock.c
Normal file
@@ -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);
|
||||||
|
}
|
||||||
77
cpukit/score/src/schedulerpriorityyield.c
Normal file
77
cpukit/score/src/schedulerpriorityyield.c
Normal file
@@ -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 );
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -45,7 +46,6 @@
|
|||||||
|
|
||||||
void _Thread_Handler_initialization(void)
|
void _Thread_Handler_initialization(void)
|
||||||
{
|
{
|
||||||
uint32_t index;
|
|
||||||
uint32_t ticks_per_timeslice;
|
uint32_t ticks_per_timeslice;
|
||||||
uint32_t maximum_extensions;
|
uint32_t maximum_extensions;
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
@@ -80,13 +80,6 @@ void _Thread_Handler_initialization(void)
|
|||||||
|
|
||||||
_Thread_Ticks_per_timeslice = ticks_per_timeslice;
|
_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)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
_Thread_MP_Handler_initialization( maximum_proxies );
|
_Thread_MP_Handler_initialization( maximum_proxies );
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
|
#include <rtems/score/schedulerpriority.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -117,14 +119,16 @@ void _Thread_Change_priority(
|
|||||||
* We now know the thread will be in the READY state when we remove
|
* 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
|
* the TRANSIENT state. So we have to place it on the appropriate
|
||||||
* Ready Queue with interrupts off.
|
* 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 );
|
the_thread->current_state = _States_Clear( STATES_TRANSIENT, state );
|
||||||
|
|
||||||
_Priority_bit_map_Add( &the_thread->Priority_map );
|
|
||||||
if ( prepend_it )
|
if ( prepend_it )
|
||||||
_Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node );
|
_Scheduler_priority_Ready_queue_enqueue_first( the_thread );
|
||||||
else
|
else
|
||||||
_Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
|
_Scheduler_priority_Ready_queue_enqueue( the_thread );
|
||||||
}
|
}
|
||||||
|
|
||||||
_ISR_Flash( level );
|
_ISR_Flash( level );
|
||||||
@@ -133,7 +137,7 @@ void _Thread_Change_priority(
|
|||||||
* We altered the set of thread priorities. So let's figure out
|
* We altered the set of thread priorities. So let's figure out
|
||||||
* who is the heir and if we need to switch to them.
|
* 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() &&
|
if ( !_Thread_Is_executing_also_the_heir() &&
|
||||||
_Thread_Executing->is_preemptible )
|
_Thread_Executing->is_preemptible )
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -66,31 +67,7 @@ void _Thread_Clear_state(
|
|||||||
the_thread->current_state = _States_Clear( state, current_state );
|
the_thread->current_state = _States_Clear( state, current_state );
|
||||||
|
|
||||||
if ( _States_Is_ready( current_state ) ) {
|
if ( _States_Is_ready( current_state ) ) {
|
||||||
|
_Scheduler_Unblock( &_Scheduler, the_thread);
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -85,6 +86,11 @@ void _Thread_Close(
|
|||||||
(void) _Watchdog_Remove( &the_thread->Timer );
|
(void) _Watchdog_Remove( &the_thread->Timer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the per-thread scheduling information.
|
||||||
|
*/
|
||||||
|
_Scheduler_Thread_scheduler_free( &_Scheduler, the_thread );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The thread might have been FP. So deal with that.
|
* The thread might have been FP. So deal with that.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -60,6 +61,7 @@ bool _Thread_Initialize(
|
|||||||
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
|
||||||
void *fp_area;
|
void *fp_area;
|
||||||
#endif
|
#endif
|
||||||
|
void *sched = NULL;
|
||||||
void *extensions_area;
|
void *extensions_area;
|
||||||
bool extension_status;
|
bool extension_status;
|
||||||
int i;
|
int i;
|
||||||
@@ -192,6 +194,9 @@ bool _Thread_Initialize(
|
|||||||
the_thread->resource_count = 0;
|
the_thread->resource_count = 0;
|
||||||
the_thread->real_priority = priority;
|
the_thread->real_priority = priority;
|
||||||
the_thread->Start.initial_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 );
|
_Thread_Set_priority( the_thread, priority );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -235,6 +240,9 @@ failed:
|
|||||||
(void) _Workspace_Free( fp_area );
|
(void) _Workspace_Free( fp_area );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ( sched )
|
||||||
|
(void) _Workspace_Free( sched );
|
||||||
|
|
||||||
_Thread_Stack_Free( the_thread );
|
_Thread_Stack_Free( the_thread );
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -55,24 +56,12 @@ void _Thread_Ready(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
ISR_Level level;
|
ISR_Level level;
|
||||||
Thread_Control *heir;
|
|
||||||
|
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
|
|
||||||
the_thread->current_state = STATES_READY;
|
the_thread->current_state = STATES_READY;
|
||||||
|
|
||||||
_Priority_bit_map_Add( &the_thread->Priority_map );
|
_Scheduler_Unblock( &_Scheduler, the_thread );
|
||||||
|
|
||||||
_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;
|
|
||||||
|
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -68,19 +69,7 @@ void _Thread_Resume(
|
|||||||
the_thread->current_state = _States_Clear(STATES_SUSPENDED, current_state);
|
the_thread->current_state = _States_Clear(STATES_SUSPENDED, current_state);
|
||||||
|
|
||||||
if ( _States_Is_ready( current_state ) ) {
|
if ( _States_Is_ready( current_state ) ) {
|
||||||
|
_Scheduler_Unblock( &_Scheduler, the_thread );
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -50,10 +51,6 @@ void _Thread_Set_priority(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
the_thread->current_priority = new_priority;
|
the_thread->current_priority = new_priority;
|
||||||
the_thread->ready = &_Thread_Ready_chain[ new_priority ];
|
|
||||||
|
|
||||||
_Priority_bit_map_Initialize_information(
|
_Scheduler_Thread_scheduler_update(&_Scheduler, the_thread);
|
||||||
&the_thread->Priority_map,
|
|
||||||
new_priority
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -54,9 +55,7 @@ void _Thread_Set_state(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
ISR_Level level;
|
ISR_Level level;
|
||||||
Chain_Control *ready;
|
|
||||||
|
|
||||||
ready = the_thread->ready;
|
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
if ( !_States_Is_ready( the_thread->current_state ) ) {
|
if ( !_States_Is_ready( the_thread->current_state ) ) {
|
||||||
the_thread->current_state =
|
the_thread->current_state =
|
||||||
@@ -67,21 +66,7 @@ void _Thread_Set_state(
|
|||||||
|
|
||||||
the_thread->current_state = state;
|
the_thread->current_state = state;
|
||||||
|
|
||||||
if ( _Chain_Has_only_one_node( ready ) ) {
|
_Scheduler_Block( &_Scheduler, the_thread);
|
||||||
|
|
||||||
_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;
|
|
||||||
|
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
|
#include <rtems/score/schedulerpriority.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -54,22 +56,15 @@ void _Thread_Set_transient(
|
|||||||
{
|
{
|
||||||
ISR_Level level;
|
ISR_Level level;
|
||||||
uint32_t old_state;
|
uint32_t old_state;
|
||||||
Chain_Control *ready;
|
|
||||||
|
|
||||||
ready = the_thread->ready;
|
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
|
|
||||||
old_state = the_thread->current_state;
|
old_state = the_thread->current_state;
|
||||||
the_thread->current_state = _States_Set( STATES_TRANSIENT, old_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 ( _States_Is_ready( old_state ) ) {
|
||||||
if ( _Chain_Has_only_one_node( ready ) ) {
|
_Scheduler_priority_Ready_queue_extract( the_thread);
|
||||||
|
|
||||||
_Chain_Initialize_empty( ready );
|
|
||||||
_Priority_bit_map_Remove( &the_thread->Priority_map );
|
|
||||||
|
|
||||||
} else
|
|
||||||
_Chain_Extract_unprotected( &the_thread->Object.Node );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -52,9 +53,7 @@ void _Thread_Suspend(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
ISR_Level level;
|
ISR_Level level;
|
||||||
Chain_Control *ready;
|
|
||||||
|
|
||||||
ready = the_thread->ready;
|
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
if ( !_States_Is_ready( the_thread->current_state ) ) {
|
if ( !_States_Is_ready( the_thread->current_state ) ) {
|
||||||
the_thread->current_state =
|
the_thread->current_state =
|
||||||
@@ -65,21 +64,7 @@ void _Thread_Suspend(
|
|||||||
|
|
||||||
the_thread->current_state = STATES_SUSPENDED;
|
the_thread->current_state = STATES_SUSPENDED;
|
||||||
|
|
||||||
if ( _Chain_Has_only_one_node( ready ) ) {
|
_Scheduler_Block(&_Scheduler, the_thread);
|
||||||
|
|
||||||
_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;
|
|
||||||
|
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
|
#include <rtems/score/scheduler.h>
|
||||||
#include <rtems/score/states.h>
|
#include <rtems/score/states.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
@@ -89,7 +90,7 @@ void _Thread_Tickle_timeslice( void )
|
|||||||
* currently executing thread is placed at the rear of the
|
* currently executing thread is placed at the rear of the
|
||||||
* FIFO for this priority and a new heir is selected.
|
* FIFO for this priority and a new heir is selected.
|
||||||
*/
|
*/
|
||||||
_Thread_Yield_processor();
|
_Scheduler_Yield( );
|
||||||
executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
|
executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user