MYNEWT-162: documentation for OS_MEMPOOL_SIZE
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/9cc22d92 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/9cc22d92 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/9cc22d92 Branch: refs/heads/os_mempool Commit: 9cc22d92ecc8b8aff45b327e071bb79b72557c49 Parents: 6afd139 Author: wes3 <w...@micosa.io> Authored: Wed Feb 24 22:23:46 2016 -0800 Committer: wes3 <w...@micosa.io> Committed: Wed Feb 24 22:23:46 2016 -0800 ---------------------------------------------------------------------- docs/os/core_os/memory_pool/OS_MEMPOOL_SIZE.md | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9cc22d92/docs/os/core_os/memory_pool/OS_MEMPOOL_SIZE.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/memory_pool/OS_MEMPOOL_SIZE.md b/docs/os/core_os/memory_pool/OS_MEMPOOL_SIZE.md new file mode 100644 index 0000000..8c52608 --- /dev/null +++ b/docs/os/core_os/memory_pool/OS_MEMPOOL_SIZE.md @@ -0,0 +1,41 @@ +## <font color="#F2853F" style="font-size:24pt">OS_MEMPOOL_SIZE</font> + +```no-highlight +OS_MEMPOOL_SIZE(n,blksize) +``` + +Calculates the number of os_membuf_t elements used by *n* blocks of size *blksize* bytes. + +Note that os_membuf_t is used so that memory blocks are aligned on OS_ALIGNMENT boundaries. + +The *blksize* variable is the minimum number of bytes required for each block; the actual block size is padded so that each block is aligned on OS_ALIGNMENT boundaries. + +<br> +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| n | Number of elements | +| blksize | Size of an element is number of bytes | + +#### Returned values +The number of os_membuf_t elements used by the memory pool. Note that os_membuf_t is defined to be a unsigned, 32-bit integer when OS_ALIGNMENT is 4 and an unsigned, 64-bit integer when OS_ALIGNMENT is 8. + +<br> +#### Notes +OS_MEMPOOL_SIZE is a macro and not a function. + +<br> +#### Example + +Here we define a memory buffer to be used by a memory pool using OS_MEMPOOL_SIZE + +```no-highlight +#define NUM_BLOCKS (16) +#define BLOCK_SIZE (32) + +os_membuf_t my_pool_memory[OS_MEMPOOL_SIZE(NUM_BLOCKS, BLOCK_SIZE)] +``` + +--------------------- +