#include <pthread.h>
#define NUM_THREADS     5
#define _GNU_SOURCE
#include <sys/time.h>
#include <stdio.h>      /* standard I/O                */
#include <stdlib.h>     /* for exit   - 1 occurrence   */
#include <unistd.h>



double ge0,ge1,lsalu;
struct timeval starttime,endtime;


void *PrintHello(void *threadid)
{
  int tid;
   tid = (int)threadid;
   printf("Hello World! It's me, thread #%d!\n", tid);
 
	system("aludir/lsalu");

   pthread_exit(NULL);
}

int main (int argc, char *argv[])
{
   pthread_t threads[NUM_THREADS];
   int rc, t;
	gettimeofday(&starttime, NULL);

   for(t=0; t<NUM_THREADS; t++){
      printf("In main: creating thread %d\n", t);
      rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
     /* if (rc){
         printf("ERROR; return code from pthread_create() is %d\n", rc);
         //exit(1);
      }*/
   }
   	gettimeofday(&endtime, NULL);
   	ge0=((double)(endtime.tv_sec*1000000-starttime.tv_sec*1000000+endtime.tv_usec-starttime.tv_usec))/1000000;
	lsalu = 4/ge0;
        printf("\n\n\tfinished.\n");
        printf("\nLSBENCH Results:");
        printf("\n\tALU index:              %lf\n", lsalu);

   pthread_exit(NULL);
}
