aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/include
diff options
context:
space:
mode:
Diffstat (limited to 'os/kernel/include')
-rw-r--r--os/kernel/include/chschd.h19
-rw-r--r--os/kernel/include/chthreads.h6
2 files changed, 17 insertions, 8 deletions
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 */
/** @} */
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h
index 66b593818..421a3e23f 100644
--- a/os/kernel/include/chthreads.h
+++ b/os/kernel/include/chthreads.h
@@ -122,6 +122,12 @@ struct Thread {
*/
trefs_t p_refs;
#endif
+ /**
+ * @brief Number of ticks remaining to this thread.
+ */
+#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
+ tslices_t p_preempt;
+#endif
#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
/**
* @brief Thread consumed time in ticks.