From 411e6a635117a17986c22d98176e80c6921f70a6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:40:21 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1678 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 134 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 os/kernel/include/chschd.h (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h new file mode 100644 index 000000000..ddb7df979 --- /dev/null +++ b/os/kernel/include/chschd.h @@ -0,0 +1,134 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file scheduler.h + * @brief Scheduler macros and structures. + * + * @addtogroup scheduler + * @{ + */ + +#ifndef _SCHEDULER_H_ +#define _SCHEDULER_H_ + +/** @brief Default thread wakeup low level message.*/ +#define RDY_OK 0 +/** @brief Low level message sent to a thread awakened by a timeout.*/ +#define RDY_TIMEOUT -1 +/** @brief Low level message sent to a thread awakened by a reset operation.*/ +#define RDY_RESET -2 + +#define NOPRIO 0 /**< @brief Ready list header priority. */ +#define IDLEPRIO 1 /**< @brief Idle thread priority. */ +#define LOWPRIO 2 /**< @brief Lowest user priority. */ +#define NORMALPRIO 64 /**< @brief Normal user priority. */ +#define HIGHPRIO 127 /**< @brief Highest user priority. */ +#define ABSPRIO 255 /**< @brief Greatest possible priority. */ + +/** + * @brief Zero time specification for some syscalls with a timeout + * specification. + * @note Not all functions accept @p TIME_IMMEDIATE as timeout parameter, + * see the specific function documentation. + */ +#define TIME_IMMEDIATE ((systime_t)-1) + +/** + * @brief Infinite time specification for all the syscalls with a timeout + * specification. + */ +#define TIME_INFINITE ((systime_t)0) + +/** + * @brief Returns the priority of the first thread on the given ready list. + */ +#define firstprio(rlp) ((rlp)->p_next->p_prio) + +/** + * @extends ThreadsQueue + * + * @brief Ready list header. + */ +typedef struct { + ThreadsQueue r_queue; /**< @brief Threads queue. */ + tprio_t r_prio; /**< @brief This field must be + initialized to zero. */ + struct context p_ctx; /**< @brief Not used, present because + offsets. */ +#if CH_USE_REGISTRY + Thread *p_newer; /**< @brief Newer registry element. */ + Thread *p_older; /**< @brief Older registry element. */ +#endif + /* End of the fields shared with the Thread structure.*/ +#if CH_TIME_QUANTUM > 0 + cnt_t r_preempt; /**< @brief Round robin counter. */ +#endif +#ifndef CH_CURRP_REGISTER_CACHE + Thread *r_current; /**< @brief The currently running + thread. */ +#endif +} ReadyList; + +#if !defined(__DOXYGEN__) +extern ReadyList rlist; +#endif + +#ifdef CH_CURRP_REGISTER_CACHE +register Thread *currp asm(CH_CURRP_REGISTER_CACHE); +#else +#define currp rlist.r_current +#endif + +/* + * Scheduler APIs. + */ +#ifdef __cplusplus +extern "C" { +#endif + void scheduler_init(void); + Thread *chSchReadyI(Thread *tp); + void chSchGoSleepS(tstate_t newstate); + msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time); + void chSchWakeupS(Thread *tp, msg_t msg); + void chSchDoRescheduleI(void); + void chSchRescheduleS(void); + bool_t chSchIsRescRequiredExI(void); + void chSchDoYieldS(void); +#ifdef __cplusplus +} +#endif + +/** + * @brief Determines if yielding is possible. + * @details This function returns @p TRUE if there is a ready thread with + * equal or higher priority. + */ +#define chSchCanYieldS() (firstprio(&rlist.r_queue) >= currp->p_prio) + +/** + * @brief Determines if the current thread must reschedule. + * @details This function returns @p TRUE if there is a ready thread with + * higher priority. + */ +#define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio) + +#endif /* _SCHEDULER_H_ */ + +/** @} */ -- cgit v1.2.3 From 5fb790997fec3b9d965c57e57b4edd156c8b8954 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:54:22 +0000 Subject: Renamed the kernel header to match their source files. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1679 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index ddb7df979..c06ed8100 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -18,15 +18,15 @@ */ /** - * @file scheduler.h + * @file chschd.h * @brief Scheduler macros and structures. * * @addtogroup scheduler * @{ */ -#ifndef _SCHEDULER_H_ -#define _SCHEDULER_H_ +#ifndef _CHSCHD_H_ +#define _CHSCHD_H_ /** @brief Default thread wakeup low level message.*/ #define RDY_OK 0 @@ -129,6 +129,6 @@ extern "C" { */ #define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio) -#endif /* _SCHEDULER_H_ */ +#endif /* _CHSCHD_H_ */ /** @} */ -- cgit v1.2.3 From 0eed163a696d4b6daab19fd8daf05b980058f5f3 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 16 Mar 2010 15:43:23 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1745 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'os/kernel/include/chschd.h') 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); @@ -115,19 +117,35 @@ 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_ */ -- cgit v1.2.3 From cf1b70f486a2696d523d585e91d0e4e5c7b8021c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 18 Mar 2010 16:01:11 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1749 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index b8406722b..d1b69cad5 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -105,14 +105,27 @@ register Thread *currp asm(CH_CURRP_REGISTER_CACHE); extern "C" { #endif void scheduler_init(void); +#if !defined(PORT_OPTIMIZED_READYI) Thread *chSchReadyI(Thread *tp); +#endif +#if !defined(PORT_OPTIMIZED_GOSLEEPS) void chSchGoSleepS(tstate_t newstate); +#endif +#if !defined(PORT_OPTIMIZED_GOSLEEPTIMEOUTS) msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time); +#endif +#if !defined(PORT_OPTIMIZED_WAKEUPS) void chSchWakeupS(Thread *tp, msg_t msg); +#endif +#if !defined(PORT_OPTIMIZED_DORESCHEDULEI) void chSchDoRescheduleI(void); +#endif +#if !defined(PORT_OPTIMIZED_RESCHEDULES) void chSchRescheduleS(void); +#endif +#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) bool_t chSchIsRescRequiredExI(void); - void chSchDoYieldS(void); +#endif #ifdef __cplusplus } #endif -- cgit v1.2.3 From 79075f9e81d9d56be5da3bf6cdae56f4ace950de Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Mar 2010 12:48:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1755 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index d1b69cad5..3847c948e 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -92,11 +92,33 @@ typedef struct { extern ReadyList rlist; #endif /* !defined(PORT_OPTIMIZED_RLIST_EXT) */ -#ifdef CH_CURRP_REGISTER_CACHE -register Thread *currp asm(CH_CURRP_REGISTER_CACHE); -#else +/** + * @brief Current thread pointer access macro. + * @note This macro is not meant to be used in the application code but + * only from within the kernel, use the @p chThdSelf() API instead. + * @note It is forbidden to use this macro in order to change the pointer + * (currp = something), use @p setcurrp() instead. + */ +#if !defined(PORT_OPTIMIZED_CURRP) || defined(__DOXYGEN__) +#if !defined(CH_CURRP_REGISTER_CACHE) || defined(__DOXYGEN__) #define currp rlist.r_current -#endif +#else /* defined(CH_CURRP_REGISTER_CACHE) */ +register Thread *currp asm(CH_CURRP_REGISTER_CACHE); +#endif /* defined(CH_CURRP_REGISTER_CACHE) */ +#endif /* !defined(PORT_OPTIMIZED_CURRP) */ + +/** + * @brief Current thread pointer change macro. + * @note This macro is not meant to be used in the application code but + * only from within the kernel. + */ +#if !defined(PORT_OPTIMIZED_SETCURRP) || defined(__DOXYGEN__) +#if !defined(CH_CURRP_REGISTER_CACHE) || defined(__DOXYGEN__) +#define setcurrp(tp) (rlist.r_current = (tp)) +#else /* defined(CH_CURRP_REGISTER_CACHE) */ +(currp = (tp)) +#endif /* defined(CH_CURRP_REGISTER_CACHE) */ +#endif /* !defined(PORT_OPTIMIZED_SETCURRP) */ /* * Scheduler APIs. @@ -135,7 +157,7 @@ extern "C" { * @details This function returns @p TRUE if there is a ready thread with * higher priority. */ -#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) && !defined(__DOXYGEN__) +#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) || defined(__DOXYGEN__) #define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio) #endif /* !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) */ @@ -144,7 +166,7 @@ extern "C" { * @details This function returns @p TRUE if there is a ready thread with * equal or higher priority. */ -#if !defined(PORT_OPTIMIZED_CANYIELDS) && !defined(__DOXYGEN__) +#if !defined(PORT_OPTIMIZED_CANYIELDS) || defined(__DOXYGEN__) #define chSchCanYieldS() (firstprio(&rlist.r_queue) >= currp->p_prio) #endif /* !defined(PORT_OPTIMIZED_CANYIELDS) */ -- cgit v1.2.3 From b61fb43e6cc681f9fc53a5efb116accc13e0d35d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Mar 2010 15:45:25 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1756 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 3847c948e..8d8a2b36f 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -71,11 +71,11 @@ typedef struct { ThreadsQueue r_queue; /**< @brief Threads queue. */ tprio_t r_prio; /**< @brief This field must be initialized to zero. */ - struct context p_ctx; /**< @brief Not used, present because + struct context r_ctx; /**< @brief Not used, present because offsets. */ #if CH_USE_REGISTRY - Thread *p_newer; /**< @brief Newer registry element. */ - Thread *p_older; /**< @brief Older registry element. */ + Thread *r_newer; /**< @brief Newer registry element. */ + Thread *r_older; /**< @brief Older registry element. */ #endif /* End of the fields shared with the Thread structure.*/ #if CH_TIME_QUANTUM > 0 -- cgit v1.2.3 From 000181feeac6baaef0c1e2c505365489b260aad9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 3 Apr 2010 15:46:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1844 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 8d8a2b36f..2518215bd 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -116,7 +116,7 @@ register Thread *currp asm(CH_CURRP_REGISTER_CACHE); #if !defined(CH_CURRP_REGISTER_CACHE) || defined(__DOXYGEN__) #define setcurrp(tp) (rlist.r_current = (tp)) #else /* defined(CH_CURRP_REGISTER_CACHE) */ -(currp = (tp)) +#define setcurrp(tp) (currp = (tp)) #endif /* defined(CH_CURRP_REGISTER_CACHE) */ #endif /* !defined(PORT_OPTIMIZED_SETCURRP) */ -- cgit v1.2.3 From 13b5f830e4ea24d0beb60f3ddf5ce76f23eb2765 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 3 Apr 2010 16:03:56 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1845 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 2518215bd..9d58fb887 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -113,11 +113,7 @@ register Thread *currp asm(CH_CURRP_REGISTER_CACHE); * only from within the kernel. */ #if !defined(PORT_OPTIMIZED_SETCURRP) || defined(__DOXYGEN__) -#if !defined(CH_CURRP_REGISTER_CACHE) || defined(__DOXYGEN__) -#define setcurrp(tp) (rlist.r_current = (tp)) -#else /* defined(CH_CURRP_REGISTER_CACHE) */ #define setcurrp(tp) (currp = (tp)) -#endif /* defined(CH_CURRP_REGISTER_CACHE) */ #endif /* !defined(PORT_OPTIMIZED_SETCURRP) */ /* -- cgit v1.2.3 From 1322201fbd4335b62c638df3727fa4246b67407a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 8 Apr 2010 12:39:05 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1859 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 9d58fb887..3c55d59a0 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -172,7 +172,7 @@ extern "C" { * equal or higher priority, if any. */ #if !defined(PORT_OPTIMIZED_DOYIELDS) || defined(__DOXYGEN__) -#define chSchDoYieldS(void) { \ +#define chSchDoYieldS() { \ if (chSchCanYieldS()) \ chSchDoRescheduleI(); \ } -- cgit v1.2.3 From ed7165dcb4da017d751903683d008077acb13d77 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 19 Jun 2010 11:24:30 +0000 Subject: White space fix. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2025 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 3c55d59a0..e5c6d7e55 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -93,7 +93,7 @@ extern ReadyList rlist; #endif /* !defined(PORT_OPTIMIZED_RLIST_EXT) */ /** - * @brief Current thread pointer access macro. + * @brief Current thread pointer access macro. * @note This macro is not meant to be used in the application code but * only from within the kernel, use the @p chThdSelf() API instead. * @note It is forbidden to use this macro in order to change the pointer -- cgit v1.2.3 From 07351222e6d0b6b3dcd4f50ecb18bc09e7402d1c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 21 Sep 2010 10:22:06 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2184 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index e5c6d7e55..a9283c290 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -58,6 +58,8 @@ /** * @brief Returns the priority of the first thread on the given ready list. + * + * @notapi */ #define firstprio(rlp) ((rlp)->p_next->p_prio) @@ -111,6 +113,8 @@ register Thread *currp asm(CH_CURRP_REGISTER_CACHE); * @brief Current thread pointer change macro. * @note This macro is not meant to be used in the application code but * only from within the kernel. + * + * @notapi */ #if !defined(PORT_OPTIMIZED_SETCURRP) || defined(__DOXYGEN__) #define setcurrp(tp) (currp = (tp)) @@ -152,6 +156,8 @@ extern "C" { * @brief Determines if the current thread must reschedule. * @details This function returns @p TRUE if there is a ready thread with * higher priority. + * + * @iclass */ #if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) || defined(__DOXYGEN__) #define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio) @@ -161,6 +167,8 @@ extern "C" { * @brief Determines if yielding is possible. * @details This function returns @p TRUE if there is a ready thread with * equal or higher priority. + * + * @sclass */ #if !defined(PORT_OPTIMIZED_CANYIELDS) || defined(__DOXYGEN__) #define chSchCanYieldS() (firstprio(&rlist.r_queue) >= currp->p_prio) @@ -170,6 +178,8 @@ extern "C" { * @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. + * + * @sclass */ #if !defined(PORT_OPTIMIZED_DOYIELDS) || defined(__DOXYGEN__) #define chSchDoYieldS() { \ -- cgit v1.2.3 From b3b1028036a2f18327fb97f2126192a2ace62bb2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 21 Feb 2011 19:06:46 +0000 Subject: TIME_IMMEDIATE and TIME_INFINITE values swapped. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2757 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index a9283c290..5d3aee7a0 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -48,13 +48,13 @@ * @note Not all functions accept @p TIME_IMMEDIATE as timeout parameter, * see the specific function documentation. */ -#define TIME_IMMEDIATE ((systime_t)-1) +#define TIME_IMMEDIATE ((systime_t)0) /** * @brief Infinite time specification for all the syscalls with a timeout * specification. */ -#define TIME_INFINITE ((systime_t)0) +#define TIME_INFINITE ((systime_t)-1) /** * @brief Returns the priority of the first thread on the given ready list. -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 5d3aee7a0..5dda6d00a 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From f5ae2552307f20f3fa3d987591fa60576981ce3d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 29 Mar 2011 14:51:08 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2850 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 5dda6d00a..1cd8e0664 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -127,7 +127,7 @@ register Thread *currp asm(CH_CURRP_REGISTER_CACHE); #ifdef __cplusplus extern "C" { #endif - void scheduler_init(void); + void _scheduler_init(void); #if !defined(PORT_OPTIMIZED_READYI) Thread *chSchReadyI(Thread *tp); #endif -- cgit v1.2.3 From b4aa14e88c9e28a16a5f9c0c220fac6cc36750ad Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 18 May 2011 09:03:50 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2971 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 1cd8e0664..e154da863 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -84,10 +84,8 @@ typedef struct { #if CH_TIME_QUANTUM > 0 cnt_t r_preempt; /**< @brief Round robin counter. */ #endif -#ifndef CH_CURRP_REGISTER_CACHE Thread *r_current; /**< @brief The currently running thread. */ -#endif } ReadyList; #endif /* !defined(PORT_OPTIMIZED_READYLIST_STRUCT) */ @@ -103,11 +101,7 @@ extern ReadyList rlist; * (currp = something), use @p setcurrp() instead. */ #if !defined(PORT_OPTIMIZED_CURRP) || defined(__DOXYGEN__) -#if !defined(CH_CURRP_REGISTER_CACHE) || defined(__DOXYGEN__) #define currp rlist.r_current -#else /* defined(CH_CURRP_REGISTER_CACHE) */ -register Thread *currp asm(CH_CURRP_REGISTER_CACHE); -#endif /* defined(CH_CURRP_REGISTER_CACHE) */ #endif /* !defined(PORT_OPTIMIZED_CURRP) */ /** -- cgit v1.2.3 From 075ff711f1c9cf031fa4708c6b704f120d9a509d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Aug 2011 09:00:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3192 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index e154da863..cd545a05e 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -76,12 +76,12 @@ typedef struct { initialized to zero. */ struct context r_ctx; /**< @brief Not used, present because offsets. */ -#if CH_USE_REGISTRY +#if CH_USE_REGISTRY || defined(__DOXYGEN__) Thread *r_newer; /**< @brief Newer registry element. */ Thread *r_older; /**< @brief Older registry element. */ #endif /* End of the fields shared with the Thread structure.*/ -#if CH_TIME_QUANTUM > 0 +#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__) cnt_t r_preempt; /**< @brief Round robin counter. */ #endif Thread *r_current; /**< @brief The currently running -- cgit v1.2.3 From aaad958769e757093a258cfdd5c75f515534fd7a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 13 Aug 2011 07:06:02 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3224 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index cd545a05e..0e933e8ba 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -134,14 +134,14 @@ extern "C" { #if !defined(PORT_OPTIMIZED_WAKEUPS) void chSchWakeupS(Thread *tp, msg_t msg); #endif -#if !defined(PORT_OPTIMIZED_DORESCHEDULEI) - void chSchDoRescheduleI(void); -#endif #if !defined(PORT_OPTIMIZED_RESCHEDULES) void chSchRescheduleS(void); #endif -#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) - bool_t chSchIsRescRequiredExI(void); +#if !defined(PORT_OPTIMIZED_ISPREEMPTIONREQUIRED) + bool_t chSchIsPreemptionRequired(void); +#endif +#if !defined(PORT_OPTIMIZED_DORESCHEDULE) + void chSchDoReschedule(void); #endif #ifdef __cplusplus } @@ -179,10 +179,37 @@ extern "C" { #if !defined(PORT_OPTIMIZED_DOYIELDS) || defined(__DOXYGEN__) #define chSchDoYieldS() { \ if (chSchCanYieldS()) \ - chSchDoRescheduleI(); \ + chSchDoReschedule(); \ } #endif /* !defined(PORT_OPTIMIZED_DOYIELDS) */ +/** + * @brief Inlineable preemption code. + * @details This is the common preemption code, this function must be invoked + * exclusively from the port layer. + * + * @special + */ +#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__) +#define chSchPreemption() { \ + tprio_t p1 = firstprio(&rlist.r_queue); \ + tprio_t p2 = currp->p_prio; \ + if (rlist.r_preempt) { \ + if (p1 > p2) \ + chSchDoReschedule(); \ + } \ + else { \ + if (p1 >= p2) \ + chSchDoReschedule(); \ + } \ +} +#else /* CH_TIME_QUANTUM == 0 */ +#define chSchPreemption() { \ + if (p1 >= p2) \ + chSchDoReschedule(); \ +} +#endif /* CH_TIME_QUANTUM == 0 */ + #endif /* _CHSCHD_H_ */ /** @} */ -- cgit v1.2.3 From 2d55ac3059fcca69cc9736db310b4521064c2b23 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 22 Aug 2011 17:18:52 +0000 Subject: Documentation improvements and code comments reformatting. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3248 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 0e933e8ba..27f6b9222 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -29,22 +29,35 @@ #ifndef _CHSCHD_H_ #define _CHSCHD_H_ -/** @brief Default thread wakeup low level message.*/ -#define RDY_OK 0 -/** @brief Low level message sent to a thread awakened by a timeout.*/ -#define RDY_TIMEOUT -1 -/** @brief Low level message sent to a thread awakened by a reset operation.*/ -#define RDY_RESET -2 +/** + * @name Wakeup status codes + * @{ + */ +#define RDY_OK 0 /**< @brief Normal wakeup message. */ +#define RDY_TIMEOUT -1 /**< @brief Wakeup caused by a timeout + condition. */ +#define RDY_RESET -2 /**< @brief Wakeup caused by a reset + condition. */ +/** @} */ +/** + * @name Priority constants + * @{ + */ #define NOPRIO 0 /**< @brief Ready list header priority. */ #define IDLEPRIO 1 /**< @brief Idle thread priority. */ #define LOWPRIO 2 /**< @brief Lowest user priority. */ #define NORMALPRIO 64 /**< @brief Normal user priority. */ #define HIGHPRIO 127 /**< @brief Highest user priority. */ #define ABSPRIO 255 /**< @brief Greatest possible priority. */ +/** @} */ /** - * @brief Zero time specification for some syscalls with a timeout + * @name Special time constants + * @{ + */ +/** + * @brief Zero time specification for some functions with a timeout * specification. * @note Not all functions accept @p TIME_IMMEDIATE as timeout parameter, * see the specific function documentation. @@ -52,10 +65,11 @@ #define TIME_IMMEDIATE ((systime_t)0) /** - * @brief Infinite time specification for all the syscalls with a timeout + * @brief Infinite time specification for all functions with a timeout * specification. */ #define TIME_INFINITE ((systime_t)-1) +/** @} */ /** * @brief Returns the priority of the first thread on the given ready list. -- cgit v1.2.3 From c9be79def630f153b0b2d28e905939c15743f989 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 23 Aug 2011 10:09:08 +0000 Subject: Kernel documentation fixes and improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 27f6b9222..0e490c26a 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -161,6 +161,10 @@ extern "C" { } #endif +/** + * @name Macro Functions + * @{ + */ /** * @brief Determines if the current thread must reschedule. * @details This function returns @p TRUE if there is a ready thread with @@ -223,6 +227,7 @@ extern "C" { chSchDoReschedule(); \ } #endif /* CH_TIME_QUANTUM == 0 */ +/** @} */ #endif /* _CHSCHD_H_ */ -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 0e490c26a..54076ec56 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 4401d0e7b2874074e37c90e0178667a854d0da1f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 6 Feb 2012 19:45:47 +0000 Subject: Round robin scheduling improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3930 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 54076ec56..215398659 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -95,9 +95,6 @@ typedef struct { Thread *r_older; /**< @brief Older registry element. */ #endif /* End of the fields shared with the Thread structure.*/ -#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__) - cnt_t r_preempt; /**< @brief Round robin counter. */ -#endif Thread *r_current; /**< @brief The currently running thread. */ } ReadyList; @@ -154,6 +151,12 @@ extern "C" { #if !defined(PORT_OPTIMIZED_ISPREEMPTIONREQUIRED) bool_t chSchIsPreemptionRequired(void); #endif +#if !defined(PORT_OPTIMIZED_DORESCHEDULEBEHIND) || defined(__DOXYGEN__) + void chSchDoRescheduleBehind(void); +#endif +#if !defined(PORT_OPTIMIZED_DORESCHEDULEAHEAD) || defined(__DOXYGEN__) + void chSchDoRescheduleAhead(void); +#endif #if !defined(PORT_OPTIMIZED_DORESCHEDULE) void chSchDoReschedule(void); #endif @@ -197,7 +200,7 @@ extern "C" { #if !defined(PORT_OPTIMIZED_DOYIELDS) || defined(__DOXYGEN__) #define chSchDoYieldS() { \ if (chSchCanYieldS()) \ - chSchDoReschedule(); \ + chSchDoRescheduleBehind(); \ } #endif /* !defined(PORT_OPTIMIZED_DOYIELDS) */ @@ -212,19 +215,19 @@ extern "C" { #define chSchPreemption() { \ tprio_t p1 = firstprio(&rlist.r_queue); \ tprio_t p2 = currp->p_prio; \ - if (rlist.r_preempt) { \ + if (currp->p_preempt) { \ if (p1 > p2) \ - chSchDoReschedule(); \ + chSchDoRescheduleAhead(); \ } \ else { \ if (p1 >= p2) \ - chSchDoReschedule(); \ + chSchDoRescheduleBehind(); \ } \ } #else /* CH_TIME_QUANTUM == 0 */ #define chSchPreemption() { \ if (p1 >= p2) \ - chSchDoReschedule(); \ + chSchDoRescheduleAhead(); \ } #endif /* CH_TIME_QUANTUM == 0 */ /** @} */ -- cgit v1.2.3 From f5a3976c393fffdc95627f27d4c49136fa9ec8ca Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 26 Mar 2012 09:13:37 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4055 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 215398659..3d1d37f7c 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -205,7 +205,7 @@ extern "C" { #endif /* !defined(PORT_OPTIMIZED_DOYIELDS) */ /** - * @brief Inlineable preemption code. + * @brief Inline-able preemption code. * @details This is the common preemption code, this function must be invoked * exclusively from the port layer. * -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chschd.h') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index 3d1d37f7c..37e457c31 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3