diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-02-18 15:12:44 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-02-18 15:12:44 +0000 |
commit | 108c4b085ccf88e9644fccbf5cec1b79c39e67e4 (patch) | |
tree | df0df1d699d02955750d1691e75ef26fe0c8e1b1 /cpukit/score/inline/rtems | |
parent | 2011-02-17 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-108c4b085ccf88e9644fccbf5cec1b79c39e67e4.tar.bz2 |
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.
Diffstat (limited to 'cpukit/score/inline/rtems')
-rw-r--r-- | cpukit/score/inline/rtems/score/scheduler.inl | 51 | ||||
-rw-r--r-- | cpukit/score/inline/rtems/score/schedulerpriority.inl | 133 |
2 files changed, 90 insertions, 94 deletions
diff --git a/cpukit/score/inline/rtems/score/scheduler.inl b/cpukit/score/inline/rtems/score/scheduler.inl index 813365fcf9..4a6c74cbf8 100644 --- a/cpukit/score/inline/rtems/score/scheduler.inl +++ b/cpukit/score/inline/rtems/score/scheduler.inl @@ -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 ); } /**@}*/ diff --git a/cpukit/score/inline/rtems/score/schedulerpriority.inl b/cpukit/score/inline/rtems/score/schedulerpriority.inl index 4b6bace9c6..680606ce53 100644 --- a/cpukit/score/inline/rtems/score/schedulerpriority.inl +++ b/cpukit/score/inline/rtems/score/schedulerpriority.inl @@ -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 |