aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/kernel/include/scheduler.h2
-rw-r--r--os/kernel/src/chschd.c3
-rw-r--r--os/ports/GCC/ARMCM3/chcore.c6
-rw-r--r--os/ports/GCC/ARMCM3/chcore.h7
4 files changed, 7 insertions, 11 deletions
diff --git a/os/kernel/include/scheduler.h b/os/kernel/include/scheduler.h
index 8aa692e58..f3216bb7a 100644
--- a/os/kernel/include/scheduler.h
+++ b/os/kernel/include/scheduler.h
@@ -117,7 +117,7 @@ extern "C" {
* @details This function returns @p TRUE if there is a ready thread with
* higher priority.
*/
-#define chSchMustRescheduleS() (firstprio(&rlist.r_queue) >= currp->p_prio)
+#define chSchMustRescheduleS() (firstprio(&rlist.r_queue) > currp->p_prio)
#endif /* _SCHEDULER_H_ */
diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c
index 1f7e27c93..08ecf46a0 100644
--- a/os/kernel/src/chschd.c
+++ b/os/kernel/src/chschd.c
@@ -210,8 +210,7 @@ void chSchDoRescheduleI(void) {
* the ready list then make the higher priority thread running.
*/
void chSchRescheduleS(void) {
- /* First thread in the runnable queue has higher priority than the running
- * thread?.*/
+
if (chSchMustRescheduleS())
chSchDoRescheduleI();
}
diff --git a/os/ports/GCC/ARMCM3/chcore.c b/os/ports/GCC/ARMCM3/chcore.c
index ce76ffa4c..4e9874f82 100644
--- a/os/ports/GCC/ARMCM3/chcore.c
+++ b/os/ports/GCC/ARMCM3/chcore.c
@@ -151,13 +151,7 @@ void PendSVVector(void) {
Thread *otp;
register struct intctx *sp_thd asm("r12");
- asm volatile ("push {lr}");
chSysLockFromIsr();
- if (!chSchRescRequiredI()) {
- chSysUnlockFromIsr();
- asm volatile ("pop {pc}");
- }
- asm volatile ("pop {lr}");
PUSH_CONTEXT(sp_thd);
diff --git a/os/ports/GCC/ARMCM3/chcore.h b/os/ports/GCC/ARMCM3/chcore.h
index 4a6ee2695..daff52090 100644
--- a/os/ports/GCC/ARMCM3/chcore.h
+++ b/os/ports/GCC/ARMCM3/chcore.h
@@ -209,8 +209,11 @@ struct context {
* IRQ epilogue code, inserted at the end of all IRQ handlers enabled to
* invoke system APIs.
*/
-#define PORT_IRQ_EPILOGUE() { \
- SCB_ICSR = ICSR_PENDSVSET; \
+#define PORT_IRQ_EPILOGUE() { \
+ chSysLockFromIsr(); \
+ if (chSchRescRequiredI()) \
+ SCB_ICSR = ICSR_PENDSVSET; \
+ chSysUnlockFromIsr(); \
}
/**