int main(int argc, char **argv){ pTp= tp_create(10, THD_NUM); int i; exit_cnt = 0; pthread_mutex_init(&lock, NULL); tp_init(pTp); srand((int)time(0)); for(i=0; i < THD_NUM; i++){ tp_process_job(pTp, proc_fun, i); } tp_run(pTp); free(pTp); fprintf(stdout, "All jobs done!\r\n"); return 0; }
int main(void) { int stdin_size; char *stdin_mem = read_stdin(&stdin_size); int cpu_count = get_cpu_count(); char output_buffer[7][MAX_OUTPUT]; # define DECLARE_PARAM(o, n) {\ .start = stdin_mem, \ .length = stdin_size, \ .frame = n,\ .output = output_buffer[o],\ .output_size = MAX_OUTPUT } struct print_freqs_param freq_params[2] = { DECLARE_PARAM(0, 1), DECLARE_PARAM(1, 2) }; # undef DECLARE_PARAM # define DECLARE_PARAM(o, s) {\ .start = stdin_mem, \ .length = stdin_size, \ .nuc_seq = s,\ .output = output_buffer[o],\ .output_size = MAX_OUTPUT } struct print_occurences_param occurences_params[5] = { DECLARE_PARAM(2, "GGT"), DECLARE_PARAM(3, "GGTA"), DECLARE_PARAM(4, "GGTATT"), DECLARE_PARAM(5, "GGTATTTTAATT"), DECLARE_PARAM(6, "GGTATTTTAATTTATAGT") }; # undef DECLARE_PARAM struct tp *tp = tp_create(7); for (int i = 0 ; i < 2; i++) { tp_add_job(tp, &print_freqs, &freq_params[i]); } for (int i = 0 ;i < 5; i++) { tp_add_job(tp, &print_occurences, &occurences_params[i]); } tp_run(tp, cpu_count + 1); tp_destroy(tp); for (int i = 0; i < 2; i++) { printf("%s\n", output_buffer[i]); } for (int i = 2; i < 7; i++) { printf("%s", output_buffer[i]); } free(stdin_mem); return 0; }