Linux memalign () __linux

Source: Internet
Author: User

Reproduced in: http://blog.csdn.net/syc0616/article/details/3734941

The DMA bus error on the cell is mostly due to the transfer memory start address that is not 16-bit aligned. Using Memalign, Valloc, (see below), malloc_aligned, the function is cell proprietary, contained in Libmisc.h. The following is transferred from Http://ms.mblogger.cn/lymons/posts/9902.aspx.

In the GNU system, the memory block address returned by malloc or realloc is a multiple of 8 (if it is a 64-bit system, it is a multiple of 16). If you need a larger granularity, use either Memalign or Valloc. These functions are declared in the header file "Stdlib.h".

In the GNU library, you can use the function free to release the memory blocks returned by Memalign and Valloc. It is not available in BSD systems, and the BSD system does not provide a way to free such chunks of memory.

function: void * memalign (size_t boundary, size_t size)
The function Memalign allocates a block of memory with a size specified by size, and an address that is a multiple of the boundary. Parameter boundary must be a power of 2. Function memalign can allocate large blocks of memory and can specify granularity for the returned address.

function: void * VALLOC (size_t size)
Using function Valloc is similar to using function memalign, in the inner implementation of function Valloc, the page size is used as the alignment length and the memalign is used to allocate memory. Its implementation is shown below:
void *
Valloc (size_t size)
{
Return Memalign (GetPageSize (), size);
}

-------------------------------
In the recording of two good cell topic pages:
1.mit cell feature page: http://cag.csail.mit.edu/ps3/cellminiref.shtml
2.IBM Special topic: http://www.ibm.com/developerworks/cn/linux/pa-linuxps3-3/index.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.