diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-03-27 14:43:43 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-03-27 14:43:43 +0000 |
commit | b11ee365281c1254e89d759d4577c27fc29b2079 (patch) | |
tree | 91238878f37fe891b5f9fba5f8b02e751238fcfb /os | |
parent | 307d87bdecde7d3fbd3af085314777e089bd7621 (diff) | |
download | ChibiOS-b11ee365281c1254e89d759d4577c27fc29b2079.tar.gz ChibiOS-b11ee365281c1254e89d759d4577c27fc29b2079.tar.bz2 ChibiOS-b11ee365281c1254e89d759d4577c27fc29b2079.zip |
Better comments.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9173 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/rt/src/chschd.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c index ace722d7b..82a38941c 100644 --- a/os/rt/src/chschd.c +++ b/os/rt/src/chschd.c @@ -287,25 +287,28 @@ thread_t *chSchReadyAheadI(thread_t *tp) { * @sclass
*/
void chSchGoSleepS(tstate_t newstate) {
- thread_t *otp;
+ thread_t *otp = currp;
chDbgCheckClassS();
- otp = currp;
+ /* New state.*/
otp->state = newstate;
+
#if CH_CFG_TIME_QUANTUM > 0
/* The thread is renouncing its remaining time slices so it will have a new
time quantum when it will wakeup.*/
otp->preempt = (tslices_t)CH_CFG_TIME_QUANTUM;
#endif
+
+ /* Next thread in ready list becomes current.*/
currp = queue_fifo_remove(&ch.rlist.queue);
+ currp->state = CH_STATE_CURRENT;
+
+ /* Handling idle-enter hook.*/
if (currp->prio == IDLEPRIO) {
CH_CFG_IDLE_ENTER_HOOK();
}
- /* The extracted thread is marked as current.*/
- currp->state = CH_STATE_CURRENT;
-
/* Swap operation as tail call.*/
chSysSwitch(currp, otp);
}
@@ -426,13 +429,15 @@ void chSchWakeupS(thread_t *ntp, msg_t msg) { (void) chSchReadyI(ntp);
}
else {
- currp = ntp;
otp = chSchReadyI(otp);
+
+ /* Handling idle-leave hook.*/
if (otp->prio == IDLEPRIO) {
CH_CFG_IDLE_LEAVE_HOOK();
}
/* The extracted thread is marked as current.*/
+ currp = ntp;
ntp->state = CH_STATE_CURRENT;
/* Swap operation as tail call.*/
@@ -501,14 +506,15 @@ void chSchDoRescheduleBehind(void) { /* Picks the first thread from the ready queue and makes it current.*/
currp = queue_fifo_remove(&ch.rlist.queue);
+ currp->state = CH_STATE_CURRENT;
+
+ /* Handling idle-leave hook.*/
if (otp->prio == IDLEPRIO) {
CH_CFG_IDLE_LEAVE_HOOK();
}
- /* The extracted thread is marked as current.*/
- currp->state = CH_STATE_CURRENT;
-
#if CH_CFG_TIME_QUANTUM > 0
+ /* It went behind peers so it gets a new time quantum.*/
otp->preempt = (tslices_t)CH_CFG_TIME_QUANTUM;
#endif
@@ -533,13 +539,13 @@ void chSchDoRescheduleAhead(void) { /* Picks the first thread from the ready queue and makes it current.*/
currp = queue_fifo_remove(&ch.rlist.queue);
+ currp->state = CH_STATE_CURRENT;
+
+ /* Handling idle-leave hook.*/
if (otp->prio == IDLEPRIO) {
CH_CFG_IDLE_LEAVE_HOOK();
}
- /* The extracted thread is marked as current.*/
- currp->state = CH_STATE_CURRENT;
-
/* Placing in ready list ahead of peers.*/
otp = chSchReadyAheadI(otp);
@@ -562,13 +568,13 @@ void chSchDoReschedule(void) { /* Picks the first thread from the ready queue and makes it current.*/
currp = queue_fifo_remove(&ch.rlist.queue);
+ currp->state = CH_STATE_CURRENT;
+
+ /* Handling idle-leave hook.*/
if (otp->prio == IDLEPRIO) {
CH_CFG_IDLE_LEAVE_HOOK();
}
- /* The extracted thread is marked as current.*/
- currp->state = CH_STATE_CURRENT;
-
#if CH_CFG_TIME_QUANTUM > 0
/* If CH_CFG_TIME_QUANTUM is enabled then there are two different scenarios
to handle on preemption: time quantum elapsed or not.*/
|