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 ]

Diff markup

Differences between /userland/myprog9.c (Article 7.5) and /userland/myprog9.c (Article 8)


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

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