]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
CPUCG allocator got in par with other allocators a little more.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 26 May 2009 00:10:47 +0000 (02:10 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 26 May 2009 00:10:47 +0000 (02:10 +0200)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
resources/cpucg/lib/cpucg_fra.c
resources/cpucg/lib/cpucg_res.h

index 82d46e466a8c0dcdd0d5422f9b0da42b8431d476..5ca773369c8ae466b1d1021b74d515903518b1c9 100644 (file)
@@ -180,65 +180,7 @@ int cpucg_change_vres(fres_vres_t *vres, void *priv)
        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)
 {
@@ -270,7 +212,7 @@ err:
        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;
 
@@ -302,45 +244,129 @@ err:
        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;
+}
index 5aa333f935db7d0111642e6b809bb7511f5d4183..67fa2fd8cbd4637d3d1e430dc147a481823d56cf 100644 (file)
@@ -8,24 +8,5 @@
 
 int cpucg_fra_init(void);
 
-int fra_CPU_bind_thread (fres_vres_t *vres,
-                         const fosa_thread_id_t thread);
-
-int fra_CPU_unbind_thread(fosa_thread_id_t thread);
-
-int fra_CPU_get_usage(const fres_vres_t *vres,
-                      fosa_rel_time_t *spent);
-int fra_CPU_get_job_usage(const fres_vres_t *vres,
-                          fosa_rel_time_t *spent);
-int fra_CPU_get_remaining_budget(const fres_vres_t *vres,
-                                 fosa_rel_time_t *budget);
-
-int fra_CPU_get_desired_budget(fres_vres_t *vres,
-                               frsh_rel_time_t *p_budget_out);
-int fra_CPU_set_desired_budget(fres_vres_t *vres,
-                              fosa_rel_time_t *p_budget_in);
-int fra_CPU_get_actual_budget(fres_vres_t *vres,
-                             fosa_rel_time_t *budget);
-
 #endif /* CPUCG_RES_H */