Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/tests/race.c need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #include <stdio.h>
0019 
0020 int
0021 main ()
0022 {
0023 
0024   int i, child, grandchild;
0025 
0026   if ((child = fork ())) {
0027     /* parent */
0028     for (i = 0; i < 10; i++)
0029       puts ("Parent!");
0030 
0031     waitpid (child);
0032   } else if ((grandchild = fork ())) {
0033     /* child */
0034     for (i = 0; i < 10; i++)
0035       puts ("Child!");
0036 
0037     waitpid (grandchild);
0038   } else
0039     /* grandchild */
0040     for (i = 0; i < 10; i++)
0041       puts ("Grandchild!");
0042 
0043   return 0;
0044 }
0045 
0046 /* 
0047  * Local Variables:
0048  * indent-tabs-mode: nil
0049  * mode: C
0050  * c-file-style: "gnu"
0051  * c-basic-offset: 2
0052  * End: 
0053  */
0054 
0055 /* vi: set et sw=2 sts=2: */