/*
 * File:	dummy_test_load.c
 * Author:	c.mills@auckland.ac.nz (Clark Mills)
 * Date:	Thu Mar  6 07:14:39 NZDT 2003
 * Project:	Mosix Cluster, Maths Dept.
 * Comments:	Create multi threaded dummy work load for benchmarking.
 * Build:	make dummy_test_load
 * Run:		time ./dummy_test_load
 */

#include <string.h>
#include <sys/wait.h>
#include <time.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

main()
{
  time_t tm;
  unsigned long j;
  double k;
  FILE *fp;
  int n;
//  char *p;

//  p = malloc( 1000000000 );
//  memset( p, '\0', 1000000000 );

				// Logfile for results of run
  fp = fopen( "dummy_test_load.log", "a" );

  for (j=0; j<27; j++)		// Create another 27 identical processes
    if (!fork())		// (14 processors * ht = 28 virtual CPUs)
      break;

  for (n=0; n<10; n++)		// Dummy workload 10x each process
  {
    time( &tm );			// Start time for this iteration

    for (j=0; j<240000000; j++)		// Dummy workload
      k += j;

					// Output results for this iteration
    fprintf( fp, "PID=%u\tIteration=%u\t%lf\tTook %u seconds\n",
      getpid(), n, k, time( NULL ) - tm );

    fflush( fp );
  }
  exit( 0 );

}

