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/myprog8.c (Article 7.5) and /userland/myprog8.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 <libc.h>                                 019 #include <libc.h>
020 #include <stdarg.h>                               020 #include <stdarg.h>
021 #include <debug.h>                                021 #include <debug.h>
022                                                   022 
023                                                   023 
024 /**                                               024 /**
025  * @file myprog8.c                                025  * @file myprog8.c
026  * Make sure that shared mappings (here: anony    026  * Make sure that shared mappings (here: anonymous shared mapping) are
027  * really shared between father and child         027  * really shared between father and child
028  */                                               028  */
029                                                   029 
030 int main()                                        030 int main()
031 {                                                 031 {
032   int i;                                          032   int i;
033   char *zoup;                                     033   char *zoup;
034                                                   034 
035   zoup = mmap((void*)4096, 8*1024*1024,        !! 035   zoup = fakemmap((void*)4096, 8*1024*1024,
036               PROT_READ | PROT_WRITE,          !! 036                   PROT_READ | PROT_WRITE,
037               MAP_SHARED,                      !! 037                   MAP_SHARED,
038               "/dev/zero", 0x123456789012345UL !! 038                   "/dev/zero", 0x123456789012345ULL);
039   bochs_printf("mapped @%x\n", (unsigned)zoup)    039   bochs_printf("mapped @%x\n", (unsigned)zoup);
040                                                   040 
041   switch (fork())                                 041   switch (fork())
042     {                                             042     {
043     case 0:                                       043     case 0:
044       bochs_printf("CHILD 1: %d %d\n", zoup[42    044       bochs_printf("CHILD 1: %d %d\n", zoup[42], zoup[43]);
045       for (i = 0 ; i < 1000000 ; i++)             045       for (i = 0 ; i < 1000000 ; i++)
046         zoup[43] = i / 19;                        046         zoup[43] = i / 19;
047       bochs_printf("CHILD 2: %d %d\n", zoup[42    047       bochs_printf("CHILD 2: %d %d\n", zoup[42], zoup[43]);
048       for (i = 0 ; i < 1000000 ; i++)             048       for (i = 0 ; i < 1000000 ; i++)
049         zoup[43] = i / 19;                        049         zoup[43] = i / 19;
050       bochs_printf("CHILD 3: %d %d\n", zoup[42    050       bochs_printf("CHILD 3: %d %d\n", zoup[42], zoup[43]);
051       break;                                      051       break;
052                                                   052 
053     default:                                      053     default:
054       bochs_printf("FATHER 1: %d %d\n", zoup[4    054       bochs_printf("FATHER 1: %d %d\n", zoup[42], zoup[43]);
055       for (i = 0 ; i < 1000000 ; i++)             055       for (i = 0 ; i < 1000000 ; i++)
056         zoup[42] = i / 17;                        056         zoup[42] = i / 17;
057       bochs_printf("FATHER 2: %d %d\n", zoup[4    057       bochs_printf("FATHER 2: %d %d\n", zoup[42], zoup[43]);
058       break;                                      058       break;
059     }                                             059     }
060                                                   060 
061   return 0;                                       061   return 0;
062 }                                                 062 }
                                                      

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