From: Michal Sojka Date: Tue, 19 May 2009 11:53:03 +0000 (+0200) Subject: Aquosa is initialized only when it is really needed X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/frsh.git/commitdiff_plain/b9901ee8bc0ce034d7b5d24eeecb987f20fcc1ca Aquosa is initialized only when it is really needed 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. --- diff --git a/fres/contract/fres_error.c b/fres/contract/fres_error.c index e0e297b..2bba1a5 100644 --- a/fres/contract/fres_error.c +++ b/fres/contract/fres_error.c @@ -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; diff --git a/fres/contract/fres_error.h b/fres/contract/fres_error.h index 8040c45..2953d75 100644 --- a/fres/contract/fres_error.h +++ b/fres/contract/fres_error.h @@ -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); diff --git a/resources/cpu_aquosa/lib/aqcpu_fra.c b/resources/cpu_aquosa/lib/aqcpu_fra.c index c5566b6..9ea2048 100644 --- a/resources/cpu_aquosa/lib/aqcpu_fra.c +++ b/resources/cpu_aquosa/lib/aqcpu_fra.c @@ -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; }