]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - resources/cpu_aquosa/lib/aqcpu_fra.c
Allow specification of the local CPU ID using environment variable
[frescor/frsh.git] / resources / cpu_aquosa / lib / aqcpu_fra.c
index 9ea2048f054902690c9d9357d6e032da2f4ee53c..2c6a9a53a5dc2425e58d512a40574a6c03c57709 100644 (file)
@@ -56,6 +56,7 @@
 
 
 #include <ul_log.h>
+#include <ul_logreg.h>
 #include <fra_generic.h>
 
 #include "aquosa/qres_lib.h"
@@ -64,7 +65,8 @@
 #include "aqcpu_contract.h"
 
 UL_LOG_CUST(ulogd_fra_aqcpu);
-//ul_log_domain_t ulogd_fra_aqcpu = {UL_LOGL_MSG, "fra_aqcpu"};
+ul_log_domain_t ulogd_fra_aqcpu = {UL_LOGL_MSG, "fra_aqcpu"};
+UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(fra_aqcpu_logreg_domains, ulogd_fra_aqcpu);
 
 static int aqcpu_initialized = 0;              /* initialization flag */
 
@@ -97,7 +99,7 @@ static int aqcpu_create_vres(fres_vres_t *vres, void *priv)
                return qos_rv_int(rv);  
        }
        
-       printf("Created AQCPU VRES(sid=%d period=%lld us, budget=%lld us)\n",
+       ul_logdeb("Created AQCPU VRES(sid=%d period=%lld us, budget=%lld us)\n",
                        sid, cpu_params.P, cpu_params.Q);
        if ((vres->priv = malloc(sizeof(qres_sid_t)))) {
                memcpy(vres->priv, &sid, sizeof(qres_sid_t));
@@ -129,7 +131,7 @@ static int aqcpu_cancel_vres(fres_vres_t *vres, void *priv)
        if (qrv != QOS_OK) {
                return qos_rv_int(qrv);
        }
-       printf("Canceled AQCPU VRES(sid=%d)\n",sid);
+       ul_logdeb("Canceled AQCPU VRES(sid=%d)\n",sid);
        free(vres->priv);
 
        return 0;
@@ -162,6 +164,8 @@ int aqcpu_change_vres(fres_vres_t *vres, void *priv)
        
        /* set cpu params */
        qrv = qres_set_params(sid, &cpu_params);
+
+       vres->perceived = vres->new;
        
        ul_logmsg("AQCPU VRES(sid=%d) params changed(period=%lld us,"
                        "budget=%lld us)\n",sid, cpu_params.P,cpu_params.Q);
@@ -178,6 +182,7 @@ static inline void aqcpu_cleanup_wrapper() {
        qres_cleanup();
 }
 
+#if 0
 static
 int aqcpu_fra_exit()
 {
@@ -186,6 +191,7 @@ int aqcpu_fra_exit()
        rv = qres_cleanup();
        return qos_rv_int(rv);
 }
+#endif
 
 static
 int fra_CPU_bind_thread
@@ -300,7 +306,7 @@ int fra_CPU_set_spare_bandwidth(fres_vres_t *vres)
        rv = qsup_reserve_spare(r2bw(cpu_params.Q, cpu_params.P));
        if (rv != QOS_OK) return qos_rv_int(rv);
 
-       printf("Created AQCPU spare (period=%lld us, budget=%lld us)\n",
+       ul_logdeb("Created AQCPU spare (period=%lld us, budget=%lld us)\n",
                        cpu_params.P, cpu_params.Q);
        if ((vres->priv = malloc(sizeof(qres_sid_t)))) {
                memcpy(vres->priv, &fake_sid, sizeof(qres_sid_t));
@@ -384,8 +390,10 @@ int aqcpu_fra_activate(forb_orb orb)
 
        /* 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))
+       if (atexit(aqcpu_cleanup_wrapper)) {
+               qres_cleanup();
                return(FRSH_ERR_INTERNAL_ERROR);
+       }
 
        aqcpu_initialized = 1;
 
@@ -394,7 +402,7 @@ int aqcpu_fra_activate(forb_orb orb)
 
 static struct fres_allocator aqcpu_allocator = {
        .res_type = FRSH_RT_PROCESSOR,
-       .res_id = 0,  /* CPU ID 0 */
+       .res_id = FRSH_CPU_ID_DEFAULT,  /* CPU ID 0 */
        .create_vres = aqcpu_create_vres,
        .cancel_vres = aqcpu_cancel_vres,
        .change_vres = aqcpu_change_vres,
@@ -435,8 +443,9 @@ int aqcpu_fra_init(void)
 {
        int rv;
 
+       aqcpu_allocator.res_id = frsh_get_local_cpu_id();
+               
        if ((rv = fra_register(&aqcpu_allocator))) {
-               qres_cleanup();
                return rv;
        }