Tickless mode implementation

Discussions and support about ChibiOS/RT, the free embedded RTOS.
hrrr
Posts: 4
Joined: Sun Jun 28, 2015 7:40 pm

Re: Tickless mode implementation

Post by hrrr »

a small question about the tickless mode....
Does CH_CFG_ST_FREQUENCY have an impact on performance of the system in tickless mode?
In traditional mode increasing CH_CFG_ST_FREQUENCY will increase the number of system interrupts per second. In tickless mode if CH_CFG_ST_FREQUENCY is increased, the system time resolution is better but... does it have any drawbacks? Any reason why a lower CH_CFG_ST_FREQUENCY might be better?

Thanks!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Tickless mode implementation

Post by Giovanni »

Hi,

The drawback is that an higher resolution allows for a shorter time before the time counter wraps back. In case you have a lot of activity with virtual timers you may need to increase the delta parameter in chconf.h. On an F4 I tested up to 4MhZ, probably it could also be increased. 1MhZ is a nice round number to use.

Note that running with too high frequencies does not make sense because the system jitter would become predominant, you would not gain accuracy.

Giovanni
hrrr
Posts: 4
Joined: Sun Jun 28, 2015 7:40 pm

Re: Tickless mode implementation

Post by hrrr »

Ok, thanks!

On a STM32F1 (16 bit timer) using CH_CFG_ST_FREQUENCY 10000 the timer will wrap about every 6.5 seconds, isn't it?
What happens then? I mean...do the virtual timer account for wrapping?

And.. in the same configuration, using the code form the wiki:
--
systime_t time = chTimeNow(); // T0
while (TRUE) {
time += MS2ST(1000); // Next deadline
do_something();
chThdSleepUntil(time);
}
--
would run into porblems after 6.5 seconds, right?
Any suggestion on how to do this reliably for long time with a f1?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Tickless mode implementation

Post by Giovanni »

Absolutely not, the counter is MEANT to wrap, it just means that the largest delay you can specify is 6.5 seconds. An OS that stops working after a finite time would not be nice.

Giovanni
hrrr
Posts: 4
Joined: Sun Jun 28, 2015 7:40 pm

Re: Tickless mode implementation

Post by hrrr »

OK, thanks! I figured it out myself as I had a look at the code...
Sorry for the question
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Tickless mode implementation

Post by alexblack »

Hi.
Is it possible to implement tickless mode on Timer with DOWN COUNT mode?
Is there any reason why used UP COUNTING mode?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Tickless mode implementation

Post by Giovanni »

The counter is used as system time and time is assumed to increase. You may simulate an up-counting counter in the ST driver, of course there is a small overhead.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Tickless mode implementation

Post by alexblack »

Thanks - good idea.
I am porting Chibi on EFM32 and want to use Low Energy timer as system because it works in deep sleep mode. Bu it is support only down counting mode. I will try simulate up counter.
Post Reply