cc [options] -Kthread file
int aio_memlock(void *avaddr, size_t asize);
An application must lock down the entire area of memory which will be accessed to transfer the data for each request. avaddr specifies the starting address of memory to lock. asize specifies the size of the area in bytes.
Multiple requests to aio_memlock are permitted during a process's lifetime; each call must specify a different address range. This allows processes to do asynchronous I/O over multiple regions of the address space.
Once the memory is locked, it cannot be unlocked or changed. No special privilege is needed for this operation.
The amount of locked memory must be sized carefully. If it is too large, it may adversely effect the overall system performance. If it is too small, it will limit the number of asynchronous I/O requests that can be outstanding at any given point in time.
In addition, the application should make sure that any calls to functions that resize memory, such as brk and sbrk do not involve addresses within the locked area.