#include <stdio.h>
#include <ul_log.h>
+#include <ul_logreg.h>
#include <fra_generic.h>
#include "diskbfq_contract.h"
#include "res_disk.h"
-UL_LOG_CUST(ulogd_fra_cpucg);
-//ul_log_domain_t ulogd_fra_cpucg = {UL_LOGL_MSG, "fra_cpucg"};
+UL_LOG_CUST(ulogd_fra_diskbfq);
+ul_log_domain_t ulogd_fra_diskbfq = {UL_LOGL_MSG, "fra_diskbfq"};
+UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(fra_diskbfq_logreg_domains, ulogd_fra_diskbfq);
static int diskbfq_initialized = 0; /* initialization flag */
return -1;
memcpy(vres->priv, &disk_sched->ioprio, sizeof(int));
- printf("Created BFQ VRES (ioprio=%d budget=%ld ms, period=%ld ms)\n",
- disk_sched->ioprio,
- fosa_rel_time_to_msec(basic->budget),
- fosa_rel_time_to_msec(basic->period));
+ ul_logmsg("Created BFQ VRES (ioprio=%d budget=%ld ms, period=%ld ms)\n",
+ disk_sched->ioprio,
+ fosa_rel_time_to_msec(basic->budget),
+ fosa_rel_time_to_msec(basic->period));
return 0;
}
* is automatically released when the thread is unbound
* from the vres itself.
*/
- printf("Canceled DISK VRES (ioprio=%d)\n", *((int*)vres->priv));
+ ul_logmsg("Canceled DISK VRES (ioprio=%d)\n", *((int*)vres->priv));
free(vres->priv);
return 0;
}
+static
int diskbfq_change_vres(fres_vres_t *vres, void *priv)
{
fres_block_disk_sched *disk_sched;
}
disk_sched = fres_contract_get_disk_sched(vres->new);
- printf("Changed BFQ VRES from ioprio=%d to ioprio=%d\n",
- *((int*)vres->priv), (int) disk_sched->ioprio);
+ ul_logmsg("Changed BFQ VRES from ioprio=%d to ioprio=%d\n",
+ *((int*)vres->priv), (int) disk_sched->ioprio);
memcpy(vres->priv, &disk_sched->ioprio, sizeof(int));
return 0;
}
-static struct fres_allocator diskbfq_allocator = {
- .res_type = FRSH_RT_DISK,
- .res_id = 0, /* DISK ID 0 */
- .create_vres = diskbfq_create_vres,
- .cancel_vres = diskbfq_cancel_vres,
- .change_vres = diskbfq_change_vres,
- .priv = NULL
-};
-
-/*
- * diskbfq_fra_init()
- *
- * initialize FRSH for the calling process
- *
- * Must be called before starting using the framework.
- * No FRSH call will be successful if this routine is not invoked
- *
- * Note that no BACKGROUND is created and negotiated and the caller thread
- * is bound to no BACKGROUND vres, since no way is provided in order of
- * specifying the contract label and get back the vres id!
- *
- * Note also that, since in this implementation the threads/processes with
- * backgound contracts are left into the default Linux scheduler hands' and
- * not attached to any AQuoSA server, while we're violating what D-AC2v1
- * (pag. 14) says, we achieve exactly the same behaviour!!
- *
- * possible return values:
- * FRSH_NO_ERROR
- * FRSH_ERR_ALREADY_INITIALIZED
- * FRSH_ERR_INTERNAL_ERROR (something, different from the previous case, gone wrong)
- */
-int diskbfq_fra_init(void)
-{
- if (diskbfq_is_initialized()) {
- return -1;
- }
-
- fres_block_register_disk_sched();
- if (fra_register(&diskbfq_allocator)) {
- return -1;
- }
-
- diskbfq_initialized = 1;
- return 0;
-}
-
int diskbfq_fra_exit()
{
return 0;
}
+static
int fra_DISK_bind_thread
- (const fres_vres_t *vres,
+ (fres_vres_t *vres,
const fosa_thread_id_t thread)
{
fres_block_basic *b;
return 0;
err:
+ ul_logerr("ioprio(): %s\n", strerror(errno));
return -1;
}
+static
int fra_DISK_unbind_thread(const fosa_thread_id_t thread)
{
int ret;
return 0;
}
+static
int fra_DISK_get_usage
(const fres_vres_t *vres,
fosa_rel_time_t *spent)
return -1;
}
+static
int fra_DISK_get_job_usage
(const fres_vres_t *vres,
fosa_rel_time_t *spent)
return -1;
}
+static
int fra_DISK_get_remaining_budget
(const fres_vres_t *vres,
fosa_rel_time_t *budget)
return -1;
}
+static
int fra_DISK_set_spare_bandwidth
(fres_vres_t *vres)
{
return -1;
}
+static
int fra_DISK_get_desired_budget
(fres_vres_t *vres,
frsh_rel_time_t *p_budget_out)
return -1;
}
+static
int fra_DISK_set_desired_budget
(fres_vres_t *vres,
fosa_rel_time_t *p_budget_in)
return -1;
}
+static
int fra_DISK_get_actual_budget
(fres_vres_t *vres,
fosa_rel_time_t *budget)
return -1;
}
+static struct fres_allocator diskbfq_allocator = {
+ .res_type = FRSH_RT_DISK,
+ .res_id = 0, /* DISK ID 0 */
+ .create_vres = diskbfq_create_vres,
+ .cancel_vres = diskbfq_cancel_vres,
+ .change_vres = diskbfq_change_vres,
+
+ .bind_thread = fra_DISK_bind_thread,
+ .unbind_thread = fra_DISK_unbind_thread,
+
+ .vres_get_usage = fra_DISK_get_usage,
+ .vres_get_job_usage = fra_DISK_get_job_usage,
+ .vres_get_remaining_budget = fra_DISK_get_remaining_budget,
+
+ .set_spare_bandwidth = fra_DISK_set_spare_bandwidth,
+ .get_desired_budget = fra_DISK_get_desired_budget,
+ .set_desired_budget = fra_DISK_set_desired_budget,
+ .get_actual_budget = fra_DISK_get_actual_budget,
+
+ .priv = NULL
+};
+
+/*
+ * diskbfq_fra_init()
+ *
+ * initialize FRSH for the calling process
+ *
+ * Must be called before starting using the framework.
+ * No FRSH call will be successful if this routine is not invoked
+ *
+ * Note that no BACKGROUND is created and negotiated and the caller thread
+ * is bound to no BACKGROUND vres, since no way is provided in order of
+ * specifying the contract label and get back the vres id!
+ *
+ * Note also that, since in this implementation the threads/processes with
+ * backgound contracts are left into the default Linux scheduler hands' and
+ * not attached to any AQuoSA server, while we're violating what D-AC2v1
+ * (pag. 14) says, we achieve exactly the same behaviour!!
+ *
+ * possible return values:
+ * FRSH_NO_ERROR
+ * FRSH_ERR_ALREADY_INITIALIZED
+ * FRSH_ERR_INTERNAL_ERROR (something, different from the previous case, gone wrong)
+ */
+int diskbfq_fra_init(void)
+{
+ if (diskbfq_is_initialized()) {
+ return -1;
+ }
+
+ fres_block_register_disk_sched();
+ if (fra_register(&diskbfq_allocator)) {
+ return -1;
+ }
+
+ diskbfq_initialized = 1;
+ return 0;
+}
+