kupl_mlock
Locks the memory pages where the buffer is located.
Interface Definition
int kupl_mlock(void *buffer, size_t count);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
buffer |
void* |
Pointer to the memory to be locked |
Input |
count |
size_t |
Size of the memory to be locked |
Input |
Return Value
- Success: KUPL_OK
- Failure: KUPL_ERROR
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <stdio.h> #include <stdlib.h> #include "kupl.h" int main() { int len = 1024; char *data = (char *)malloc(len); if (data == nullptr) { return 0; } kupl_mlock(data, len); kupl_munlock(data, len); free(data); return 0; } |
- The preceding example demonstrates the workflow of allocating memory, locking the memory, unlocking it, and finally freeing the memory.
- The kupl_mlock function locks the memory pointed to by data.
- The kupl_mlock function locks the memory. The availability of an SDMA device in the environment is a prerequisite for the kupl_mlock function to successfully lock the memory.
Parent topic: Memory Management Functions