void * child(void *v) { unsigned long long index_f ; unsigned int index_0 ; sem_wait(&sem); // down() while(chains < table_length){ sem_post(&sem); // up() sem_wait(&sem2); // down() i_index++ ; index_0 = i_index ; sem_post(&sem2); // up() index_f = generate_chain(index_0,num_table); sem_wait(&sem); // down() if(get3(&hash_table,index_f)){ coll++; }else{ put3(&hash_table,index_f,index_0); chains++; } } sem_post(&sem); // up() pthread_exit(0); }
int main(int argc, char ** argv) { chain_options * ops = parse_ops(argc, argv); corpus_root * root = generate_chain(ops); output_chain(root); free_options(ops); free_chain(root); return EXIT_SUCCESS; }
void Euler_14_1() { const uint64_t N = 1000000; uint64_t max_terms = 0, max_start = 0; for( uint64_t i = 1; i <= N; ++i ) { uint64_t terms = generate_chain(i); if( terms > max_terms ) { max_terms = terms; max_start = i; } } cout << max_start << " has " << max_terms << " terms. " << cache_miss << " Cache Misses." << endl; }