Not an embedded systems developer so an honest question. What do you do instead of malloc? Have a large array on stack and manage memory within that manually?
Not an embedded systems developer so an honest question. What do you do instead of malloc? Have a large array on stack and manage memory within that manually?
Then I follow my two rules of embedded development: - no recursion - everything has to be O(1)
If I'm honest, I can't remember a project where I had to use even a pool allocator, which you would usually need if you were trying to do like, reorderable queues / lists / trees or so. I right now can't come up with a proper use case. If you do need to say, compute a variable length sequence of actions based on an incoming packet, then I would structure my code so that:
a) only the current action and the next action get computed (so that there is no pause in between executing them)
b) compute the next action when I switch over (basically with a ping-pong buffer)
c) verify real-time invariants
My most used structure is the ring buffer to smooth out "semi-realtime" stuff, and if the ring buffer overflows, well, the ring buffer overflows and it has to be dealt with. If I could have more memory I would just make the ring buffer bigger.
I'm not sure how clear this explanation is :)
How is this done from C code? Any code examples someone can point me to?
char foobar[256] = {0};In many systems this isn't a problem. The number of engines, flaps, etc., don't change at run-time :-). If they change, you're on the ground in maintenance mode and can reboot.