git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7551 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
5b59f89d98
commit
c7da76627c
|
@ -464,11 +464,21 @@ static inline void chVTDoTickI(void) {
|
||||||
}
|
}
|
||||||
#else /* CH_CFG_ST_TIMEDELTA > 0 */
|
#else /* CH_CFG_ST_TIMEDELTA > 0 */
|
||||||
virtual_timer_t *vtp;
|
virtual_timer_t *vtp;
|
||||||
systime_t now = chVTGetSystemTimeX();
|
systime_t now;
|
||||||
systime_t delta = now - ch.vtlist.vt_lasttime;
|
|
||||||
|
|
||||||
while ((vtp = ch.vtlist.vt_next)->vt_delta <= delta) {
|
while (true) {
|
||||||
vtfunc_t fn;
|
vtfunc_t fn;
|
||||||
|
systime_t delta;
|
||||||
|
|
||||||
|
/* Getting the current system time and calculating the time window since
|
||||||
|
the last time has expired.*/
|
||||||
|
now = chVTGetSystemTimeX();
|
||||||
|
delta = now - ch.vtlist.vt_lasttime;
|
||||||
|
|
||||||
|
/* The next element is outside the current time window, the loop
|
||||||
|
is stopped here.*/
|
||||||
|
if ((vtp = ch.vtlist.vt_next)->vt_delta > delta)
|
||||||
|
break;
|
||||||
|
|
||||||
/* The "last time" becomes this timer's expiration time.*/
|
/* The "last time" becomes this timer's expiration time.*/
|
||||||
delta -= vtp->vt_delta;
|
delta -= vtp->vt_delta;
|
||||||
|
@ -491,8 +501,12 @@ static inline void chVTDoTickI(void) {
|
||||||
port_timer_stop_alarm();
|
port_timer_stop_alarm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Updating the alarm to the next deadline.*/
|
/* Updating the alarm to the next deadline, deadline that must not be
|
||||||
port_timer_set_alarm(now + vtp->vt_delta);
|
closer in time than the minimum time delta.*/
|
||||||
|
if (vtp->vt_delta >= CH_CFG_ST_TIMEDELTA)
|
||||||
|
port_timer_set_alarm(now + vtp->vt_delta);
|
||||||
|
else
|
||||||
|
port_timer_set_alarm(now + CH_CFG_ST_TIMEDELTA);
|
||||||
}
|
}
|
||||||
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
|
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,9 +180,14 @@ void chVTDoResetI(virtual_timer_t *vtp) {
|
||||||
port_timer_stop_alarm();
|
port_timer_stop_alarm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* The alarm is set to the next element in the delta list.*/
|
/* Updating the alarm to the next deadline, deadline that must not be
|
||||||
port_timer_set_alarm(ch.vtlist.vt_lasttime +
|
closer in time than the minimum time delta.*/
|
||||||
ch.vtlist.vt_next->vt_delta);
|
if (ch.vtlist.vt_next->vt_delta >= CH_CFG_ST_TIMEDELTA)
|
||||||
|
port_timer_set_alarm(ch.vtlist.vt_lasttime +
|
||||||
|
ch.vtlist.vt_next->vt_delta);
|
||||||
|
else
|
||||||
|
port_timer_set_alarm(ch.vtlist.vt_lasttime +
|
||||||
|
CH_CFG_ST_TIMEDELTA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
|
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||||
|
|
||||||
#define ALLOWED_DELAY MS2ST(5)
|
#define ALLOWED_DELAY MS2ST(2)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note, the static initializers are not really required because the
|
* Note, the static initializers are not really required because the
|
||||||
|
@ -170,10 +170,10 @@ static void sem2_execute(void) {
|
||||||
* Testing timeout condition.
|
* Testing timeout condition.
|
||||||
*/
|
*/
|
||||||
test_wait_tick();
|
test_wait_tick();
|
||||||
target_time = chVTGetSystemTime() + MS2ST(5 * 500);
|
target_time = chVTGetSystemTime() + MS2ST(5 * 50);
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
test_emit_token('A' + i);
|
test_emit_token('A' + i);
|
||||||
msg = chSemWaitTimeout(&sem1, MS2ST(500));
|
msg = chSemWaitTimeout(&sem1, MS2ST(50));
|
||||||
test_assert(7, msg == MSG_TIMEOUT, "wrong wake-up message");
|
test_assert(7, msg == MSG_TIMEOUT, "wrong wake-up message");
|
||||||
test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty");
|
test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty");
|
||||||
test_assert(9, sem1.s_cnt == 0, "counter not zero");
|
test_assert(9, sem1.s_cnt == 0, "counter not zero");
|
||||||
|
|
|
@ -194,22 +194,30 @@ static void thd4_execute(void) {
|
||||||
/* Timeouts in microseconds.*/
|
/* Timeouts in microseconds.*/
|
||||||
time = chVTGetSystemTime();
|
time = chVTGetSystemTime();
|
||||||
chThdSleepMicroseconds(100000);
|
chThdSleepMicroseconds(100000);
|
||||||
test_assert_time_window(1, time + US2ST(100000), time + US2ST(100000) + 1);
|
test_assert_time_window(1,
|
||||||
|
time + US2ST(100000),
|
||||||
|
time + US2ST(100000) + CH_CFG_ST_TIMEDELTA);
|
||||||
|
|
||||||
/* Timeouts in milliseconds.*/
|
/* Timeouts in milliseconds.*/
|
||||||
time = chVTGetSystemTime();
|
time = chVTGetSystemTime();
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(100);
|
||||||
test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + 1);
|
test_assert_time_window(2,
|
||||||
|
time + MS2ST(100),
|
||||||
|
time + MS2ST(100) + CH_CFG_ST_TIMEDELTA);
|
||||||
|
|
||||||
/* Timeouts in seconds.*/
|
/* Timeouts in seconds.*/
|
||||||
time = chVTGetSystemTime();
|
time = chVTGetSystemTime();
|
||||||
chThdSleepSeconds(1);
|
chThdSleepSeconds(1);
|
||||||
test_assert_time_window(3, time + S2ST(1), time + S2ST(1) + 1);
|
test_assert_time_window(3,
|
||||||
|
time + S2ST(1),
|
||||||
|
time + S2ST(1) + CH_CFG_ST_TIMEDELTA);
|
||||||
|
|
||||||
/* Absolute timelines.*/
|
/* Absolute timelines.*/
|
||||||
time = chVTGetSystemTime() + MS2ST(100);
|
time = chVTGetSystemTime() + MS2ST(100);
|
||||||
chThdSleepUntil(time);
|
chThdSleepUntil(time);
|
||||||
test_assert_time_window(4, time, time + 1);
|
test_assert_time_window(4,
|
||||||
|
time,
|
||||||
|
time + CH_CFG_ST_TIMEDELTA);
|
||||||
}
|
}
|
||||||
|
|
||||||
ROMCONST struct testcase testthd4 = {
|
ROMCONST struct testcase testthd4 = {
|
||||||
|
|
Loading…
Reference in New Issue