|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||
|
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 035 zoup = fakemmap((void*)4096, 8*1024*1024, 036 PROT_READ | PROT_WRITE, 037 MAP_SHARED, 038 "/dev/zero", 0x123456789012345ULL); 039 bochs_printf("mapped @%x\n", (unsigned)zoup); 040 041 switch (fork()) 042 { 043 case 0: 044 bochs_printf("CHILD 1: %d %d\n", zoup[42], zoup[43]); 045 for (i = 0 ; i < 1000000 ; i++) 046 zoup[43] = i / 19; 047 bochs_printf("CHILD 2: %d %d\n", zoup[42], zoup[43]); 048 for (i = 0 ; i < 1000000 ; i++) 049 zoup[43] = i / 19; 050 bochs_printf("CHILD 3: %d %d\n", zoup[42], zoup[43]); 051 break; 052 053 default: 054 bochs_printf("FATHER 1: %d %d\n", zoup[42], zoup[43]); 055 for (i = 0 ; i < 1000000 ; i++) 056 zoup[42] = i / 17; 057 bochs_printf("FATHER 2: %d %d\n", zoup[42], zoup[43]); 058 break; 059 } 060 061 return 0; 062 }
[ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |