SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

001 /* Copyright (C) 2005 David Decotigny
002 
003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any later version.
007    
008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details.
012    
013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA. 
017 */
018 
019 #include <crt.h>
020 #include <libc.h>
021 #include <stdarg.h>
022 #include <debug.h>
023 
024 /**
025  * @file myprog9.c
026  *
027  * mmap/munmap tests
028  *
029  * We use the temporary syscall 4004 to dump the list of VRs in the
030  * thread's address space
031  */
032 
033 int main(void)
034 {
035   char *zoup;
036   int fd;
037 
038   fd = open("/dev/zero", O_RDWR);
039   zoup = mmap((void*)4096, 8*1024*1024,
040               PROT_READ | PROT_WRITE,
041               MAP_SHARED,
042               fd, 34);
043   close(fd);
044 
045   bochs_printf("mapped @%x\n", (unsigned)zoup);
046 
047   /* Do a fork() here to complicate things */
048   fork();
049   fork();
050   
051   _sos_syscall1(4004, (unsigned)"Initial");
052   munmap(zoup, 10*4096);
053   zoup += 10*4096;
054   _sos_syscall1(4004, (unsigned)"After munmap Low");
055 
056   munmap(zoup-4096, 2*4096);
057   zoup += 4096;
058   _sos_syscall1(4004, (unsigned)"After munmap Before Low");
059 
060   munmap(zoup-4096, 4096);
061   _sos_syscall1(4004, (unsigned)"After munmap Before Low (bis)");
062 
063   munmap(zoup + 1024*1024, 4096);
064   _sos_syscall1(4004, (unsigned)"After munmap middle");
065 
066   munmap(zoup + 1024*1024, 4096);
067   _sos_syscall1(4004, (unsigned)"After munmap middle (bis)");
068 
069   munmap(zoup + 8*1024*1024 - 11*4096 - 4096, 4096);
070   _sos_syscall1(4004, (unsigned)"After munmap High");
071 
072   munmap(zoup + 8*1024*1024 - 11*4096 - 2*4096, 3*4096);
073   _sos_syscall1(4004, (unsigned)"After munmap Past High");
074 
075   munmap((void*)0x40000000, 0x10000000);
076   _sos_syscall1(4004, (unsigned)"After munmap Over everything");
077 
078   munmap((void*)0x40000000, 0x10000000);
079   _sos_syscall1(4004, (unsigned)"After munmap Over everything (bis)");
080 
081   return 0;
082 }

source navigation ] diff markup ] identifier search ] general search ]