#include <ul_log.h>
+#include <ul_logreg.h>
#include <fra_generic.h>
#include "aquosa/qres_lib.h"
#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 */
qres_sid_t sid;
qos_rv rv;
+ if (vres->priv) {
+ errno = -EINVAL;
+ return -1;
+ }
+
/* get aqcpu params from contract */
get_aqcpu_params(vres, &cpu_params);
/* create cpu vres */
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));
/*
* aqcpu_cancel_vres(), cancels vres
*
- * The thread bound to the vres are unbound, and so, detached from their
- * AQuoSA resource reservation servers and continue their execution according
+ * The threads bound to the vres are unbound, and so, detached from their
+ * AQuoSA resource reservation server and continue their execution according
* to the standard Linux scheduler policies.
*
*/
qres_sid_t sid;
qos_rv qrv;
- if (vres->priv) {
+ if (!vres->priv) {
errno = -EINVAL;
return -1;
}
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;
qres_sid_t sid;
qos_rv qrv;
- if (vres->priv) {
+ if (!vres->priv) {
errno = -EINVAL;
return -1;
}
/* 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);
qres_cleanup();
}
+#if 0
static
int aqcpu_fra_exit()
{
rv = qres_cleanup();
return qos_rv_int(rv);
}
+#endif
static
int fra_CPU_bind_thread
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));
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)) {
+ qres_cleanup();
+ 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 */
+ .res_id = FRSH_CPU_ID_DEFAULT, /* CPU ID 0 */
.create_vres = aqcpu_create_vres,
.cancel_vres = aqcpu_cancel_vres,
.change_vres = aqcpu_change_vres,
.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
};
*/
int aqcpu_fra_init(void)
{
- qos_rv qrv;
int rv;
- if ((qrv = qres_init()) != QOS_OK) {
- return -1;
- }
-
+ aqcpu_allocator.res_id = frsh_get_local_cpu_id();
+
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;
}