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

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