From 23f78c21c5101d0ba40c8552d895a5fb72cdd05a Mon Sep 17 00:00:00 2001 From: Matt Mullins Date: Sat, 21 Sep 2013 17:49:27 +0000 Subject: [PATCH] Unmap the pages as we read them. --- mmap_everything.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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); } -- 2.11.0