Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / vm / mmap-unmap.c
1 #include <stdio.h>
2 #include <string.h>
3 #ifdef PINTOS
4 #include <syscall.h>
5 #else
6 #include "posix-compat.h"
7 #endif
8 #include "sample.inc"
9
10 #define ACTUAL ((void *) 0x10000000)
11
12 int
13 main (void) 
14 {
15   int fd;
16   mapid_t map;
17
18   printf ("(mmap-unmap) begin\n");
19
20   fd = open ("sample.txt");
21   if (fd < 0) 
22     {
23       printf ("(mmap-unmap) open() failed\n");
24       return 1;
25     }
26
27   map = mmap (fd, ACTUAL);
28   if (map == MAP_FAILED)
29     {
30       printf ("(mmap-unmap) mmap() failed\n");
31       return 1;
32     }
33
34   munmap (map);
35
36   printf ("(mmap-unmap) FAIL: unmapped memory is readable (%d)\n",
37           *(int *) ACTUAL);
38   
39   /* Done. */
40   printf ("(mmap-unmap) end\n");
41
42   return 0;
43 }