Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/tests/test7.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 "syscall.h"
0019 
0020 #define ITERATIONS 1000000
0021 #define NUM_THREADS 4
0022 
0023 void
0024 putx (unsigned long l)
0025 {
0026   int i, li;
0027 
0028   for (i = 7; i >= 0; i--)
0029     if ((li = (l >> (i << 2)) & 0x0F) > 9)
0030       putchar ('A' + li - 0x0A);
0031     else
0032       putchar ('0' + li);
0033 }
0034 
0035 void
0036 print (char *s)
0037 {
0038   while (*s) {
0039     putchar (*s++);
0040   }
0041 }
0042 
0043 void
0044 child (int idx)
0045 {
0046   int id, i;
0047   unsigned long ebx, eax = 1;
0048 
0049   for (i=0;i<ITERATIONS;i++) {
0050     if (!(i & 0xFFF)) {
0051       asm volatile ("cpuid":"=b" (ebx), "+a" (eax)::"ecx", "edx");
0052       id = (ebx >> 24) & 0xFF;
0053       putchar (id + '0');
0054     }
0055   }
0056 
0057   _exit (0);
0058 }
0059 
0060 void
0061 _start ()
0062 {
0063   int pid[NUM_THREADS];
0064   int i;
0065 
0066   for (i=0; i<NUM_THREADS; i++) {
0067     if ((pid[i]=fork ()) == 0) {
0068       child (i);
0069     } else putchar ('F');
0070   }
0071   _exit (0);
0072 }
0073 
0074 
0075 /*
0076  * Local Variables:
0077  * indent-tabs-mode: nil
0078  * mode: C
0079  * c-file-style: "gnu"
0080  * c-basic-offset: 2
0081  * End:
0082  */
0083 
0084 /* vi: set et sw=2 sts=2: */