]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - resources/cpu_aquosa/lib/aqcpu_fra.c
Additional FRA functionality implemented by virtual functions
[frescor/frsh.git] / resources / cpu_aquosa / lib / aqcpu_fra.c
index c9acd50f8d4c70561d4eec0dbae1c5af1fb2867a..0a9b82cfeaa4249e3ddffbca4ecc091190c09248 100644 (file)
@@ -139,6 +139,7 @@ static int aqcpu_cancel_vres(fres_vres_t *vres, void *priv)
  * possible.
  *
  */
+static
 int aqcpu_change_vres(fres_vres_t *vres, void *priv)
 {
        aqcpu_params_t cpu_params;
@@ -163,15 +164,6 @@ int aqcpu_change_vres(fres_vres_t *vres, void *priv)
        return 0;
 }
 
-static struct fres_allocator aqcpu_allocator = {
-       .res_type = FRSH_RT_PROCESSOR,
-       .res_id = 0,  /* CPU ID 0 */
-       .create_vres = aqcpu_create_vres,
-       .cancel_vres = aqcpu_cancel_vres,
-       .change_vres = aqcpu_change_vres,
-       .priv = NULL
-};
-
 /*
  * installed as an exit handler (with 'atexit()') by the initialization
  * code... For now it only calls the cleanup function of the AQuoSA
@@ -181,45 +173,7 @@ static inline void aqcpu_cleanup_wrapper() {
        qres_cleanup();
 }
 
-/*
- * aqcpu_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!!
- */
-int aqcpu_fra_init(void)
-{
-       qos_rv qrv;
-       int rv;
-
-       if ((qrv = qres_init()) != QOS_OK) {
-               return -1;
-       }
-
-       if ((rv = fra_register(&aqcpu_allocator))) {
-               qres_cleanup();
-               return rv;
-       }
-       
-       /* install the cleanup function of th AQuoSA framework as an exit
-        * handler function (quite futile but, for now, it's sufficent) */
-       if (atexit(aqcpu_cleanup_wrapper))
-               return(FRSH_ERR_INTERNAL_ERROR);
-
-       aqcpu_initialized = 1;
-
-       return 0;
-}
-
+static
 int aqcpu_fra_exit()
 {
        qos_rv rv;
@@ -228,8 +182,9 @@ int aqcpu_fra_exit()
        return qos_rv_int(rv);
 }
 
+static
 int fra_CPU_bind_thread
-  (const fres_vres_t *vres,
+  (fres_vres_t *vres,
    const fosa_thread_id_t thread)
 {
        qos_rv  qrv;
@@ -244,6 +199,7 @@ err:
        return -1;
 }
 
+static
 int fra_CPU_unbind_thread(const fosa_thread_id_t thread)
 {
        qos_rv  qrv;
@@ -261,6 +217,7 @@ err:
        return -1;
 }
 
+static
 int fra_CPU_get_usage
   (const fres_vres_t *vres,
    fosa_rel_time_t *spent)
@@ -280,6 +237,7 @@ int fra_CPU_get_usage
        return 0;
 }
 
+static
 int fra_CPU_get_job_usage
   (const fres_vres_t *vres,
    fosa_rel_time_t *spent)
@@ -302,6 +260,7 @@ int fra_CPU_get_job_usage
        return 0;
 }
 
+static
 int fra_CPU_get_remaining_budget
   (const fres_vres_t *vres,
    fosa_rel_time_t *budget)
@@ -321,6 +280,7 @@ int fra_CPU_get_remaining_budget
        return 0;
 }
 
+static
 int fra_CPU_set_spare_bandwidth(fres_vres_t *vres)
 {
        qres_sid_t fake_sid = (qres_sid_t) -1;
@@ -344,6 +304,7 @@ int fra_CPU_set_spare_bandwidth(fres_vres_t *vres)
        return 0;
 }
 
+static
 int fra_CPU_get_desired_budget
   (fres_vres_t *vres,
    frsh_rel_time_t *p_budget_out)
@@ -363,6 +324,7 @@ int fra_CPU_get_desired_budget
        return 0;
 }
 
+static
 int fra_CPU_set_desired_budget
   (fres_vres_t *vres,
    fosa_rel_time_t *p_budget_in)
@@ -385,6 +347,7 @@ int fra_CPU_set_desired_budget
        return 0;
 }
 
+static
 int fra_CPU_get_actual_budget
   (fres_vres_t *vres,
    fosa_rel_time_t *budget)
@@ -404,3 +367,63 @@ int fra_CPU_get_actual_budget
        return 0;
 }
 
+static struct fres_allocator aqcpu_allocator = {
+       .res_type = FRSH_RT_PROCESSOR,
+       .res_id = 0,  /* CPU ID 0 */
+       .create_vres = aqcpu_create_vres,
+       .cancel_vres = aqcpu_cancel_vres,
+       .change_vres = aqcpu_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,
+       
+       .priv = NULL
+};
+
+/*
+ * aqcpu_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!!
+ */
+int aqcpu_fra_init(void)
+{
+       qos_rv qrv;
+       int rv;
+
+       if ((qrv = qres_init()) != QOS_OK) {
+               return -1;
+       }
+
+       if ((rv = fra_register(&aqcpu_allocator))) {
+               qres_cleanup();
+               return rv;
+       }
+       
+       /* install the cleanup function of th AQuoSA framework as an exit
+        * handler function (quite futile but, for now, it's sufficent) */
+       if (atexit(aqcpu_cleanup_wrapper))
+               return(FRSH_ERR_INTERNAL_ERROR);
+
+       aqcpu_initialized = 1;
+
+       return 0;
+}