diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-13 13:15:31 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-13 13:15:31 +0000 |
commit | f32d1e094163de8cba88ddef023e588a4b44a76f (patch) | |
tree | fcf3ed400b682cbbc434633ffa93538e860f2a02 /os/nil/src | |
parent | cbfcf714d6979593d62bfffc861195ee4e163106 (diff) | |
download | ChibiOS-f32d1e094163de8cba88ddef023e588a4b44a76f.tar.gz ChibiOS-f32d1e094163de8cba88ddef023e588a4b44a76f.tar.bz2 ChibiOS-f32d1e094163de8cba88ddef023e588a4b44a76f.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6302 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/nil/src')
-rw-r--r-- | os/nil/src/nil.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/os/nil/src/nil.c b/os/nil/src/nil.c index 7f1ee3516..5d9a660f7 100644 --- a/os/nil/src/nil.c +++ b/os/nil/src/nil.c @@ -337,29 +337,32 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) { #if NIL_CFG_ST_TIMEDELTA > 0
if (timeout != TIME_INFINITE) {
- systime_t time = chVTGetSystemTimeX() + timeout;
+ systime_t abstime;
/* TIMEDELTA makes sure to have enough time to reprogram the timer
before the free-running timer counter reaches the selected timeout.*/
if (timeout < NIL_CFG_ST_TIMEDELTA)
timeout = NIL_CFG_ST_TIMEDELTA;
+ /* Absolute time of the timeout event.*/
+ abstime = chVTGetSystemTimeX() + timeout;
+
if (nil.lasttime == nil.nexttime) {
/* Special case, first thread asking for a timeout.*/
- port_timer_start_alarm(time);
- nil.nexttime = time;
+ port_timer_start_alarm(abstime);
+ nil.nexttime = abstime;
}
else {
/* Special case, there are already other threads with a timeout
activated, evaluating the order.*/
- if (chVTIsTimeWithinX(time, nil.lasttime, nil.nexttime)) {
- port_timer_set_alarm(time);
- nil.nexttime = time;
+ if (chVTIsTimeWithinX(abstime, nil.lasttime, nil.nexttime)) {
+ port_timer_set_alarm(abstime);
+ nil.nexttime = abstime;
}
}
/* Timeout settings.*/
- otp->timeout = time - nil.lasttime;
+ otp->timeout = abstime - nil.lasttime;
}
#else
|