#include <forb.h>
#include <error.h>
#include <errno.h>
+#include <getopt.h>
#include <fres_sa_scenario.h>
#include <stdbool.h>
#include <ul_log.h>
+#include <ul_logreg.h>
#include <stdio.h>
+#include <frsh_core.h>
UL_LOG_CUST(ulogd_frm_cpucg);
-ul_log_domain_t ulogd_fra_fwp = {UL_LOGL_DEB, "frm_cpucg"};
+ul_log_domain_t ulogd_frm_cpucg = {UL_LOGL_DEB, "frm_cpucg"};
/**
* root cgroup`s period
long int period, budget;
long int sum_utilization = 0;
- fres_sa_scenario_for_each_contract(scenario, c) {
+ fres_sa_scenario_for_each_no_cancel_contract(scenario, c) {
fres_block_basic *basic;
char id[40];
fres_contract_id_to_string(id, &c->contract->id, sizeof(id));
sum_utilization+= budget*100/period;
}
- printf("sum_ut= %ld global_ut=%ld \n", sum_utilization, (global_runtime_us*100/global_period_us));
+ printf("sum_ut= %ld global_ut=%ld \n", sum_utilization, ((long)global_runtime_us*100/global_period_us));
*schedulable = (sum_utilization < (global_runtime_us*100/global_period_us));
printf("=> %s\n", (*schedulable)?"schedulable":"not schedulable");
return 0;
}
-static const struct fres_res_manager frm = {
+static struct fres_res_manager frm = {
.res_type = FRSH_RT_PROCESSOR,
.res_id = 0,
+ .name = "cgroup",
.admission_test = cpucg_admtest,
.priv = NULL
};
-int main(int argc, char *argv[])
+static struct option long_opts[] = {
+ { "loglevel", 1, 0, 'l' },
+ { 0, 0, 0, 0}
+};
+
+static void
+usage(void)
+{
+ printf("usage: frm_aqcpu [ options ]\n");
+ printf(" -l, --loglevel <number>|<domain>=<number>,...\n");
+}
+
+int forb_main(forb_orb orb, int argc, char *argv[])
{
- forb_orb orb;
FILE* fd;
int ret;
+ int opt;
+ forb_init_attr_t attr = { .orb_id = "org.frescor.frm.cgcpu" };
+ bool opt_daemon = false;
+ char *opt_pidfile = NULL;
+
+ ul_logreg_domain(&ulogd_frm_cpucg);
+
+ while ((opt = getopt_long(argc, argv, "hl:", &long_opts[0], NULL)) != EOF) {
+ switch (opt) {
+ case 'l':
+ ul_log_domain_arg2levels(optarg);
+ break;
+ case 'h':
+ /*default:*/
+ usage();
+ exit(opt == 'h' ? 0 : 1);
+ }
+ }
- orb = forb_init(&argc, &argv, "frm_cpucg");
- if (!orb) error(1, errno, "forb_init");
if (!(fd = fopen("/proc/sys/kernel/sched_rt_period_us", "r"))) {
error(1, errno, "frm_generic_run");
}
fclose(fd);
+ frm.res_id = frsh_get_local_cpu_id();
ret = frm_register_and_run(orb, &frm);
if (ret != 0) {
error(1, errno, "frm_generic_run");