forked from Imagelibrary/rtems
2011-02-18 Joel Sherrill <joel.sherrill@oarcorp.com>
* sapi/include/confdefs.h, score/Makefile.am, score/include/rtems/score/scheduler.h, score/include/rtems/score/schedulerpriority.h, score/include/rtems/score/thread.h, score/inline/rtems/score/scheduler.inl, score/inline/rtems/score/schedulerpriority.inl, score/src/scheduler.c, score/src/schedulerpriority.c, score/src/schedulerpriorityblock.c, score/src/schedulerpriorityschedule.c, score/src/schedulerpriorityunblock.c, score/src/schedulerpriorityyield.c, score/src/threadchangepriority.c, score/src/threadclose.c, score/src/threadinitialize.c, score/src/threadsetpriority.c, score/src/threadsettransient.c: Significant clean up on Scheduler Plugin Interface. Names were shortened. Missing operations added. Many scheduler files had unneeded includes removed. Made pointer to scheduler information in Thread_Control and Scheduler_Control a void * pointer because the thread and scheduler wrapper should be unaware of scheduler types AND this is broken for user provided schedulers. * score/src/schedulerpriorityallocate.c, score/src/schedulerpriorityenqueue.c, score/src/schedulerpriorityenqueuefirst.c, score/src/schedulerpriorityextract.c, score/src/schedulerpriorityfree.c, score/src/schedulerpriorityupdate.c: New files. * score/src/schedulerprioritythreadschedulerallocate.c, score/src/schedulerprioritythreadschedulerfree.c, score/src/schedulerprioritythreadschedulerupdate.c: Removed.
This commit is contained in:
@@ -1,3 +1,34 @@
|
||||
2011-02-18 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* sapi/include/confdefs.h, score/Makefile.am,
|
||||
score/include/rtems/score/scheduler.h,
|
||||
score/include/rtems/score/schedulerpriority.h,
|
||||
score/include/rtems/score/thread.h,
|
||||
score/inline/rtems/score/scheduler.inl,
|
||||
score/inline/rtems/score/schedulerpriority.inl,
|
||||
score/src/scheduler.c, score/src/schedulerpriority.c,
|
||||
score/src/schedulerpriorityblock.c,
|
||||
score/src/schedulerpriorityschedule.c,
|
||||
score/src/schedulerpriorityunblock.c,
|
||||
score/src/schedulerpriorityyield.c, score/src/threadchangepriority.c,
|
||||
score/src/threadclose.c, score/src/threadinitialize.c,
|
||||
score/src/threadsetpriority.c, score/src/threadsettransient.c:
|
||||
Significant clean up on Scheduler Plugin Interface. Names were
|
||||
shortened. Missing operations added. Many scheduler files had
|
||||
unneeded includes removed. Made pointer to scheduler information in
|
||||
Thread_Control and Scheduler_Control a void * pointer because the
|
||||
thread and scheduler wrapper should be unaware of scheduler types AND
|
||||
this is broken for user provided schedulers.
|
||||
* score/src/schedulerpriorityallocate.c,
|
||||
score/src/schedulerpriorityenqueue.c,
|
||||
score/src/schedulerpriorityenqueuefirst.c,
|
||||
score/src/schedulerpriorityextract.c,
|
||||
score/src/schedulerpriorityfree.c,
|
||||
score/src/schedulerpriorityupdate.c: New files.
|
||||
* score/src/schedulerprioritythreadschedulerallocate.c,
|
||||
score/src/schedulerprioritythreadschedulerfree.c,
|
||||
score/src/schedulerprioritythreadschedulerupdate.c: Removed.
|
||||
|
||||
2011-02-17 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* sapi/include/confdefs.h, sapi/include/rtems/config.h,
|
||||
|
||||
@@ -603,8 +603,8 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
||||
*/
|
||||
#ifdef CONFIGURE_INIT
|
||||
Scheduler_Control _Scheduler = {
|
||||
.Ready_queues.priority = NULL,
|
||||
.Operations = SCHEDULER_ENTRY_POINTS
|
||||
.information = NULL,
|
||||
.Operations = SCHEDULER_ENTRY_POINTS
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -144,13 +144,16 @@ 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
|
||||
src/schedulerpriorityallocate.c \
|
||||
src/schedulerpriorityblock.c \
|
||||
src/schedulerpriorityenqueue.c \
|
||||
src/schedulerpriorityenqueuefirst.c \
|
||||
src/schedulerpriorityextract.c \
|
||||
src/schedulerpriorityfree.c \
|
||||
src/schedulerpriorityschedule.c \
|
||||
src/schedulerpriorityunblock.c \
|
||||
src/schedulerpriorityupdate.c \
|
||||
src/schedulerpriorityyield.c
|
||||
|
||||
## PROTECTED_HEAP_C_FILES
|
||||
libscore_a_SOURCES += src/pheapallocate.c \
|
||||
|
||||
@@ -36,35 +36,6 @@ extern "C" {
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
typedef struct Scheduler_Control_struct Scheduler_Control;
|
||||
|
||||
/*
|
||||
* This type defines the scheduler initialization table entry, 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_entry;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -86,37 +57,39 @@ typedef struct {
|
||||
void ( *unblock )(Thread_Control *);
|
||||
|
||||
/** allocates the scheduler field of the given thread */
|
||||
void * ( *scheduler_allocate )(Thread_Control *);
|
||||
void * ( *allocate )(Thread_Control *);
|
||||
|
||||
/** frees the scheduler field of the given thread */
|
||||
void ( *scheduler_free )(Thread_Control *);
|
||||
void ( *free )(Thread_Control *);
|
||||
|
||||
/** updates the scheduler field of the given thread -- primarily used
|
||||
* when changing the thread's priority. */
|
||||
void ( *scheduler_update )(Thread_Control *);
|
||||
void ( *update )(Thread_Control *);
|
||||
|
||||
/** enqueue a thread as the last of its priority group */
|
||||
void ( *enqueue )(Thread_Control *);
|
||||
|
||||
/** enqueue a thread as the first of its priority group */
|
||||
void ( *enqueue_first )(Thread_Control *);
|
||||
|
||||
/** extract a thread from the ready set */
|
||||
void ( *extract )(Thread_Control *);
|
||||
} Scheduler_Operations;
|
||||
|
||||
/**
|
||||
* This is the structure used to manage the scheduler.
|
||||
*/
|
||||
struct Scheduler_Control_struct {
|
||||
typedef 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
|
||||
* This points 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;
|
||||
void *information;
|
||||
|
||||
/** The jump table for scheduler-specific functions */
|
||||
Scheduler_Operations Operations;
|
||||
};
|
||||
Scheduler_Operations Operations;
|
||||
} Scheduler_Control;
|
||||
|
||||
/**
|
||||
* The _Scheduler holds the structures used to manage the
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
#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>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -40,16 +38,30 @@ extern "C" {
|
||||
*/
|
||||
#define SCHEDULER_PRIORITY_ENTRY_POINTS \
|
||||
{ \
|
||||
.initialize = _Scheduler_priority_Initialize, \
|
||||
.schedule = _Scheduler_priority_Schedule, \
|
||||
.yield = _Scheduler_priority_Yield, \
|
||||
.block = _Scheduler_priority_Block, \
|
||||
.unblock = _Scheduler_priority_Unblock, \
|
||||
.scheduler_allocate = _Scheduler_priority_Thread_scheduler_allocate, \
|
||||
.scheduler_free = _Scheduler_priority_Thread_scheduler_free, \
|
||||
.scheduler_update = _Scheduler_priority_Thread_scheduler_update \
|
||||
.initialize = _Scheduler_priority_Initialize, \
|
||||
.schedule = _Scheduler_priority_Schedule, \
|
||||
.yield = _Scheduler_priority_Yield, \
|
||||
.block = _Scheduler_priority_Block, \
|
||||
.unblock = _Scheduler_priority_Unblock, \
|
||||
.allocate = _Scheduler_priority_Allocate, \
|
||||
.free = _Scheduler_priority_Free, \
|
||||
.update = _Scheduler_priority_Update, \
|
||||
.enqueue = _Scheduler_priority_Enqueue, \
|
||||
.enqueue_first = _Scheduler_priority_Enqueue_first, \
|
||||
.extract = _Scheduler_priority_Extract \
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* This routine initializes the priority scheduler.
|
||||
*/
|
||||
@@ -60,6 +72,8 @@ void _Scheduler_priority_Initialize(void);
|
||||
* that is, removes it from the ready queue. It performs
|
||||
* any necessary scheduling operations including the selection of
|
||||
* a new heir thread.
|
||||
*
|
||||
* @param[in] the_thread is the thread to be blocked
|
||||
*/
|
||||
void _Scheduler_priority_Block(
|
||||
Thread_Control *the_thread
|
||||
@@ -72,24 +86,33 @@ void _Scheduler_priority_Block(
|
||||
void _Scheduler_priority_Schedule(void);
|
||||
|
||||
/**
|
||||
* This routine allocates @a the_thread->scheduler.
|
||||
* This routine allocates @a the_thread->scheduler.
|
||||
*
|
||||
* @param[in] the_thread is the thread the scheduler is allocating
|
||||
* management memory for
|
||||
*/
|
||||
void * _Scheduler_priority_Thread_scheduler_allocate(
|
||||
void * _Scheduler_priority_Allocate(
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine frees @a the_thread->scheduler.
|
||||
* This routine frees @a the_thread->scheduler.
|
||||
*
|
||||
* @param[in] the_thread is the thread whose scheduler specific information
|
||||
* will be deallocated.
|
||||
*/
|
||||
void _Scheduler_priority_Thread_scheduler_free(
|
||||
void _Scheduler_priority_Free(
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine updates @a the_thread->scheduler based on @a the_scheduler
|
||||
* structures and thread state
|
||||
* This routine updates @a the_thread->scheduler based on @a the_scheduler
|
||||
* structures and thread state.
|
||||
*
|
||||
* @param[in] the_thread will have its scheduler specific information
|
||||
* structure updated.
|
||||
*/
|
||||
void _Scheduler_priority_Thread_scheduler_update(
|
||||
void _Scheduler_priority_Update(
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
@@ -97,6 +120,8 @@ void _Scheduler_priority_Thread_scheduler_update(
|
||||
* 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.
|
||||
*
|
||||
* @param[in] the_thread will be unblocked
|
||||
*/
|
||||
void _Scheduler_priority_Unblock(
|
||||
Thread_Control *the_thread
|
||||
@@ -115,6 +140,36 @@ void _Scheduler_priority_Unblock(
|
||||
*/
|
||||
void _Scheduler_priority_Yield( void );
|
||||
|
||||
/**
|
||||
* This routine puts @a the_thread on to the priority-based ready queue.
|
||||
*
|
||||
* @param[in] the_thread will be enqueued at the TAIL of its priority.
|
||||
*/
|
||||
void _Scheduler_priority_Enqueue(
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param[in] the_thread will be enqueued at the HEAD of its priority.
|
||||
*/
|
||||
void _Scheduler_priority_Enqueue_first(
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine removes a specific thread from the scheduler's set
|
||||
* of ready threads.
|
||||
*
|
||||
* @param[in] the_thread will be extracted from the ready set.
|
||||
*/
|
||||
void _Scheduler_priority_Extract(
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
#include <rtems/score/schedulerpriority.inl>
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* COPYRIGHT (c) 1989-2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -390,10 +390,10 @@ struct Thread_Control_struct {
|
||||
* since it was created.
|
||||
*/
|
||||
Thread_CPU_usage_t cpu_time_used;
|
||||
/** This union holds per-thread data for the scheduler and ready queue. */
|
||||
union {
|
||||
Scheduler_priority_Per_thread *priority;
|
||||
} scheduler;
|
||||
|
||||
/** This pointer holds per-thread data for the scheduler and ready queue. */
|
||||
void *scheduler_info;
|
||||
|
||||
/** This field contains information about the starting state of
|
||||
* this thread.
|
||||
*/
|
||||
|
||||
@@ -93,37 +93,70 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
|
||||
_Scheduler.Operations.unblock( the_thread );
|
||||
}
|
||||
|
||||
/** @brief _Scheduler_Thread_scheduler_allocate
|
||||
/** @brief _Scheduler_Allocate
|
||||
*
|
||||
* This routine allocates @a the_thread->scheduler
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void* _Scheduler_Thread_scheduler_allocate(
|
||||
RTEMS_INLINE_ROUTINE void* _Scheduler_Allocate(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
return _Scheduler.Operations.scheduler_allocate( the_thread );
|
||||
return _Scheduler.Operations.allocate( the_thread );
|
||||
}
|
||||
|
||||
/** @brief _Scheduler_Thread_scheduler_free
|
||||
/** @brief _Scheduler_Free
|
||||
*
|
||||
* This routine frees @a the_thread->scheduler
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Thread_scheduler_free(
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Free(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
return _Scheduler.Operations.scheduler_free( the_thread );
|
||||
return _Scheduler.Operations.free( the_thread );
|
||||
}
|
||||
|
||||
/** @brief _Scheduler_Thread_scheduler_update
|
||||
/** @brief _Scheduler_Update
|
||||
*
|
||||
* This routine updates @a the_thread->scheduler
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Thread_scheduler_update(
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Update(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler.Operations.scheduler_update( the_thread );
|
||||
_Scheduler.Operations.update( the_thread );
|
||||
}
|
||||
|
||||
/** @brief _Scheduler_Enqueue
|
||||
*
|
||||
* This routine enqueue @a the_thread->scheduler
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler.Operations.enqueue( the_thread );
|
||||
}
|
||||
|
||||
/** @brief _Scheduler_Enqueue_first
|
||||
*
|
||||
* This routine enqueue_first @a the_thread->scheduler
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue_first(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler.Operations.enqueue_first( the_thread );
|
||||
}
|
||||
|
||||
/** @brief _Scheduler_Extract
|
||||
*
|
||||
* This routine extract @a the_thread->scheduler
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Extract(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler.Operations.extract( the_thread );
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_INL
|
||||
#define _RTEMS_SCORE_SCHEDULERPRIORITY_INL
|
||||
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
/**
|
||||
* @addtogroup ScoreScheduler
|
||||
* @{
|
||||
@@ -34,17 +36,18 @@
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(void)
|
||||
{
|
||||
size_t index;
|
||||
size_t index;
|
||||
Chain_Control *ready_queues;
|
||||
|
||||
/* allocate ready queue structures */
|
||||
_Scheduler.Ready_queues.priority = (Chain_Control *)
|
||||
_Workspace_Allocate_or_fatal_error(
|
||||
((size_t) PRIORITY_MAXIMUM + 1) * sizeof(Chain_Control)
|
||||
);
|
||||
_Scheduler.information = _Workspace_Allocate_or_fatal_error(
|
||||
((size_t) PRIORITY_MAXIMUM + 1) * sizeof(Chain_Control)
|
||||
);
|
||||
|
||||
/* initialize ready queue structures */
|
||||
ready_queues = (Chain_Control *) _Scheduler.information;
|
||||
for( index=0; index <= PRIORITY_MAXIMUM; index++)
|
||||
_Chain_Initialize_empty( &_Scheduler.Ready_queues.priority[index] );
|
||||
_Chain_Initialize_empty( &ready_queues[index] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,10 +61,15 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Priority_bit_map_Add( &the_thread->scheduler.priority->Priority_map );
|
||||
Scheduler_priority_Per_thread *sched_info;
|
||||
Chain_Control *ready;
|
||||
|
||||
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
|
||||
ready = sched_info->ready_chain;
|
||||
|
||||
_Priority_bit_map_Add( &sched_info->Priority_map );
|
||||
|
||||
_Chain_Append_unprotected( the_thread->scheduler.priority->ready_chain,
|
||||
&the_thread->Object.Node );
|
||||
_Chain_Append_unprotected( ready, &the_thread->Object.Node );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,10 +85,18 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Priority_bit_map_Add( &the_thread->scheduler.priority->Priority_map );
|
||||
Scheduler_priority_Per_thread *sched_info;
|
||||
Chain_Control *ready;
|
||||
|
||||
_Chain_Prepend_unprotected( the_thread->scheduler.priority->ready_chain,
|
||||
&the_thread->Object.Node );
|
||||
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
|
||||
ready = sched_info->ready_chain;
|
||||
|
||||
_Priority_bit_map_Add( &sched_info->Priority_map );
|
||||
|
||||
_Chain_Prepend_unprotected(
|
||||
sched_info->ready_chain,
|
||||
&the_thread->Object.Node
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,13 +111,18 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
Chain_Control *ready = the_thread->scheduler.priority->ready_chain;
|
||||
Scheduler_priority_Per_thread *sched_info;
|
||||
Chain_Control *ready;
|
||||
|
||||
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
|
||||
ready = sched_info->ready_chain;
|
||||
|
||||
if ( _Chain_Has_only_one_node( ready ) ) {
|
||||
_Chain_Initialize_empty( ready );
|
||||
_Priority_bit_map_Remove( &the_thread->scheduler.priority->Priority_map );
|
||||
} else
|
||||
_Priority_bit_map_Remove( &sched_info->Priority_map );
|
||||
} else {
|
||||
_Chain_Extract_unprotected( &the_thread->Object.Node );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,13 +158,19 @@ 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
|
||||
) ) {
|
||||
Scheduler_priority_Per_thread *sched_info;
|
||||
Chain_Control *ready;
|
||||
|
||||
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
|
||||
ready = sched_info->ready_chain;
|
||||
|
||||
if ( !_Chain_Has_only_one_node( sched_info->ready_chain ) ) {
|
||||
_Chain_Extract_unprotected( &the_thread->Object.Node );
|
||||
|
||||
_Chain_Append_unprotected( the_thread->scheduler.priority->ready_chain,
|
||||
&the_thread->Object.Node );
|
||||
_Chain_Append_unprotected(
|
||||
sched_info->ready_chain,
|
||||
&the_thread->Object.Node
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,74 +185,10 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue(
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(void)
|
||||
{
|
||||
_Thread_Heir = _Scheduler_priority_Ready_queue_first(
|
||||
_Scheduler.Ready_queues.priority
|
||||
(Chain_Control *) _Scheduler.information
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _Scheduler_priority_Block_body
|
||||
*
|
||||
* This kernel routine removes the_thread from scheduling decisions based
|
||||
* on simple queue extraction.
|
||||
*
|
||||
* @param[in] the_thread - pointer to thread
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Block_body(
|
||||
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();
|
||||
|
||||
if ( _Thread_Is_executing( the_thread ) )
|
||||
_Thread_Dispatch_necessary = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief _Scheduler_priority_Unblock_body
|
||||
*
|
||||
* This kernel routine readies the requested thread according to the queuing
|
||||
* discipline. A new heir thread may be selected.
|
||||
*
|
||||
* @param[in] the_thread - pointer to thread
|
||||
*
|
||||
* @note This routine uses the "blocking" heir selection mechanism.
|
||||
* This ensures the correct heir after a thread restart.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Unblock_body (
|
||||
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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Scheduler Handler
|
||||
* Scheduler Handler / Initialization
|
||||
*
|
||||
* Copyright (C) 2010 Gedare Bloom.
|
||||
* Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
|
||||
@@ -17,24 +17,8 @@
|
||||
|
||||
#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
|
||||
* initialize function registered in the Configuration Scheduler Table.
|
||||
*
|
||||
* Input parameters: NONE
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*/
|
||||
void _Scheduler_Handler_initialization(void)
|
||||
{
|
||||
(*_Scheduler.Operations.initialize)();
|
||||
|
||||
@@ -17,13 +17,9 @@
|
||||
|
||||
#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/prioritybitmap.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;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* Scheduler Handler
|
||||
* Scheduler Priority Handler / Allocate
|
||||
*
|
||||
* Copyright (C) 2010 Gedare Bloom.
|
||||
* Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@@ -18,18 +19,17 @@
|
||||
#include <rtems/config.h>
|
||||
#include <rtems/score/scheduler.h>
|
||||
#include <rtems/score/schedulerpriority.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
void *_Scheduler_priority_Thread_scheduler_allocate (
|
||||
void* _Scheduler_priority_Allocate (
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
void *sched;
|
||||
void *sched;
|
||||
|
||||
sched = _Workspace_Allocate( sizeof(Scheduler_priority_Per_thread) );
|
||||
|
||||
the_thread->scheduler.priority = (Scheduler_priority_Per_thread *) sched;
|
||||
the_thread->scheduler_info = (Scheduler_priority_Per_thread*) sched;
|
||||
|
||||
return sched;
|
||||
}
|
||||
@@ -29,5 +29,14 @@ void _Scheduler_priority_Block(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler_priority_Block_body(the_thread);
|
||||
_Scheduler_priority_Ready_queue_extract( the_thread );
|
||||
|
||||
/* TODO: flash critical section? */
|
||||
|
||||
if ( _Thread_Is_heir( the_thread ) )
|
||||
_Scheduler_priority_Schedule_body();
|
||||
|
||||
if ( _Thread_Is_executing( the_thread ) )
|
||||
_Thread_Dispatch_necessary = true;
|
||||
|
||||
}
|
||||
|
||||
26
cpukit/score/src/schedulerpriorityenqueue.c
Normal file
26
cpukit/score/src/schedulerpriorityenqueue.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* 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/scheduler.h>
|
||||
#include <rtems/score/schedulerpriority.h>
|
||||
|
||||
void _Scheduler_priority_Enqueue(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler_priority_Ready_queue_enqueue( the_thread );
|
||||
}
|
||||
27
cpukit/score/src/schedulerpriorityenqueuefirst.c
Normal file
27
cpukit/score/src/schedulerpriorityenqueuefirst.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* 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/schedulerpriority.h>
|
||||
|
||||
void _Scheduler_priority_Enqueue_first(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler_priority_Ready_queue_enqueue_first( the_thread );
|
||||
}
|
||||
|
||||
26
cpukit/score/src/schedulerpriorityextract.c
Normal file
26
cpukit/score/src/schedulerpriorityextract.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* 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/schedulerpriority.h>
|
||||
|
||||
void _Scheduler_priority_Extract(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler_priority_Ready_queue_extract( the_thread );
|
||||
}
|
||||
@@ -17,18 +17,13 @@
|
||||
|
||||
#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>
|
||||
|
||||
void _Scheduler_priority_Thread_scheduler_free (
|
||||
void _Scheduler_priority_Free (
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Workspace_Free( the_thread->scheduler.priority );
|
||||
_Workspace_Free( the_thread->scheduler_info );
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Scheduler Handler
|
||||
* Scheduler Handler / Scheduler
|
||||
*
|
||||
* Copyright (C) 2010 Gedare Bloom.
|
||||
* Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
|
||||
|
||||
@@ -23,5 +23,26 @@ void _Scheduler_priority_Unblock (
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Scheduler_priority_Unblock_body(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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,18 +23,21 @@
|
||||
#include <rtems/score/schedulerpriority.h>
|
||||
#include <rtems/score/thread.h>
|
||||
|
||||
void _Scheduler_priority_Thread_scheduler_update(
|
||||
void _Scheduler_priority_Update(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
Chain_Control *rq = _Scheduler.Ready_queues.priority;
|
||||
Scheduler_priority_Per_thread *sched_info;
|
||||
Chain_Control *rq;
|
||||
|
||||
the_thread->scheduler.priority->ready_chain = &rq[
|
||||
the_thread->current_priority
|
||||
];
|
||||
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
|
||||
rq = (Chain_Control *) _Scheduler.information;
|
||||
|
||||
|
||||
sched_info->ready_chain = &rq[ the_thread->current_priority ];
|
||||
|
||||
_Priority_bit_map_Initialize_information(
|
||||
&the_thread->scheduler.priority->Priority_map,
|
||||
the_thread->current_priority
|
||||
&sched_info->Priority_map,
|
||||
the_thread->current_priority
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* Scheduler Handler
|
||||
* Scheduler Priority Handler / Yield
|
||||
*
|
||||
* Copyright (C) 2010 Gedare Bloom.
|
||||
* Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@@ -15,19 +16,10 @@
|
||||
#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/schedulerpriority.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/threadq.h>
|
||||
#include <rtems/score/userext.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
/*
|
||||
* INTERRUPT LATENCY:
|
||||
@@ -37,12 +29,14 @@
|
||||
|
||||
void _Scheduler_priority_Yield(void)
|
||||
{
|
||||
ISR_Level level;
|
||||
Thread_Control *executing;
|
||||
Chain_Control *ready;
|
||||
Scheduler_priority_Per_thread *sched_info;
|
||||
ISR_Level level;
|
||||
Thread_Control *executing;
|
||||
Chain_Control *ready;
|
||||
|
||||
executing = _Thread_Executing;
|
||||
ready = executing->scheduler.priority->ready_chain;
|
||||
executing = _Thread_Executing;
|
||||
sched_info = (Scheduler_priority_Per_thread *) executing->scheduler_info;
|
||||
ready = sched_info->ready_chain;
|
||||
_ISR_Disable( level );
|
||||
if ( !_Chain_Has_only_one_node( ready ) ) {
|
||||
_Chain_Extract_unprotected( &executing->Object.Node );
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* Thread Handler
|
||||
* Thread Handler / Change Priority
|
||||
*
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* COPYRIGHT (c) 1989-2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -32,21 +31,6 @@ void _Thread_Change_priority(
|
||||
ISR_Level level;
|
||||
States_Control state, original_state;
|
||||
|
||||
/*
|
||||
* If this is a case where prepending the task to its priority is
|
||||
* potentially desired, then we need to consider whether to do it.
|
||||
* This usually occurs when a task lowers its priority implcitly as
|
||||
* the result of losing inherited priority. Normal explicit priority
|
||||
* change calls (e.g. rtems_task_set_priority) should always do an
|
||||
* append not a prepend.
|
||||
*/
|
||||
/*
|
||||
if ( prepend_it &&
|
||||
_Thread_Is_executing( the_thread ) &&
|
||||
new_priority >= the_thread->current_priority )
|
||||
prepend_it = true;
|
||||
*/
|
||||
|
||||
/*
|
||||
* Save original state
|
||||
*/
|
||||
@@ -91,16 +75,13 @@ void _Thread_Change_priority(
|
||||
* 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 );
|
||||
|
||||
if ( prepend_it )
|
||||
_Scheduler_priority_Ready_queue_enqueue_first( the_thread );
|
||||
_Scheduler_Enqueue_first( the_thread );
|
||||
else
|
||||
_Scheduler_priority_Ready_queue_enqueue( the_thread );
|
||||
_Scheduler_Enqueue( the_thread );
|
||||
}
|
||||
|
||||
_ISR_Flash( level );
|
||||
|
||||
@@ -35,7 +35,6 @@ void _Thread_Close(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
|
||||
/*
|
||||
* Now we are in a dispatching critical section again and we
|
||||
* can take the thread OUT of the published set. It is invalid
|
||||
@@ -78,7 +77,7 @@ void _Thread_Close(
|
||||
/*
|
||||
* Free the per-thread scheduling information.
|
||||
*/
|
||||
_Scheduler_Thread_scheduler_free( the_thread );
|
||||
_Scheduler_Free( the_thread );
|
||||
|
||||
/*
|
||||
* The thread might have been FP. So deal with that.
|
||||
|
||||
@@ -193,7 +193,7 @@ bool _Thread_Initialize(
|
||||
the_thread->resource_count = 0;
|
||||
the_thread->real_priority = priority;
|
||||
the_thread->Start.initial_priority = priority;
|
||||
sched =_Scheduler_Thread_scheduler_allocate( the_thread );
|
||||
sched =_Scheduler_Allocate( the_thread );
|
||||
if ( !sched )
|
||||
goto failed;
|
||||
_Thread_Set_priority( the_thread, priority );
|
||||
|
||||
@@ -16,19 +16,8 @@
|
||||
#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>
|
||||
|
||||
void _Thread_Set_priority(
|
||||
Thread_Control *the_thread,
|
||||
@@ -37,5 +26,5 @@ void _Thread_Set_priority(
|
||||
{
|
||||
the_thread->current_priority = new_priority;
|
||||
|
||||
_Scheduler_Thread_scheduler_update( the_thread );
|
||||
_Scheduler_Update( the_thread );
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* Thread Handler
|
||||
* Thread Handler / Thread Set Transient
|
||||
*
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* COPYRIGHT (c) 1989-2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -32,24 +31,10 @@
|
||||
#include <rtems/score/userext.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _Thread_Set_transient
|
||||
*
|
||||
* This kernel routine places the requested thread in the transient state
|
||||
* which will remove it from the ready queue, if necessary. No
|
||||
* rescheduling is necessary because it is assumed that the transient
|
||||
* state will be cleared before dispatching is enabled.
|
||||
*
|
||||
* Input parameters:
|
||||
* the_thread - pointer to thread control block
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
/*
|
||||
* INTERRUPT LATENCY:
|
||||
* only case
|
||||
*/
|
||||
|
||||
void _Thread_Set_transient(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
@@ -62,9 +47,8 @@ void _Thread_Set_transient(
|
||||
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 ) ) {
|
||||
_Scheduler_priority_Ready_queue_extract( the_thread);
|
||||
_Scheduler_Extract( the_thread );
|
||||
}
|
||||
|
||||
_ISR_Enable( level );
|
||||
|
||||
Reference in New Issue
Block a user