int cpuinfo(int cores, int cpufrequency, double cpuarray1[2][4][8]) {
        FILE* fp;
	//        printf("cores: %d cpufrequency: %d inside cpuinfo\n", cores, cpufrequency);
	struct timeval starttime,endtime;
	double te0,te1,te2,te3,te4,te5,te6,te7;
	//printf("cores: %d\n", cores);
	//printf("cpufrequency: %d\n", cpufrequency);
        int count = 0;
        //int coresdetected = 0;
	int user, nice, system, idle, iowait, irq, softirq, totalcycles;
	int user1, nice1, system1, idle1, iowait1, irq1, softirq1;
	int user2, nice2, system2, idle2, iowait2, irq2, softirq2;
	char buf[SIZE];
        //char cpuarray1[SIZE];

	//double cpuarray1[2][cores][8];

	//char cpuarray2[SIZE];
	//char *cpustring;
	char *token;
	char *line;
	char *search = " ";

	int linenum = 0;
        if( ( fp = fopen( "/proc/stat", "r" ) ) == NULL ) {
                fprintf( stderr, "Error opening file.\n" );
                exit( 1 );
        }
	gettimeofday(&starttime, NULL);
	//"$user $nice $system $idle $iowait $irq $softirq"
        while( fgets(buf, sizeof(buf), fp) != NULL)
        {
		if (linenum <= cores && linenum != 0)
		{
			count = 1;
			//printf( "%s", buf );
			line = buf;
			token = strtok(line, search);
			token = strtok(NULL, search);
				cpuarray1[1][linenum][count] = atof(token);
				count++;	
				//user1 = atoi(token);
				//printf( "User1 token: %s\n", token );
				//printf( "User1: %d\n", user1 );
			token = strtok(NULL, search);
                                cpuarray1[1][linenum][count] = atof(token);
				count++;
				//nice1 = atoi(token);
                		//printf( "Nice1 token: %s\n", token );
				//printf( "Nice1: %d\n", nice1 );
			token = strtok(NULL, search);
                                cpuarray1[1][linenum][count] = atof(token);
                                count++;
				//system1 = atoi(token);
                		//printf( "System1 token: %s\n", token );
				//printf( "System1: %d\n", system1 );
			token = strtok(NULL, search);
                                cpuarray1[1][linenum][count] = atof(token);
                                count++;
				//idle1 = atoi(token);
                		//printf( "Idle1 token: %s\n", token );
                                //printf( "Idle1: %d\n", idle1 );
			token = strtok(NULL, search);
                                cpuarray1[1][linenum][count] = atof(token);
                                count++;
				//iowait1 = atoi(token);
                		//printf( "IOwait1 token: %s\n", token );
                                //printf( "IOwait1: %d\n", iowait1 );
			token = strtok(NULL, search);
                                cpuarray1[1][linenum][count] = atof(token);
                                count++;
				//irq1 = atoi(token);
                		//printf( "Irq1 token: %s\n", token );
                                //printf( "Irq1: %d\n", irq1 );
			token = strtok(NULL, search);
                                cpuarray1[1][linenum][count] = atof(token);
                                count++;
				//softirq1 = atoi(token);
                		//printf( "Softirq1 token: %s\n", token );
                                //printf( "Softirq1: %d\n", softirq1 );

			//buf 
		}
		linenum++;			
	}
	fclose( fp );
//	gettimeofday(&endtime, NULL);
	linenum = 0;
	//sleep(1);
	sleep(cpufrequency);
        if( ( fp = fopen( "/proc/stat", "r" ) ) == NULL ) {
		fprintf( stderr, "Error opening file.\n" );
                exit( 1 );
        }
	gettimeofday(&endtime, NULL);
        while( fgets(buf, sizeof(buf), fp) != NULL)
        {
                if (linenum <= cores && linenum != 0)
                {
		//if (linenum == cores)
		//{
			count = 1;
                        //printf( "%s", buf );
                        line = buf;
                        token = strtok(line, search);
                        token = strtok(NULL, search);
                        cpuarray1[2][linenum][count] = atof(token);
                        count++;
				//user2 = atoi(token);
                        	//printf( "User2 token: %s\n", token ); 
                                //printf( "User2: %d\n", user2 );
                        token = strtok(NULL, search);
                        cpuarray1[2][linenum][count] = atof(token);
                        count++;
				//nice2 = atoi(token); 
                        	//printf( "Nice2 token: %s\n", token );
                                //printf( "Nice2: %d\n", nice2 );
                        token = strtok(NULL, search);
                        cpuarray1[2][linenum][count] = atof(token);
                        count++;
				//system2 = atoi(token); 
                        	//printf( "System2 token: %s\n", token );
                                //printf( "System2: %d\n", system2 );
                        token = strtok(NULL, search);
                        cpuarray1[2][linenum][count] = atof(token);
                        count++;
				//idle2 = atoi(token);   
                        	//printf( "Idle2 token: %s\n", token );
                                //printf( "Idle2: %d\n", idle2 );  
                        token = strtok(NULL, search);                        
			cpuarray1[2][linenum][count] = atof(token);
                        count++;
				//iowait2 = atoi(token); 
                        	//printf( "IOwait2 token: %s\n", token );
                                //printf( "IOwait2: %d\n", iowait2 );
                        token = strtok(NULL, search);
                        cpuarray1[2][linenum][count] = atof(token);
                        count++;			
				//irq2 = atoi(token);   
                        	//printf( "Irq2 token: %s\n", token );
                                //printf( "Irq2: %d\n", irq2 );   
                        token = strtok(NULL, search);
                        cpuarray1[2][linenum][count] = atof(token);
                        count++;
				//softirq2 = atoi(token);
                        	//printf( "Softirq2 token: %s\n", token );
                                //printf( "Softirq2: %d\n", softirq2 );

                        //buf
                }
                linenum++;
        }
        fclose( fp );

	te0=((double)(endtime.tv_sec*1000000-starttime.tv_sec*1000000+endtime.tv_usec-starttime.tv_usec))/1000000;

        return (te0);
}

