-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implemented heap_6 for C++ real-time applications #1031
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
Conversation
I tried to adjust my heap to FreeRTOS. This is my very first commit to FreeRTOS, i don't even know how to compile the kernel. Maybe You get it running and let me know what You think about it. https://forums.freertos.org/t/real-time-memory-manager/19685
My implementation is now compiling and running. I've made a test with the WIN32-MSVC demo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not the right place to put the code, perhaps a subfolder under memmang will be a more appropriate location?
This implementation is a lot more complex than the other heaps, so we need to take a look if it makes sense to break the pattern for this one?
We also need to add a readme to explain how this works, and probably some benchmarking to show that it actually does what it claims.
There was a mistake when the heap was full. Adding a block to the map can fail, i have to check for this and add the block to cache if so.
Hi Sven, Johnny from Denmark. Nice to see you provided an example. Thanks!
What do you mean? All of the heaps are working as described! FreeRTOS is used right now with these heaps in production software, safety critical software and in aviation software.
What certification(s) are you talking about (do you have a specific ISO, EN or DIN standard in mind)? When danielglasser (https://forums.freertos.org/u/danielglasser) talk about DO-178B not allowing deallocation, then it has nothing to do with the existing heap managers or with malloc/free as provided by the compiler - it is a requirement by the standard because this leave less points where the program can fail. Same with MISRA: Analysing what causes programs to crash and then making rules for how to make your program to avoid these pitfalls. Your heap changes nothing in this regard. With your example I tried to test the code for the two things I value for embedded projects: Speed and memory usage/overhead. The test (after setting configUSE_MALLOC_FAILED_HOOK to 0) using 100 bytes memory block was as follows:
So your heap wins on number of allocations, but lose on time. Thats actually nice! However, heap_5.c is normally not used that much as we often can allocate static variables in the non-contiguous blocks, so here is the results for a contiguous memory area of mainREGION_1_SIZE+mainREGION_2_SIZE+mainREGION_3_SIZE (configTOTAL_HEAP_SIZE set to 50913 bytes):
As you can see these three heaps are faster and has less overhead. An observation: Your code does not respect the configUSE_MALLOC_FAILED_HOOK flag - it indicates that a failed allocation should call the provided vApplicationMallocFailedHook function instead of returning NULL. So from my point of view, your memory manager seems to have a nice use case for multiple non-contiguous memory blocks, not at least because it can provide more allocated blocks than heap_5, but only if it is okay that it takes more time to allocate/deallocate. Best regards, |
Very good idea, my first intention.
Thank You very much, Johnny!
Thank You very much, Johnny!
Hi,
I don't get mad, but I get mildly annoyed when you can't see that the most common use of FreeRTOS are for embedded programming, where the resources (processsing power, flash memory and RAM) are very limited. The Win32 example is not even a good demonstration of FreeRTOS tasks or memory usage, as it maps to Windows threads and uses Windows stacks, which are two of the more memory consuming things in a embedded FreeRTOS based program. The Windows port is good for simulating an embedded program to try out concepts in an unlimited environment, but it is not used to make Windows multi-threaded programs.
And many of us using FreeRTOS are professional programmers which make actual programs for actual devices. The certification we talk about is e.g. software for heavy machinery, where peoples health or lives is at risk if a controlling device or the software running it crashes. For this reason, there are some international standards we have to adhere to and often an actual certification process of the system (hardware, software and the system it controls) performed by certification bodies. Please respect, that some people has used FreeRTOS for a long time and maybe, just maybe have a little bit of more knowledge of how it works and what it needs, than other people.
I've heard Mr. Musk talk about software stuff from time to time (AI included) indicating he has little to no actual knowledge about the science or programming behind it. He is an excellent business man, however - respect for that.
Thank you! As mentioned, after you made the example and used time to implement it for FreeRTOS, some people might find use for it. From my experience with the thing I have worked on (heavy machinery like cranes and foresting machines, earbuds, multiple surveillance systems) heap_2 is mostly used (maybe heap_4 for newer projects), followed by heap_1 and heap_3. Heap_5 is a niche as most embedded systems does not have the discontinuous memory that it is used for. However, more and more new microcontrollers seems to have more complex memory maps, so it might be more useable in the future. Best regards, |
I renamed parent_group to cluster_parent_group.
Thank you sharing your heap implementation. You should be able to use your heap with FreeRTOS without any issue. Please let us know if that is not the case and any support from the FreeRTOS Kernel is needed. As far as keeping the implementation goes, I think the best way to proceed would be to create an example using this heap, possibly showcasing its strengths, and putting it in the following repository to make it available to the community - https://github.com/FreeRTOS/FreeRTOS-Community-Supported-Demos. Since you already host your heap on GitHub, you should be able to consume it in your example using CMake FetchContent (or some other similar mechanism in your build system). Please let us know if you are good with this and I will close this PR. Thanks again! |
|
* fix warnings * update naming * updating +TCP to latest * review comments fix
Thanks for your PR, and enthusiasm for the topic. Having reviewed the code, I agree with aggarg@’s post – hence closing the PR here in the hope you create a PR in the community contributions repo as the best way of making this code available. I feel the code is a little more complex than users expect for FreeRTOS, and from some of your comments, may contain issues. Plus, some of the novelty would require signing of a Contributor License Agreement as mentioned at the bottom of the CONTRIBUTING.md file, which would then trigger escalated reviews on our side. |
I fixed my issue, it is ready for certification. Good bye! |
No description provided.