Messages in this thread | | | Date | Wed, 2 Feb 2000 14:36:39 -0500 (EST) | From | Chuck Lever <> | Subject | Re: Adaptive thread creation by the kernel |
| |
On Wed, 2 Feb 2000, Jamie Lokier wrote: > Chuck Lever wrote: > > this is exactly what an interface like mincore() is designed for. the > > application, or an underlying threads library, can use it to avoid page > > faults that would block all the threads running in an address space. > > You want to read part of one of your mmap()ed files. How do you check > if it's going to fault?
usually like this:
int fd; void * map; char vec[VEC_SIZE];
fd = open("/your/file, O_RDONLY); if (fd == -1) { perror("open"); exit(-1); }
map = mmap(0, SIZE, PROT_READ, MAP_PRIVATE, fd, 0); if (!map) { perror("mmap"); close(fd); exit(-1); }
if (mincore(map, readlength, vec)) perror("mincore");
the vec[] contains a byte for each page you queried. each byte has value "1" if the page is already in memory, otherwise "0".
- Chuck Lever -- corporate: <chuckl@netscape.com> personal: <chucklever@netscape.net> or <cel@monkey.org>
The Linux Scalability project: http://www.citi.umich.edu/projects/linux-scalability/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |