diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-03-16 15:43:23 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-03-16 15:43:23 +0000 |
commit | 0eed163a696d4b6daab19fd8daf05b980058f5f3 (patch) | |
tree | 0826c195f562234d1d220223271f2ef29ff183cf /os/kernel | |
parent | c7add28f3b906a4c91fd0b5619125760179ae02d (diff) | |
download | ChibiOS-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
Diffstat (limited to 'os/kernel')
-rw-r--r-- | os/kernel/include/chschd.h | 30 | ||||
-rw-r--r-- | os/kernel/kernel.dox | 12 | ||||
-rw-r--r-- | os/kernel/src/chschd.c | 56 | ||||
-rw-r--r-- | os/kernel/src/chthreads.c | 7 |
4 files changed, 52 insertions, 53 deletions
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.
+ *
* @{
*/
|