return 0;
}
-
-
-static struct fres_allocator cpucg_allocator = {
- .res_type = FRSH_RT_PROCESSOR,
- .res_id = 0, /* CPU ID 0 */
- .create_vres = cpucg_create_vres,
- .cancel_vres = cpucg_cancel_vres,
- .change_vres = cpucg_change_vres,
- .priv = NULL,
-};
-
-/*
- * cpucg_fra_init()
- *
- * initialize FRSH for the calling process
- *
- * Must be called before starting using the framework.
- * No FRSH call will be successful if this routine is not invoked
- *
- * Note that no BACKGROUND is created and negotiated and the caller thread
- * is bound to no BACKGROUND vres, since no way is provided in order of
- * specifying the contract label and get back the vres id!
- *
- * Note also that, since in this implementation the threads/processes with
- * backgound contracts are left into the default Linux scheduler hands' and
- * not attached to any AQuoSA server, while we're violating what D-AC2v1
- * (pag. 14) says, we achieve exactly the same behaviour!!
- *
- * possible return values:
- * FRSH_NO_ERROR
- * FRSH_ERR_ALREADY_INITIALIZED
- * FRSH_ERR_INTERNAL_ERROR (something, different from the previous case, gone wrong)
- */
-int cpucg_fra_init(void)
-{
- if (cpucg_is_initialized()) {
- return -1;
- }
-
- /* TODO: tets whether cpu controller is mounted */
- //if (cgroup_init() || !cgroup_test_subsys_mounted("cpu")) {
- if (cgroup_init()) {
- return -1;
- }
-
- if (fra_register(&cpucg_allocator)) {
- return -1;
- }
-
- cpucg_initialized = 1;
- return 0;
-}
-
-int cpucg_fra_exit()
-{
- return 0;
-}
-
-int fra_CPU_bind_thread
+static int fra_CPU_bind_thread
(fres_vres_t *vres,
const fosa_thread_id_t thread)
{
return -1;
}
-int fra_CPU_unbind_thread(const fosa_thread_id_t thread)
+static int fra_CPU_unbind_thread(const fosa_thread_id_t thread)
{
int ret;
return -1;
}
-int fra_CPU_get_usage
+static int fra_CPU_get_usage
(const fres_vres_t *vres,
fosa_rel_time_t *spent)
{
- return -1;
+ return FRSH_ERR_NOT_IMPLEMENTED;
}
-int fra_CPU_get_job_usage
+static int fra_CPU_get_job_usage
(const fres_vres_t *vres,
fosa_rel_time_t *spent)
{
- return -1;
+ return FRSH_ERR_NOT_IMPLEMENTED;
}
-int fra_CPU_get_remaining_budget
+static int fra_CPU_get_remaining_budget
(const fres_vres_t *vres,
fosa_rel_time_t *budget)
{
- return -1;
+ return FRSH_ERR_NOT_IMPLEMENTED;
}
-int fra_CPU_get_desired_budget
+static
+int fra_CPU_set_spare_bandwidth(fres_vres_t *vres)
+{
+ return FRSH_ERR_NOT_IMPLEMENTED;
+}
+
+static int fra_CPU_get_desired_budget
(fres_vres_t *vres,
frsh_rel_time_t *p_budget_out)
{
- return -1;
+ return FRSH_ERR_NOT_IMPLEMENTED;
}
-int fra_CPU_set_desired_budget
+static int fra_CPU_set_desired_budget
(fres_vres_t *vres,
fosa_rel_time_t *p_budget_in)
{
- return -1;
+ return FRSH_ERR_NOT_IMPLEMENTED;
}
-int fra_CPU_get_actual_budget
+static int fra_CPU_get_actual_budget
(fres_vres_t *vres,
fosa_rel_time_t *budget)
{
- return -1;
+ return FRSH_ERR_NOT_IMPLEMENTED;
+}
+
+int cpucg_fra_activate(forb_orb orb)
+{
+ if (cpucg_is_initialized()) {
+ return FRSH_ERR_SYSTEM_ALREADY_INITIALIZED;
+ }
+
+ /* TODO: tets whether cpu controller is mounted */
+ //if (cgroup_init() || !cgroup_test_subsys_mounted("cpu")) {
+ if (cgroup_init()) {
+ return FRES_ERR_KERNEL_SUPPORT_MISSING;
+ }
+
+ cpucg_initialized = 1;
+ return 0;
+
+}
+
+static struct fres_allocator cpucg_allocator = {
+ .res_type = FRSH_RT_PROCESSOR,
+ .res_id = 0, /* CPU ID 0 */
+ .create_vres = cpucg_create_vres,
+ .cancel_vres = cpucg_cancel_vres,
+ .change_vres = cpucg_change_vres,
+
+ .bind_thread = fra_CPU_bind_thread,
+ .unbind_thread = fra_CPU_unbind_thread,
+
+ .vres_get_usage = fra_CPU_get_usage,
+ .vres_get_job_usage = fra_CPU_get_job_usage,
+ .vres_get_remaining_budget = fra_CPU_get_remaining_budget,
+
+ .set_spare_bandwidth = fra_CPU_set_spare_bandwidth,
+ .get_desired_budget = fra_CPU_get_desired_budget,
+ .set_desired_budget = fra_CPU_set_desired_budget,
+ .get_actual_budget = fra_CPU_get_actual_budget,
+
+ .activate_callback = cpucg_fra_activate,
+
+ .priv = NULL,
+};
+
+/*
+ * cpucg_fra_init()
+ *
+ * initialize FRSH for the calling process
+ *
+ * Must be called before starting using the framework.
+ * No FRSH call will be successful if this routine is not invoked
+ *
+ * Note that no BACKGROUND is created and negotiated and the caller thread
+ * is bound to no BACKGROUND vres, since no way is provided in order of
+ * specifying the contract label and get back the vres id!
+ *
+ * Note also that, since in this implementation the threads/processes with
+ * backgound contracts are left into the default Linux scheduler hands' and
+ * not attached to any AQuoSA server, while we're violating what D-AC2v1
+ * (pag. 14) says, we achieve exactly the same behaviour!!
+ *
+ * possible return values:
+ * FRSH_NO_ERROR
+ * FRSH_ERR_ALREADY_INITIALIZED
+ * FRSH_ERR_INTERNAL_ERROR (something, different from the previous case, gone wrong)
+ */
+int cpucg_fra_init(void)
+{
+ int rv;
+
+ if ((rv = fra_register(&cpucg_allocator))) {
+ return rv;
+ }
+
+ return 0;
}
+int cpucg_fra_exit()
+{
+ return 0;
+}