'What is a pre-allocated buffer, and how should you use one?
I am studying FreeRTOS, and in their tutorial book they talk about using "a pool of pre-allocated buffers" for holding pointers to char[] arrays (to pass between tasks via a queue).
In the example found in Chapter 4.5 Working with Large or Variable Sized Data, they reference this sudo function called prvGetBuffer() and state "The implementation of prvGetBuffer() is not shown – it might obtain the buffer from a pool of pre-allocated buffers, or just allocate the buffer dynamically.". This seems like a funciton I would like to take a look at, but its nowhere to be found in their docs / examples.
What exactly is "a pool of pre-allocated buffers", and what does an implementation look like in C/C++? I can't find much on the internets about this.
I want to assume it is perhaps a 2-dimensional array that is "statically" allocated prior to run-time. Maybe it gets declared like char strBuffer[5][50]; or something - idk.
Solution 1:[1]
What exactly is "a pool of pre-allocated buffers",
A memory buffer is region of memory where objects can potentially be created. Allocation is the act of acquiring a resource and in this case the resource is a memory buffer.
"Pre" prefix implies that the allocation will have happened before prvGetBuffer is called. A "pool" is an abstract description of a collection of things, such as a data structure.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | eerorika |
