]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Aquosa is initialized only when it is really needed
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 19 May 2009 11:53:03 +0000 (13:53 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 19 May 2009 13:36:35 +0000 (15:36 +0200)
Now, the framework can bi compiled with Aquosa supoprt, but test not
requring aquosa can run without aquosa kernel. Aquosa is initialized
just before the first contract for CPU is negotiated.

fres/contract/fres_error.c
fres/contract/fres_error.h
resources/cpu_aquosa/lib/aqcpu_fra.c

index e0e297bfe0ee94790fa4982af7f0952bd5a215e4..2bba1a5f85ddf0f3b750f6a15f6857e637052390 100644 (file)
@@ -100,6 +100,7 @@ int fres_strerror (int error, char *message, size_t size)
                MSG(BLOCK_DUP);
                MSG(NO_RESOURCE_ALLOCATOR);
                MSG(ADMISSION_TEST);
+               MSG(KERNEL_SUPPORT_MISSING);
        }
 
        if (s == NULL) return FRSH_ERR_BAD_ARGUMENT;
index 8040c45c6621246179892d2cfed3b6523cfe1ef0..2953d75912ff670bee11a413c4c5643323673e0b 100644 (file)
@@ -67,6 +67,7 @@ enum fres_error {
        FRES_ERR_BLOCK_DUP,
        FRES_ERR_NO_RESOURCE_ALLOCATOR,
        FRES_ERR_ADMISSION_TEST,
+       FRES_ERR_KERNEL_SUPPORT_MISSING,
 };
 
 int fres_strerror (int error, char *message, size_t size);
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;
 }