]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - resources/cpu_aquosa/lib/aqcpu_fra.c
Aquosa is initialized only when it is really needed
[frescor/frsh.git] / resources / cpu_aquosa / lib / aqcpu_fra.c
index c5566b628039dce086bb96b3e7e07014408d4730..9ea2048f054902690c9d9357d6e032da2f4ee53c 100644 (file)
@@ -372,6 +372,26 @@ int fra_CPU_get_actual_budget
        return 0;
 }
 
+int aqcpu_fra_activate(forb_orb orb)
+{
+       qos_rv qrv;
+       if ((qrv = qres_init()) != QOS_OK) {
+               if (qrv == QOS_E_MISSING_COMPONENT) {
+                       return FRES_ERR_KERNEL_SUPPORT_MISSING;
+               } else
+                       return FRSH_ERR_INTERNAL_ERROR;
+       }
+
+       /* 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 struct fres_allocator aqcpu_allocator = {
        .res_type = FRSH_RT_PROCESSOR,
        .res_id = 0,  /* CPU ID 0 */
@@ -390,6 +410,8 @@ static struct fres_allocator aqcpu_allocator = {
        .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 = aqcpu_fra_activate,
        
        .priv = NULL
 };
@@ -411,24 +433,12 @@ static struct fres_allocator aqcpu_allocator = {
  */
 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;
 }