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/src | |
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/src')
17 files changed, 153 insertions, 119 deletions
diff --git a/cpukit/score/src/scheduler.c b/cpukit/score/src/scheduler.c index 60d8bc7fe7..71938a728c 100644 --- a/cpukit/score/src/scheduler.c +++ b/cpukit/score/src/scheduler.c @@ -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)(); diff --git a/cpukit/score/src/schedulerpriority.c b/cpukit/score/src/schedulerpriority.c index 93586a8a7b..377b5f7a9c 100644 --- a/cpukit/score/src/schedulerpriority.c +++ b/cpukit/score/src/schedulerpriority.c @@ -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; diff --git a/cpukit/score/src/schedulerprioritythreadschedulerallocate.c b/cpukit/score/src/schedulerpriorityallocate.c index 3cce3e866e..9df1e9ee5e 100644 --- a/cpukit/score/src/schedulerprioritythreadschedulerallocate.c +++ b/cpukit/score/src/schedulerpriorityallocate.c @@ -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; } diff --git a/cpukit/score/src/schedulerpriorityblock.c b/cpukit/score/src/schedulerpriorityblock.c index 3babe6e0cc..702ea48034 100644 --- a/cpukit/score/src/schedulerpriorityblock.c +++ b/cpukit/score/src/schedulerpriorityblock.c @@ -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; + } diff --git a/cpukit/score/src/schedulerpriorityenqueue.c b/cpukit/score/src/schedulerpriorityenqueue.c new file mode 100644 index 0000000000..82e192ac8c --- /dev/null +++ b/cpukit/score/src/schedulerpriorityenqueue.c @@ -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 ); +} diff --git a/cpukit/score/src/schedulerpriorityenqueuefirst.c b/cpukit/score/src/schedulerpriorityenqueuefirst.c new file mode 100644 index 0000000000..56573b7bb8 --- /dev/null +++ b/cpukit/score/src/schedulerpriorityenqueuefirst.c @@ -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 ); +} + diff --git a/cpukit/score/src/schedulerpriorityextract.c b/cpukit/score/src/schedulerpriorityextract.c new file mode 100644 index 0000000000..2d0206caef --- /dev/null +++ b/cpukit/score/src/schedulerpriorityextract.c @@ -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 ); +} diff --git a/cpukit/score/src/schedulerprioritythreadschedulerfree.c b/cpukit/score/src/schedulerpriorityfree.c index 5b13d20952..27757755e3 100644 --- a/cpukit/score/src/schedulerprioritythreadschedulerfree.c +++ b/cpukit/score/src/schedulerpriorityfree.c @@ -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 ); } diff --git a/cpukit/score/src/schedulerpriorityschedule.c b/cpukit/score/src/schedulerpriorityschedule.c index 052de7156a..e608e1f1f0 100644 --- a/cpukit/score/src/schedulerpriorityschedule.c +++ b/cpukit/score/src/schedulerpriorityschedule.c @@ -1,5 +1,5 @@ /* - * Scheduler Handler + * Scheduler Handler / Scheduler * * Copyright (C) 2010 Gedare Bloom. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c index c0ca1924d2..8c0f490c8c 100644 --- a/cpukit/score/src/schedulerpriorityunblock.c +++ b/cpukit/score/src/schedulerpriorityunblock.c @@ -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; + } } diff --git a/cpukit/score/src/schedulerprioritythreadschedulerupdate.c b/cpukit/score/src/schedulerpriorityupdate.c index 4b75d1d084..bbd46ee667 100644 --- a/cpukit/score/src/schedulerprioritythreadschedulerupdate.c +++ b/cpukit/score/src/schedulerpriorityupdate.c @@ -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; + + sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info; + rq = (Chain_Control *) _Scheduler.information; - the_thread->scheduler.priority->ready_chain = &rq[ - the_thread->current_priority - ]; + + 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 ); } diff --git a/cpukit/score/src/schedulerpriorityyield.c b/cpukit/score/src/schedulerpriorityyield.c index d25820993d..ba46a08f3d 100644 --- a/cpukit/score/src/schedulerpriorityyield.c +++ b/cpukit/score/src/schedulerpriorityyield.c @@ -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; - - executing = _Thread_Executing; - ready = executing->scheduler.priority->ready_chain; + Scheduler_priority_Per_thread *sched_info; + ISR_Level level; + Thread_Control *executing; + Chain_Control *ready; + + 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 ); diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c index 313d1697e8..95011d8237 100644 --- a/cpukit/score/src/threadchangepriority.c +++ b/cpukit/score/src/threadchangepriority.c @@ -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 @@ -33,21 +32,6 @@ void _Thread_Change_priority( 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 */ original_state = the_thread->current_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 ); diff --git a/cpukit/score/src/threadclose.c b/cpukit/score/src/threadclose.c index 853451aab1..ea2ee5bda4 100644 --- a/cpukit/score/src/threadclose.c +++ b/cpukit/score/src/threadclose.c @@ -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. diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index cda596bc56..adb0567d14 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -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 ); diff --git a/cpukit/score/src/threadsetpriority.c b/cpukit/score/src/threadsetpriority.c index 5c43c376a5..678df56fc8 100644 --- a/cpukit/score/src/threadsetpriority.c +++ b/cpukit/score/src/threadsetpriority.c @@ -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 ); } diff --git a/cpukit/score/src/threadsettransient.c b/cpukit/score/src/threadsettransient.c index 931125d20d..11f91ed30e 100644 --- a/cpukit/score/src/threadsettransient.c +++ b/cpukit/score/src/threadsettransient.c @@ -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 ); |