summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-06-17 14:31:46 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-06-17 14:31:46 +0000
commit3203e09507da6484f267605793fd770586a63d55 (patch)
tree882a86450acc183b1485995ae7b14e430e27a358 /cpukit
parent2011-04-10 Kate Feng <feng@bnl.gov> (diff)
downloadrtems-3203e09507da6484f267605793fd770586a63d55.tar.bz2
2011-06-17 Joel Sherrill <joel.sherrill@oarcorp.com>
PR 1819/cpukit * rtems/src/clocktick.c, score/Makefile.am, score/include/rtems/score/scheduler.h, score/include/rtems/score/schedulerpriority.h, score/include/rtems/score/schedulersimple.h, score/include/rtems/score/schedulersimplesmp.h, score/include/rtems/score/thread.h, score/inline/rtems/score/scheduler.inl: Add a scheduler entry point which is invoked at each clock tick. _Thread_Tickle_timeslice() is now a method owned by the Deterministic Priority Scheduler and shared by the Simple Priority Scheduler. The Simple SMP Scheduler has its own variation on this which does timeslicing bookkeeping on all cores. * score/src/schedulerprioritytick.c, score/src/schedulersimplesmptick.c: New files. * score/src/threadtickletimeslice.c: Removed.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/ChangeLog19
-rw-r--r--cpukit/rtems/src/clocktick.c6
-rw-r--r--cpukit/score/Makefile.am7
-rw-r--r--cpukit/score/include/rtems/score/scheduler.h3
-rw-r--r--cpukit/score/include/rtems/score/schedulerpriority.h12
-rw-r--r--cpukit/score/include/rtems/score/schedulersimple.h4
-rw-r--r--cpukit/score/include/rtems/score/schedulersimplesmp.h13
-rw-r--r--cpukit/score/include/rtems/score/thread.h9
-rw-r--r--cpukit/score/inline/rtems/score/scheduler.inl12
-rw-r--r--cpukit/score/src/schedulerprioritytick.c (renamed from cpukit/score/src/threadtickletimeslice.c)32
-rw-r--r--cpukit/score/src/schedulersimplesmptick.c100
11 files changed, 169 insertions, 48 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index e53dc410f1..b74f395e1b 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,22 @@
+2011-06-17 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ PR 1819/cpukit
+ * rtems/src/clocktick.c, score/Makefile.am,
+ score/include/rtems/score/scheduler.h,
+ score/include/rtems/score/schedulerpriority.h,
+ score/include/rtems/score/schedulersimple.h,
+ score/include/rtems/score/schedulersimplesmp.h,
+ score/include/rtems/score/thread.h,
+ score/inline/rtems/score/scheduler.inl: Add a scheduler entry point
+ which is invoked at each clock tick. _Thread_Tickle_timeslice() is
+ now a method owned by the Deterministic Priority Scheduler and shared
+ by the Simple Priority Scheduler. The Simple SMP Scheduler has its
+ own variation on this which does timeslicing bookkeeping on all
+ cores.
+ * score/src/schedulerprioritytick.c,
+ score/src/schedulersimplesmptick.c: New files.
+ * score/src/threadtickletimeslice.c: Removed.
+
2011-06-17 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/include/rtems/libio.h, cpukit/libcsupport/src/termios.c:
diff --git a/cpukit/rtems/src/clocktick.c b/cpukit/rtems/src/clocktick.c
index f02f48fb45..fa8a454070 100644
--- a/cpukit/rtems/src/clocktick.c
+++ b/cpukit/rtems/src/clocktick.c
@@ -1,7 +1,5 @@
/*
- * Clock Manager
- *
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -45,7 +43,7 @@ rtems_status_code rtems_clock_tick( void )
_Watchdog_Tickle_ticks();
- _Thread_Tickle_timeslice();
+ _Scheduler_Tick();
if ( _Thread_Is_context_switch_necessary() &&
_Thread_Is_dispatching_enabled() )
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 9138178e33..cc7d8b9e45 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -134,7 +134,7 @@ endif
if HAS_SMP
libscore_a_SOURCES += src/smp.c src/smplock.c \
src/schedulersimplesmpblock.c src/schedulersimplesmpschedule.c \
- src/schedulersimplesmpunblock.c
+ src/schedulersimplesmpunblock.c src/schedulerprioritytick.c
endif
## CORE_APIMUTEX_C_FILES
@@ -196,6 +196,7 @@ libscore_a_SOURCES += src/scheduler.c
## SCHEDULERPRIORITY_C_FILES
libscore_a_SOURCES += src/schedulerpriority.c \
src/schedulerpriorityallocate.c \
+ src/schedulerprioritytick.c \
src/schedulerpriorityblock.c \
src/schedulerpriorityenqueue.c \
src/schedulerpriorityenqueuefirst.c \
@@ -239,8 +240,8 @@ libscore_a_SOURCES += src/thread.c src/threadchangepriority.c \
src/threadrestart.c src/threadsetpriority.c \
src/threadsetstate.c src/threadsettransient.c \
src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \
- src/threadstartmultitasking.c src/threadtickletimeslice.c \
- src/iterateoverthreads.c src/threadblockingoperationcancel.c
+ src/threadstartmultitasking.c src/iterateoverthreads.c \
+ src/threadblockingoperationcancel.c
if HAS_SMP
libscore_a_SOURCES += src/threaddispatchdisablelevel.c
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index c094b9400a..2c99a3d7f5 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -74,6 +74,9 @@ typedef struct {
/** extract a thread from the ready set */
void ( *extract )(Thread_Control *);
+
+ /** perform scheduler update actions required at each clock tick */
+ void ( *tick )(void);
} Scheduler_Operations;
/**
diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h
index 2cd2353204..2f164b7635 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -48,7 +48,8 @@ extern "C" {
_Scheduler_priority_Update, /* update entry point */ \
_Scheduler_priority_Enqueue, /* enqueue entry point */ \
_Scheduler_priority_Enqueue_first, /* enqueue_first entry point */ \
- _Scheduler_priority_Extract /* extract entry point */ \
+ _Scheduler_priority_Extract, /* extract entry point */ \
+ _Scheduler_priority_Tick /* tick entry point */ \
}
/**
@@ -171,6 +172,15 @@ void _Scheduler_priority_Extract(
);
/**
+ * @brief Deterministic Priority Scheduler Tick Method
+ *
+ * This routine is invoked as part of processing each clock tick.
+ * It is responsible for determining if the current thread allows
+ * timeslicing and, if so, when its timeslice expires.
+ */
+void _Scheduler_priority_Tick( void );
+
+/**
* This is the major bit map.
*/
extern volatile Priority_bit_map_Control _Priority_Major_bit_map;
diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h
index d81939e49c..902349adfb 100644
--- a/cpukit/score/include/rtems/score/schedulersimple.h
+++ b/cpukit/score/include/rtems/score/schedulersimple.h
@@ -28,6 +28,7 @@ extern "C" {
#endif
#include <rtems/score/scheduler.h>
+#include <rtems/score/schedulerpriority.h>
/**
* Entry points for Scheduler Simple
@@ -44,7 +45,8 @@ extern "C" {
_Scheduler_simple_Update, /* update entry point */ \
_Scheduler_simple_Enqueue, /* enqueue entry point */ \
_Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \
- _Scheduler_simple_Extract /* extract entry point */ \
+ _Scheduler_simple_Extract, /* extract entry point */ \
+ _Scheduler_priority_Tick /* tick entry point */ \
}
/**
diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h
index 462eaf00e6..55c24ea41d 100644
--- a/cpukit/score/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h
@@ -56,7 +56,8 @@ extern "C" {
_Scheduler_simple_Update, /* update entry point */ \
_Scheduler_simple_Enqueue, /* enqueue entry point */ \
_Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \
- _Scheduler_simple_Extract /* extract entry point */ \
+ _Scheduler_simple_Extract, /* extract entry point */ \
+ _Scheduler_simple_smp_Tick /* tick entry point */ \
}
/**
@@ -95,6 +96,16 @@ void _Scheduler_simple_smp_Unblock(
Thread_Control *the_thread
);
+/**
+ * @brief Scheduler Simple SMP Tick Method
+ *
+ * This routine is invoked as part of processing each clock tick.
+ * It is responsible for determining if the current thread allows
+ * timeslicing and, if so, when its timeslice expires.
+ */
+void _Scheduler_simple_smp_Tick( void );
+
+/**
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 8e469f4058..c1b5d14b47 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2011.
+ * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -660,13 +660,6 @@ void _Thread_Set_transient(
);
/**
- * This routine is invoked as part of processing each clock tick.
- * It is responsible for determining if the current thread allows
- * timeslicing and, if so, when its timeslice expires.
- */
-void _Thread_Tickle_timeslice( void );
-
-/**
* This routine initializes the context of the_thread to its
* appropriate starting state.
*/
diff --git a/cpukit/score/inline/rtems/score/scheduler.inl b/cpukit/score/inline/rtems/score/scheduler.inl
index 4a6c74cbf8..cc0a79614a 100644
--- a/cpukit/score/inline/rtems/score/scheduler.inl
+++ b/cpukit/score/inline/rtems/score/scheduler.inl
@@ -159,6 +159,18 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Extract(
_Scheduler.Operations.extract( the_thread );
}
+/** @brief Scheduler Method Invoked at Each Clock Tick
+ *
+ * This method is invoked at each clock tick to allow the scheduler
+ * implementation to perform any activities required. For the
+ * scheduler which support standard RTEMS features, this includes
+ * time-slicing management.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Tick( void )
+{
+ _Scheduler.Operations.tick();
+}
+
/**@}*/
#endif
diff --git a/cpukit/score/src/threadtickletimeslice.c b/cpukit/score/src/schedulerprioritytick.c
index 4c2772a2aa..6f49ab60c8 100644
--- a/cpukit/score/src/threadtickletimeslice.c
+++ b/cpukit/score/src/schedulerprioritytick.c
@@ -1,7 +1,4 @@
/*
- * Thread Handler
- *
- *
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
@@ -17,34 +14,9 @@
#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>
-
-/*PAGE
- *
- * _Thread_Tickle_timeslice
- *
- * This scheduler routine determines if timeslicing is enabled
- * for the currently executing thread and, if so, updates the
- * timeslice count and checks for timeslice expiration.
- *
- * Input parameters: NONE
- *
- * Output parameters: NONE
- */
+#include <rtems/score/schedulerpriority.h>
-void _Thread_Tickle_timeslice( void )
+void _Scheduler_priority_Tick( void )
{
Thread_Control *executing;
diff --git a/cpukit/score/src/schedulersimplesmptick.c b/cpukit/score/src/schedulersimplesmptick.c
new file mode 100644
index 0000000000..5577b5579b
--- /dev/null
+++ b/cpukit/score/src/schedulersimplesmptick.c
@@ -0,0 +1,100 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * 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/score/schedulersimplesmp.h>
+
+static void _Scheduler_simple_smp_Tick_helper(
+ int cpu
+)
+{
+ Thread_Control *executing;
+
+ executing = _Per_CPU_Information[cpu].executing;
+
+ #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
+ /*
+ * Increment the number of ticks this thread has been executing
+ */
+ executing->cpu_time_used++;
+ #endif
+
+ /*
+ * If the thread is not preemptible or is not ready, then
+ * just return.
+ */
+
+ if ( !executing->is_preemptible )
+ return;
+
+ if ( !_States_Is_ready( executing->current_state ) )
+ return;
+
+ /*
+ * The cpu budget algorithm determines what happens next.
+ */
+
+ switch ( executing->budget_algorithm ) {
+ case THREAD_CPU_BUDGET_ALGORITHM_NONE:
+ break;
+
+ case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
+ #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
+ case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
+ #endif
+ if ( (int)(--executing->cpu_time_budget) <= 0 ) {
+
+ /*
+ * A yield performs the ready chain mechanics needed when
+ * resetting a timeslice. If no other thread's are ready
+ * at the priority of the currently executing thread, then the
+ * executing thread's timeslice is reset. Otherwise, the
+ * currently executing thread is placed at the rear of the
+ * FIFO for this priority and a new heir is selected.
+ *
+ * In the SMP case, we do the chain manipulation for every
+ * CPU, then schedule after all CPUs have been evaluated.
+ */
+ _ISR_Disable( level );
+ _Scheduler_simple_Ready_queue_requeue( &_Scheduler, executing );
+ _ISR_Enable( level );
+
+ executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
+ }
+ break;
+
+ #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
+ case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
+ if ( --executing->cpu_time_budget == 0 )
+ (*executing->budget_callout)( executing );
+ break;
+ #endif
+ }
+}
+
+void _Scheduler_simple_smp_Tick( void )
+{
+ uint32_t cpu;
+
+ /*
+ * Iterate over all cores, updating time slicing information
+ * and logically performing a yield. Then perform a schedule
+ * operation to account for all the changes.
+ */
+ for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
+ _Scheduler_simple_smp_Tick_helper( cpu );
+ }
+ _Scheduler_simple_smp_Schedule();
+}