Chapter 8: Memory Management: Byte Pools and Block Pools
8.1 Introduction
Recall that we used arrays for the thread stacks in the previous chapter. Although this approach has the advantage of simplicity, it is frequently undesirable and is quite inflexible. This chapter focuses on two ThreadX memory management resources that provide a good deal of flexibility: memory byte pools and memory block pools.
A memory byte pool is a contiguous block of bytes. Within such a pool, byte groups of any size (subject to the total size of the pool) may be used and reused. Memory byte pools are flexible and can be used for thread stacks and other resources that require memory. However, this flexibility leads to some problems, such as fragmentation of the memory byte pool as groups of bytes of varying sizes are used.
A memory block pool is also a contiguous block of bytes, but it is organized into a collection of fixed-size memory blocks. Thus, the amount of memory used or reused from a memory block pool is always the same the size of one fixed-size memory block. There is no fragmentation problem, and allocating and releasing memory blocks is fast. In general, the use of memory block pools is preferred over memory byte pools.
We will study and compare both types of memory management resources in this chapter. We will consider the features, capabilities, pitfalls, and services for each type. We will also create illustrative sample systems using these resources.
8.2 Summary of Memory Byte Pools
A memory byte pool is similar...