11 void int_handler(int signal)
16 static struct option long_opts[] = {
17 { "loglevel", 1, 0, 'l' },
24 printf("usage: cpu_spare_capacity [ options ]\n");
25 printf(" -l, --loglevel <number>|<domain>=<number>,...\n");
29 #define MSEC(x) { x/1000, (x%1000) * 1000000 }
30 frsh_utilization_set_t utilization_set = {
33 { .budget = MSEC(20), .period = MSEC(100), .deadline = MSEC(100) },
34 { .budget = MSEC(50), .period = MSEC(100), .deadline = MSEC(100) },
38 int main(int argc, char *argv[])
41 frsh_contract_t contract;
42 frsh_rel_time_t zero = fosa_msec_to_rel_time(0);
46 sem_init(&finish, 0, 0);
48 while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
51 ul_log_domain_arg2levels(optarg);
56 exit(opt == 'h' ? 0 : 1);
61 if (ret) PERROR_AND_EXIT(ret, "frsh_init");
63 signal(SIGINT, int_handler);
64 signal(SIGTERM, int_handler);
66 /* Contract negotiation for CPU */
67 ret = frsh_contract_init(&contract);
68 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_init");
70 ret = frsh_contract_set_basic_params(&contract,
71 &utilization_set.utilizations[0].budget,
72 &utilization_set.utilizations[0].period,
75 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params");
77 ret = frsh_contract_set_resource_and_label(&contract ,
78 DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID,
80 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label");
82 ret = frsh_contract_set_reclamation_params(&contract,
84 &utilization_set.utilizations[utilization_set.size-1].budget,
85 &utilization_set.utilizations[utilization_set.size-1].period,
90 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_reclamation_params");
92 ret = frsh_contract_negotiate(&contract, &vres);
93 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
97 ret = frsh_contract_cancel(vres);
98 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_cancel");