aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-03-16 15:43:23 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-03-16 15:43:23 +0000
commit0eed163a696d4b6daab19fd8daf05b980058f5f3 (patch)
tree0826c195f562234d1d220223271f2ef29ff183cf
parentc7add28f3b906a4c91fd0b5619125760179ae02d (diff)
downloadChibiOS-0eed163a696d4b6daab19fd8daf05b980058f5f3.tar.gz
ChibiOS-0eed163a696d4b6daab19fd8daf05b980058f5f3.tar.bz2
ChibiOS-0eed163a696d4b6daab19fd8daf05b980058f5f3.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1745 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--docs/Doxyfile2
-rw-r--r--docs/reports/SPC563M64-80.txt6
-rw-r--r--docs/rsc/layout.xml184
-rw-r--r--os/kernel/include/chschd.h30
-rw-r--r--os/kernel/kernel.dox12
-rw-r--r--os/kernel/src/chschd.c56
-rw-r--r--os/kernel/src/chthreads.c7
-rw-r--r--readme.txt7
8 files changed, 247 insertions, 57 deletions
diff --git a/docs/Doxyfile b/docs/Doxyfile
index 9ebf7f47d..6f2187e40 100644
--- a/docs/Doxyfile
+++ b/docs/Doxyfile
@@ -511,7 +511,7 @@ FILE_VERSION_FILTER =
# file name after the option, if omitted DoxygenLayout.xml will be used as the name
# of the layout file.
-LAYOUT_FILE =
+LAYOUT_FILE = ./rsc/layout.xml
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
diff --git a/docs/reports/SPC563M64-80.txt b/docs/reports/SPC563M64-80.txt
index 2b4930c77..a11669746 100644
--- a/docs/reports/SPC563M64-80.txt
+++ b/docs/reports/SPC563M64-80.txt
@@ -92,7 +92,7 @@ Settings: SYSCLK=80, optimal wait states, prefetching enabled
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
---- Score : 280181 msgs/S, 560362 ctxswc/S
+--- Score : 280180 msgs/S, 560360 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
@@ -120,7 +120,7 @@ Settings: SYSCLK=80, optimal wait states, prefetching enabled
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
---- Score : 654408 reschedulations/S, 654408 ctxswc/S
+--- Score : 614140 reschedulations/S, 614140 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
@@ -128,7 +128,7 @@ Settings: SYSCLK=80, optimal wait states, prefetching enabled
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
---- Score : 1093662 timers/S
+--- Score : 1093664 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
diff --git a/docs/rsc/layout.xml b/docs/rsc/layout.xml
new file mode 100644
index 000000000..eba6d68b3
--- /dev/null
+++ b/docs/rsc/layout.xml
@@ -0,0 +1,184 @@
+<doxygenlayout version="1.0">
+ <!-- Navigation index tabs for HTML output -->
+ <navindex>
+ <tab type="mainpage" visible="yes" title=""/>
+ <tab type="pages" visible="yes" title=""/>
+ <tab type="modules" visible="yes" title=""/>
+ <tab type="namespaces" visible="yes" title="">
+ <tab type="namespaces" visible="yes" title=""/>
+ <tab type="namespacemembers" visible="yes" title=""/>
+ </tab>
+ <tab type="classes" visible="yes" title="">
+ <tab type="classes" visible="yes" title=""/>
+ <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
+ <tab type="hierarchy" visible="yes" title=""/>
+ <tab type="classmembers" visible="yes" title=""/>
+ </tab>
+ <tab type="files" visible="yes" title="">
+ <tab type="files" visible="yes" title=""/>
+ <tab type="globals" visible="yes" title=""/>
+ </tab>
+ <tab type="dirs" visible="yes" title=""/>
+ <tab type="examples" visible="yes" title=""/>
+ </navindex>
+
+ <!-- Layout definition for a class page -->
+ <class>
+ <briefdescription visible="yes"/>
+ <includes visible="$SHOW_INCLUDE_FILES"/>
+ <inheritancegraph visible="$CLASS_GRAPH"/>
+ <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+ <allmemberslink visible="yes"/>
+ <memberdecl>
+ <nestedclasses visible="yes" title=""/>
+ <publictypes title=""/>
+ <publicslots title=""/>
+ <signals title=""/>
+ <publicmethods title=""/>
+ <publicstaticmethods title=""/>
+ <publicattributes title=""/>
+ <publicstaticattributes title=""/>
+ <protectedtypes title=""/>
+ <protectedslots title=""/>
+ <protectedmethods title=""/>
+ <protectedstaticmethods title=""/>
+ <protectedattributes title=""/>
+ <protectedstaticattributes title=""/>
+ <packagetypes title=""/>
+ <packagemethods title=""/>
+ <packagestaticmethods title=""/>
+ <packageattributes title=""/>
+ <packagestaticattributes title=""/>
+ <properties title=""/>
+ <events title=""/>
+ <privatetypes title=""/>
+ <privateslots title=""/>
+ <privatemethods title=""/>
+ <privatestaticmethods title=""/>
+ <privateattributes title=""/>
+ <privatestaticattributes title=""/>
+ <friends title=""/>
+ <related title="" subtitle=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ <memberdef>
+ <typedefs title=""/>
+ <enums title=""/>
+ <constructors title=""/>
+ <functions title=""/>
+ <related title=""/>
+ <variables title=""/>
+ <properties title=""/>
+ <events title=""/>
+ </memberdef>
+ <usedfiles visible="$SHOW_USED_FILES"/>
+ <authorsection visible="yes"/>
+ </class>
+
+ <!-- Layout definition for a namespace page -->
+ <namespace>
+ <briefdescription visible="yes"/>
+ <memberdecl>
+ <nestednamespaces visible="yes" title=""/>
+ <classes visible="yes" title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ <memberdef>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ </memberdef>
+ <authorsection visible="yes"/>
+ </namespace>
+
+ <!-- Layout definition for a file page -->
+ <file>
+ <briefdescription visible="yes"/>
+ <includes visible="$SHOW_INCLUDE_FILES"/>
+ <includegraph visible="$INCLUDE_GRAPH"/>
+ <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+ <sourcelink visible="yes"/>
+ <memberdecl>
+ <classes visible="yes" title=""/>
+ <namespaces visible="yes" title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ <memberdef>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ </memberdef>
+ <authorsection/>
+ </file>
+
+ <!-- Layout definition for a group page -->
+ <group>
+ <briefdescription visible="yes"/>
+ <groupgraph visible="$GROUP_GRAPHS"/>
+ <detaileddescription title="Description"/>
+ <memberdecl>
+ <classes visible="yes" title=""/>
+ <namespaces visible="yes" title=""/>
+ <dirs visible="yes" title=""/>
+ <nestedgroups visible="yes" title=""/>
+ <files visible="yes" title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <enumvalues title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <signals title=""/>
+ <publicslots title=""/>
+ <protectedslots title=""/>
+ <privateslots title=""/>
+ <events title=""/>
+ <properties title=""/>
+ <friends title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <memberdef>
+ <pagedocs/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <enumvalues title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <signals title=""/>
+ <publicslots title=""/>
+ <protectedslots title=""/>
+ <privateslots title=""/>
+ <events title=""/>
+ <properties title=""/>
+ <friends title=""/>
+ </memberdef>
+ <authorsection visible="yes"/>
+ </group>
+
+ <!-- Layout definition for a directory page -->
+ <directory>
+ <briefdescription visible="yes"/>
+ <directorygraph visible="yes"/>
+ <memberdecl>
+ <dirs visible="yes"/>
+ <files visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ </directory>
+</doxygenlayout>
diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h
index c06ed8100..b8406722b 100644
--- a/os/kernel/include/chschd.h
+++ b/os/kernel/include/chschd.h
@@ -66,6 +66,7 @@
*
* @brief Ready list header.
*/
+#if !defined(PORT_OPTIMIZED_READYLIST_STRUCT) || defined(__DOXYGEN__)
typedef struct {
ThreadsQueue r_queue; /**< @brief Threads queue. */
tprio_t r_prio; /**< @brief This field must be
@@ -85,10 +86,11 @@ typedef struct {
thread. */
#endif
} ReadyList;
+#endif /* !defined(PORT_OPTIMIZED_READYLIST_STRUCT) */
-#if !defined(__DOXYGEN__)
+#if !defined(PORT_OPTIMIZED_RLIST_EXT) && !defined(__DOXYGEN__)
extern ReadyList rlist;
-#endif
+#endif /* !defined(PORT_OPTIMIZED_RLIST_EXT) */
#ifdef CH_CURRP_REGISTER_CACHE
register Thread *currp asm(CH_CURRP_REGISTER_CACHE);
@@ -116,18 +118,34 @@ extern "C" {
#endif
/**
+ * @brief Determines if the current thread must reschedule.
+ * @details This function returns @p TRUE if there is a ready thread with
+ * higher priority.
+ */
+#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) && !defined(__DOXYGEN__)
+#define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio)
+#endif /* !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) */
+
+/**
* @brief Determines if yielding is possible.
* @details This function returns @p TRUE if there is a ready thread with
* equal or higher priority.
*/
+#if !defined(PORT_OPTIMIZED_CANYIELDS) && !defined(__DOXYGEN__)
#define chSchCanYieldS() (firstprio(&rlist.r_queue) >= currp->p_prio)
+#endif /* !defined(PORT_OPTIMIZED_CANYIELDS) */
/**
- * @brief Determines if the current thread must reschedule.
- * @details This function returns @p TRUE if there is a ready thread with
- * higher priority.
+ * @brief Yields the time slot.
+ * @details Yields the CPU control to the next thread in the ready list with
+ * equal or higher priority, if any.
*/
-#define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio)
+#if !defined(PORT_OPTIMIZED_DOYIELDS) || defined(__DOXYGEN__)
+#define chSchDoYieldS(void) { \
+ if (chSchCanYieldS()) \
+ chSchDoRescheduleI(); \
+}
+#endif /* !defined(PORT_OPTIMIZED_DOYIELDS) */
#endif /* _CHSCHD_H_ */
diff --git a/os/kernel/kernel.dox b/os/kernel/kernel.dox
index 5ca6005f6..b55d53d49 100644
--- a/os/kernel/kernel.dox
+++ b/os/kernel/kernel.dox
@@ -62,18 +62,6 @@
*/
/**
- * @defgroup scheduler Scheduler
- * ChibiOS/RT scheduler APIs and macros.
- * @ingroup base
- */
-
-/**
- * @defgroup threads Threads
- * Threads related APIs.
- * @ingroup base
- */
-
-/**
* @defgroup synchronization Synchronization
* Synchronization services.
* @ingroup kernel
diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c
index 412467b65..023c35d41 100644
--- a/os/kernel/src/chschd.c
+++ b/os/kernel/src/chschd.c
@@ -21,7 +21,13 @@
* @file chschd.c
* @brief Scheduler code.
*
- * @addtogroup scheduler
+ * @defgroup scheduler Scheduler
+ * @ingroup base
+ * @details This module provides the default portable scheduler code,
+ * scheduler functions can be individually captured by the port
+ * layer in order to provide architecture optimized equivalents.
+ * When a function is captured its default code is not built into
+ * the OS image, the optimized version is included instead.
* @{
*/
@@ -30,7 +36,9 @@
/**
* @brief Ready list header.
*/
+#if !defined(PORT_OPTIMIZED_RLIST_VAR) || defined(__DOXYGEN__)
ReadyList rlist;
+#endif /* !defined(PORT_OPTIMIZED_RLIST_VAR) */
/**
* @brief Scheduler initialization.
@@ -56,6 +64,7 @@ void scheduler_init(void) {
* @param[in] tp the Thread to be made ready
* @return The Thread pointer.
*/
+#if !defined(PORT_OPTIMIZED_READYI) || defined(__DOXYGEN__)
#if CH_OPTIMIZE_SPEED
/* NOTE: it is inlined in this module only.*/
INLINE Thread *chSchReadyI(Thread *tp) {
@@ -74,6 +83,7 @@ Thread *chSchReadyI(Thread *tp) {
tp->p_prev->p_next = cp->p_prev = tp;
return tp;
}
+#endif /* !defined(PORT_OPTIMIZED_READYI) */
/**
* @brief Puts the current thread to sleep into the specified state.
@@ -82,6 +92,7 @@ Thread *chSchReadyI(Thread *tp) {
*
* @param[in] newstate the new thread state
*/
+#if !defined(PORT_OPTIMIZED_GOSLEEPS) || defined(__DOXYGEN__)
void chSchGoSleepS(tstate_t newstate) {
Thread *otp;
@@ -93,6 +104,7 @@ void chSchGoSleepS(tstate_t newstate) {
chDbgTrace(currp, otp);
chSysSwitchI(currp, otp);
}
+#endif /* !defined(PORT_OPTIMIZED_GOSLEEPS) */
/*
* Timeout wakeup callback.
@@ -169,6 +181,7 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {
* @param[in] ntp the Thread to be made ready
* @param[in] msg message to the awakened thread
*/
+#if !defined(PORT_OPTIMIZED_WAKEUPS) || defined(__DOXYGEN__)
void chSchWakeupS(Thread *ntp, msg_t msg) {
ntp->p_u.rdymsg = msg;
@@ -189,12 +202,14 @@ void chSchWakeupS(Thread *ntp, msg_t msg) {
chSysSwitchI(ntp, otp);
}
}
+#endif /* !defined(PORT_OPTIMIZED_WAKEUPS) */
/**
* @brief Switches to the first thread on the runnable queue.
* @note It is intended to be called if @p chSchRescRequiredI() evaluates
* to @p TRUE.
*/
+#if !defined(PORT_OPTIMIZED_DORESCHEDULEI) || defined(__DOXYGEN__)
void chSchDoRescheduleI(void) {
Thread *otp, *ntp;
@@ -202,23 +217,26 @@ void chSchDoRescheduleI(void) {
rlist.r_preempt = CH_TIME_QUANTUM;
#endif
otp = currp;
- /* Pick the first thread from the ready queue and makes it current.*/
+ /* Picks the first thread from the ready queue and makes it current.*/
(currp = ntp = fifo_remove(&rlist.r_queue))->p_state = THD_STATE_CURRENT;
chSchReadyI(otp);
chDbgTrace(ntp, otp);
chSysSwitchI(ntp, otp);
}
+#endif /* !defined(PORT_OPTIMIZED_DORESCHEDULEI) */
/**
* @brief Performs a reschedulation if a higher priority thread is runnable.
* @details If a thread with a higher priority than the current thread is in
* the ready list then make the higher priority thread running.
*/
+#if !defined(PORT_OPTIMIZED_RESCHEDULES) || defined(__DOXYGEN__)
void chSchRescheduleS(void) {
if (chSchIsRescRequiredI())
chSchDoRescheduleI();
}
+#endif /* !defined(PORT_OPTIMIZED_RESCHEDULES) */
/**
* @brief Evaluates if a reschedulation is required.
@@ -230,6 +248,7 @@ void chSchRescheduleS(void) {
* @retval TRUE if there is a thread that should go in running state.
* @retval FALSE if a reschedulation is not required.
*/
+#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) || defined(__DOXYGEN__)
bool_t chSchIsRescRequiredExI(void) {
tprio_t p1 = firstprio(&rlist.r_queue);
tprio_t p2 = currp->p_prio;
@@ -245,37 +264,6 @@ bool_t chSchIsRescRequiredExI(void) {
return p1 > p2;
#endif
}
-
-/**
- * @brief Yields the time slot.
- * @details Yields the CPU control to the next thread in the ready list with
- * equal priority, if any.
- */
-void chSchDoYieldS(void) {
-
- if (chSchCanYieldS()) {
- Thread *cp = (Thread *)&rlist.r_queue;
- Thread *otp = currp;
-
- /* Note, the following insertion code works because we know that on the
- ready list there is at least one thread with priority equal or higher
- than the current one.*/
- otp->p_state = THD_STATE_READY;
- do {
- cp = cp->p_prev;
- } while (cp->p_prio < otp->p_prio);
- /* Insertion on p_next.*/
- otp->p_next = (otp->p_prev = cp)->p_next;
- otp->p_next->p_prev = cp->p_next = otp;
-
- /* Pick the first thread from the ready queue and makes it current.*/
- (currp = fifo_remove(&rlist.r_queue))->p_state = THD_STATE_CURRENT;
-#if CH_TIME_QUANTUM > 0
- rlist.r_preempt = CH_TIME_QUANTUM;
-#endif
- chDbgTrace(currp, otp);
- chSysSwitchI(currp, otp);
- }
-}
+#endif /* !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) */
/** @} */
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c
index 79ea23f94..a2745b94c 100644
--- a/os/kernel/src/chthreads.c
+++ b/os/kernel/src/chthreads.c
@@ -21,7 +21,12 @@
* @file chthreads.c
* @brief Threads code.
*
- * @addtogroup threads
+ * @defgroup threads Threads
+ * @ingroup base
+ * @details This module contains all the threads related APIs, creation,
+ * termination, synchronization, delay etc. Dynamic variants of
+ * the base static API are also included.
+ *
* @{
*/
diff --git a/readme.txt b/readme.txt
index 7af58f577..670871f95 100644
--- a/readme.txt
+++ b/readme.txt
@@ -65,9 +65,16 @@
subdirectory, this should make things easier for RIDE7 users. The normal
makefile is still available of course.
- NEW: New article in the documentation. Fixed an orphaned page (STM8 port).
+- NEW: The port layer now can "capture" the implementation of individual
+ scheduler API functions in order to provide architecture-optimized
+ versions. This is done because further scheduler optimizations are
+ becoming increasingly pointless without considering architecture and
+ compiler related constraints.
- OPT: Optimization on the interface between scheduler and port layer, now
the kernel is even smaller and the context switch performance improved
quite a bit on all the supported architectures.
+- OPT: Simplified the implementation of chSchYieldS() and made it a macro.
+ The previous implementation was probably overkill and took too much space.
*** 1.5.3 ***
- FIX: Removed C99-style variables declarations (bug 2964418)(backported