/* * Init all parameters */ bool main_init(struct busy_data * busy, int argc, char ** argv) { memset(busy, 0, sizeof(struct busy_data)); busy->total_sequential_time = atof(argv[1]); busy->running_time = atof(argv[2]); busy->sleeping_time = atof(argv[3]); busy->tasks_max = argc - 4; busy->tasks_nice = argv + 4; busy->error_str = "Invalid combination of TOTAL_SEQUENTIAL_TIME RUNNING_TIME SLEEPING_TIME"; if ((busy->total_sequential_time / (busy->running_time + busy->sleeping_time) <= 0) || (busy->total_sequential_time / (busy->running_time + busy->sleeping_time) > 1024*1024*1024)) return false; busy->error_str = "Not enough memory"; busy->times = (double *)malloc(sizeof(double) * (argc - 4)); if (busy->times == NULL) return false; busy->pids = (int *)malloc(sizeof(int) * (argc - 4)); if (busy->pids == NULL) return false; busy->busy_loop = busy_init(busy->running_time); if (busy->busy_loop == NULL) return false; busy->error_str = NULL; return true; }
int main(int argc, char *argv[]) { busy_ctx_t ctx; errno_t res; if (busy_init()) return 0x80; aal_memset(&ctx, 0, sizeof(ctx)); if ((res = busy_ctx_init(&ctx, argc, argv))) { libreiser4_fini(); return res; } res = tests[ctx.testno].handler(&ctx); busy_ctx_fini(&ctx); libreiser4_fini(); return res; }