-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Long sleeps imprecise #11
Comments
Oh, and Argon is running in tickless mode. |
Also, argon keeps time of wakeups in ticks. When systick period is clamped to value, which is not aligned to with (multiple of) tick duration, more timing errors raises. |
Hi @flit, again, I have project which would benefit from such light RTOS. So I dove into Argon debugging again and found several bugs in tickless mode timing (not tested tick mode). It's all about requests to argon between ticks (aligned times when could scheduler ticks occur). Are you interested in discussion about fixes? |
Definitely interested! 😄 |
Great! Timing allignment issueLet's have this scenario:
Thread B:
Thread B is periodically resumed from some timer IRQ (really does not matter, just asynchronous to tick). Runtime:
In extreme case when Solution is to take timer current value into account when configuring timer. This would mean configuring timer to 7 ms.
Same time loss happens, when thread runs several ms and in the end, requests sleep. Wakeup time is referenced to moment of this call screwing timing for others. Repetitive tick increment issueSame thread config like in issue above. Runtime:
The issue is, that scheduler calls IMO cleanest solution would be to move handling of all ticking to ar_port.cpp together with Note: Issues may not be clear at first, but I've spent several days debugging Argon. Drawn numerous timing diagrams and did some poor man's tracing Current stateI have working tickless mode with precise timing on STM32F303 with 2 chained timers/counters. First one is counting microseconds between kernel ticks (16bit) and second one is counting overflows = ticks (32bit). Wake-up interrupt is connected on value compare on tick counter. Values or Reloads are never altered. Counters are never stopped. When Argon wants time, it always gets value from counters. I'll try to implement timing with single timer without necessity for chaining 2 timers. I have to cleanup my code and will link relevant branch here. |
WIP here: https://github.com/diggit/argon-rtos/tree/ticklessFixes |
I am also curious, which version of C++ do you target? Even C++11 has |
(Sorry I'm being slow to reply… this weekend I've been totally focused on implementing CMSIS-Pack debug sequence support for pyOCD.) Timing These are where I'd like to take Argon in regards to timing:
(You can see some of these, and a lot more, in I was thinking the timer management should be moved to a separate I'll take a look at your ticklessFixes branch over the next few days/week. Again, I really appreciate your working on this! 😄 Language stuff Btw, using enums for integer constants is a style widely used by Apple. Years ago, I used to primarily be a Mac developer, so it just looks natural to me. For related constants, I like how it syntactically groups them together. Missed ticks |
No problem. I've never tried pyOCD and always stick to openocd. Maybe it's time to try something new.
What about moving todos to some issue which can be easily edited/updated even without committing changes? Language stuffWell I am using llvm and gcc, both support C++17, but even C++14 would be nice. Missed ticksAlready ditched them in my branch. Function was remaed |
Unfortunately IAR only supports C++14 (not even C++11!). Although I'm not using IAR much anymore myself, I'd still like to keep compatibility with the 3 major compilers. Long ago (like mid-2000s), in a pre-Argon RTOS for ARM7, I did have a full C++ implementation with C wrappers. Unfortunately, this configuration makes it very difficult to manage statically-allocated kernel objects from the C wrappers. It also is the least efficient as far as code-size (you can't place calls to the C++ objects in inline C functions, since you can't import the C++ headers at the C API level). |
can you elaborate? In following code, class Test {
int member {99};
public:
int double_me_and_add(int num) {return num*2 + member;}
};
Test g_t;
extern "C" int test_double_me_and_add(int num) {
return g_t.double_me_and_add(num);
}
Well, as long as you compile sources individually and link them afterwards, almost every call in single compilation unit can be inlined. Calls between compilation units can be inlined when function body is in header which can be included other compilation units. If you enable Is IAR Embedded something differemnt from IAR? Here they say about support of all features of C++17. Even C++14 would be nice. Please consider migration of Argon to C++, there are so many benefits. |
When there is scheduled sleep longer than maximum systick period, sleeping times become imprecise. Sleep times are then multiples of systick maximum period, even the last one which would be probably shorter than that. Problem is this line https://github.com/flit/argon-rtos/blob/master/src/ar_kernel.cpp#L279. Systick is not reconfigured and stays at maximum period until it overshoots or matches nextWakeup time. Sleep is then longer than required.
I'll try to fix it and open PR
The text was updated successfully, but these errors were encountered: