From: Matt Mullins Date: Sat, 21 Sep 2013 17:49:27 +0000 (+0000) Subject: Unmap the pages as we read them. X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=23f78c21c5101d0ba40c8552d895a5fb72cdd05a;p=mmap_everything.git Unmap the pages as we read them. --- diff --git a/mmap_everything.c b/mmap_everything.c index ae1d529..d2db52d 100644 --- a/mmap_everything.c +++ b/mmap_everything.c @@ -45,8 +45,9 @@ int main() { } srand48(time(NULL)); - int *pi; + int data; do { + int *pi; uint32_t lower = lrand48(); uint32_t upper = lrand48(); @@ -56,6 +57,12 @@ int main() { pi = (void*)(pvalue); printf("*%p = ", (void*)pi); - printf("%x\n", *pi); - } while (*pi == 0); + fflush(stdout); + data = *pi; + printf("%x\n", data); + + if (munmap((void*)(pvalue & ~0xFFFL), 4096)) { + perror("munmap"); + } + } while (data == 0); }