void test_simple_list_fill(struct test_list* _head) { START_TEST(); CHECK_TRUE(_is_equal(_get_by_buffer(_head, bar), 42, bar), "%s", _print_result(_get_by_buffer(_head, bar))); CHECK_TRUE(_is_equal(_get_by_value(_head, 23), 23, foo), "%s", _print_result(_get_by_value(_head, 23))); END_TEST(); }
void test_simple_list_remove(struct test_list** __head) { struct test_list* _head; simple_list_remove(__head, _get_by_buffer(*__head, foo)); _head = *__head; START_TEST(); CHECK_TRUE(_is_equal(_head, 42, bar), "%s", _print_result(_head)); CHECK_TRUE(_is_equal(_head->next, 1337, baz), "%s", _print_result(_head->next)); END_TEST(); }
void test_simple_list_find(struct test_list* _head) { char buffer[sizeof bar]; memcpy(buffer, bar, sizeof buffer); START_TEST(); CHECK_TRUE(_is_equal(simple_list_find_memcmp(_head, buffer), 42, bar), "%s", _print_result(simple_list_find_memcmp(_head, buffer))); CHECK_TRUE(_is_equal(simple_list_find_cmp(_head, buffer, (int (*)(void *, void *)) strcmp), 42, bar), "%s", _print_result(simple_list_find_cmp(_head, buffer, (int (*)(void *, void *)) strcmp))); END_TEST(); }
//____________________________________________________________ int print_bench () { static char buff [1024]; FILE * fd; int ret = 0; #ifdef WIN32 sprintf (buff, "midishare-bench.txt"); #else const char* home = getenv("HOME"); if (home) sprintf (buff, "%s/midishare-bench.txt", home); else sprintf (buff, "/midishare-bench.txt"); #endif fd = fopen(buff, "w"); if (fd) { ret = _print_result (fd, kIgnoreValues, gCount, gTable); fclose(fd); } return ret; }
int main(int argc, char *argv[]) { /* there should be 8 arguments provided to the controller */ if (argc < 10) { fprintf(stderr, "usage:./controller slurm_conf_file numController memList " "partitionSize workload zht_config_file zht_memlist num_proc_thread " "controller_index\n"); exit(1); } _initialize(argv); /* controller forks a new thread to receive messages coming to it*/ pthread_t *recv_msg_thread = (pthread_t*) malloc(sizeof(pthread_t)); while (pthread_create(recv_msg_thread, NULL, _recv_msg_proc, NULL)) { fprintf(stderr, "pthread_create error!"); sleep(1); } /* blocked until all the slurmds have already registered*/ while (!ready) { usleep(1); } /* sleep for some time to ensure that all the other * controllers also finished registration */ //sleep(30); /* start to launch jobs */ gettimeofday(&start, 0x0); // get the starting time stamp /* as long as there are still jobs in the queue, * forks a launching thread to launch the first job*/ while (job_queue->queue_length > 0) { if (num_proc_thread < max_proc_thread) { queue_item *job = del_first_queue(job_queue); pthread_t *job_proc_thread = (pthread_t*) malloc(sizeof(pthread_t)); while (pthread_create(job_proc_thread, NULL, _job_proc, (void*) job)) { fprintf(stderr, "pthread_create error!"); sleep(1); } pthread_mutex_lock(&num_proc_thread_mutex); num_proc_thread++; pthread_mutex_unlock(&num_proc_thread_mutex); } else { usleep(1); } } /* blocked until all jobs are finished */ while (num_job_fin + num_job_fail < num_job) { usleep(1); } gettimeofday(&end, 0x0); // get the ending time stamp _print_result(&end, &start); /* sleep some time in case other controllers * need to talk for resource stealing */ sleep(10000); }