c - What does posix_memalign/memalign do -
i'm trying understand functions memalign() , posix_memalign() do. reading available documentation didn't help.
can me understand how works , used for? or, perhaps provide usage example?
i'm trying understand how linux memory works, need write own simple memory pool (low-fragmentation heap).
whereas malloc gives chunk of memory have alignment (the requirement must aligned largest primitive type implementation supports), posix_memalign gives chunk of memory guaranteed have requested alignment.
so result of e.g. posix_memalign(&p, 32, 128) 128-byte chunk of memory start address guaranteed multiple of 32.
this useful various low-level operations (such using sse instructions, or dma), require memory obeys particular alignment.
Comments
Post a Comment