内容简介
#include <unistd.h>%uA0#include <sys/mman.h>
int mincore(void *start, size_t%uA0length, unsigned char *vec)
描述
The%uA0mincore() function requests a vector describing which pages of a file are in core and can be read without disk access. The kernel will supply data for%uA0length%uA0bytes following the%uA0startꂭdress. On return, the kernel will have filled%uA0vec%uA0with bytes, of which the least significant bit indicates if a page is core resident. (The other bits are undefined, reserved for possible later use.) Of course this is only a snapshot: pages that are not locked in core can come and go any moment, and the contents of%uA0vec%uA0may be stale already when this call returns.For%uA0mincore() to return successfully,%uA0start%uA0must lie on a page boundary. It is the caller’s responsibility to round up to the nearest page. The%uA0length%uA0parameter need not be a multiple of the page size. The vector%uA0vec%uA0must be large enough to contain (length+PAGE_SIZE-1) / PAGE_SIZE bytes. One may obtain the page size fromgetpagesize(2).
%uA0
返回值
On success,%uA0mincore() returns zero. On error, -1 is returned, and%uA0errno%uA0is set appropriately.错误
EAGAIN%uA0kernel is temporarily out of resources标签 | 描述 |
---|---|
EFAULT | vec%uA0yiibais to an invalid address |
EINVAL | start%uA0is not a multiple of the page size. |
ENOMEM | len%uA0is greater than (TASK_SIZE%uA0-%uA0start). (This could occur if a negative value is specified for%uA0len, since that value will be interpreted as a large unsigned integer.) In Linux 2.6.11 and earlier, the error%uA0EINVAL%uA0was returned for this condition. |
ENOMEM | address%uA0to%uA0address%uA0+%uA0length%uA0contained unmapped memory, or memory not part of a file. |