Diff markup
001 001
002 002
003 003
004 004
005 005
006 006
007 007
008 008
009 009
010 010
011 011
012 012
013 013
014 014
015 015
016 016
017 017
018 018
019 #include <crt.h> 019 #include <crt.h>
020 #include <libc.h> 020 #include <libc.h>
021 #include <stdarg.h> 021 #include <stdarg.h>
022 #include <debug.h> 022 #include <debug.h>
023 023
024 024
025 !! 025
026 026
027 027
028 028
029 029
030 030
031 031
032 032
033 int main() !! 033 int main(void)
034 { 034 {
035 char *zoup; 035 char *zoup;
>> 036 int fd;
036 037
>> 038 fd = open("/dev/zero", O_RDWR);
037 zoup = mmap((void*)4096, 8*1024*1024, 039 zoup = mmap((void*)4096, 8*1024*1024,
038 PROT_READ | PROT_WRITE, 040 PROT_READ | PROT_WRITE,
039 MAP_SHARED, 041 MAP_SHARED,
040 "/dev/zero", 34); !! 042 fd, 34);
>> 043 close(fd);
>> 044
041 bochs_printf("mapped @%x\n", (unsigned)zoup) 045 bochs_printf("mapped @%x\n", (unsigned)zoup);
042 046
043 047
044 fork(); 048 fork();
045 fork(); 049 fork();
046 050
047 _sos_syscall1(4004, (unsigned)"Initial"); 051 _sos_syscall1(4004, (unsigned)"Initial");
048 munmap(zoup, 10*4096); 052 munmap(zoup, 10*4096);
049 zoup += 10*4096; 053 zoup += 10*4096;
050 _sos_syscall1(4004, (unsigned)"After munmap 054 _sos_syscall1(4004, (unsigned)"After munmap Low");
051 055
052 munmap(zoup-4096, 2*4096); 056 munmap(zoup-4096, 2*4096);
053 zoup += 4096; 057 zoup += 4096;
054 _sos_syscall1(4004, (unsigned)"After munmap 058 _sos_syscall1(4004, (unsigned)"After munmap Before Low");
055 059
056 munmap(zoup-4096, 4096); 060 munmap(zoup-4096, 4096);
057 _sos_syscall1(4004, (unsigned)"After munmap 061 _sos_syscall1(4004, (unsigned)"After munmap Before Low (bis)");
058 062
059 munmap(zoup + 1024*1024, 4096); 063 munmap(zoup + 1024*1024, 4096);
060 _sos_syscall1(4004, (unsigned)"After munmap 064 _sos_syscall1(4004, (unsigned)"After munmap middle");
061 065
062 munmap(zoup + 1024*1024, 4096); 066 munmap(zoup + 1024*1024, 4096);
063 _sos_syscall1(4004, (unsigned)"After munmap 067 _sos_syscall1(4004, (unsigned)"After munmap middle (bis)");
064 068
065 munmap(zoup + 8*1024*1024 - 11*4096 - 4096, 069 munmap(zoup + 8*1024*1024 - 11*4096 - 4096, 4096);
066 _sos_syscall1(4004, (unsigned)"After munmap 070 _sos_syscall1(4004, (unsigned)"After munmap High");
067 071
068 munmap(zoup + 8*1024*1024 - 11*4096 - 2*4096 072 munmap(zoup + 8*1024*1024 - 11*4096 - 2*4096, 3*4096);
069 _sos_syscall1(4004, (unsigned)"After munmap 073 _sos_syscall1(4004, (unsigned)"After munmap Past High");
070 074
071 munmap((void*)0x40000000, 0x10000000); 075 munmap((void*)0x40000000, 0x10000000);
072 _sos_syscall1(4004, (unsigned)"After munmap 076 _sos_syscall1(4004, (unsigned)"After munmap Over everything");
073 077
074 munmap((void*)0x40000000, 0x10000000); 078 munmap((void*)0x40000000, 0x10000000);
075 _sos_syscall1(4004, (unsigned)"After munmap 079 _sos_syscall1(4004, (unsigned)"After munmap Over everything (bis)");
076 080
077 return 0; 081 return 0;
078 } 082 }