int main(int argc, char* argv[]) {

	if (argc != 2){ 
		fprintf(stderr, "please provide a command line argument for thread count less than %d\n", MAX_THREADS);
   		exit(0);
	}

	thread_count = strtol(argv[1], NULL, 10);  
   	if (thread_count <= 0 || thread_count > MAX_THREADS){ 
		fprintf(stderr, "please provide a command line argument for thread count less than %d\n", MAX_THREADS);
   		exit(0);
	}
	
	int i=0;
	//Inserting elements to linked-list
    for(;i<n;i++){   
        int r = rand()%65536;
        if(!Insert(r)){
            i--;
        }
    }
 
	pthread_t* thread_handles;

	thread_handles = malloc(thread_count*sizeof(pthread_t));
	pthread_mutex_init(&mutex, NULL);
	pthread_mutex_init(&count_mutex, NULL);

	start_time = clock();
	for (i = 0; i < thread_count; i++)
		pthread_create(&thread_handles[i], NULL, Thread_Function, (void*) i);

	for (i = 0; i < thread_count; i++)
		pthread_join(thread_handles[i], NULL);
   
	finish_time = clock();
	time_elapsed = (finish_time - start_time)/CLOCKS_PER_SEC;
    //printf("Time Elapsed  = %.10f seconds\n", time_elapsed);
	printf("%.10f\n", time_elapsed);
    
	Clear_Memory();
	pthread_mutex_destroy(&mutex);
	pthread_mutex_destroy(&count_mutex);
	free(thread_handles);
	return 0;
}
Exemplo n.º 2
0
void Game_Engine::Settings_Apply_Changes()
{
	Clear_Memory();
	Allocate_Memory();
	Game_Reset();
}
Exemplo n.º 3
0
void Game_Engine::Settings_Reset()
{
	Clear_Memory();
	Initialize();
}
Exemplo n.º 4
0
//destructor
Game_EEG::~Game_EEG(void)
{
	//release memory space
	Clear_Memory();
}