--- /dev/null
+#include "cpu_contract.h"
+
+int get_cpu_vres(contract_t contract, qres_sid_t *vres)
+{
+ return 0;
+}
+
+int set_cpu_vres(contract_t contract, qres_sid_t vres)
+{
+ return 0;
+}
+
+int get_cpu_params(contract_t *contract, cpu_params_t *cpu_params)
+{
+ /* core contract parameters */
+ cpu_params->Q_min = timespec_to_usec(contract->budget_min);
+ cpu_params->P = timespec_to_usec(contract->period_max);
+ /* non-core contract parameters */
+ cpu_params->Q = timespec_to_usec(contract->budget_max);
+ /* AQuoSA specific configuration */
+ cpu_params->flags = 0x000;
+ cpu_params->flags |= QOS_F_PERSISTENT;
+ /* if we're negotiating for the service thread create
+ * a soft server */
+ if (contract == &service_th_contract) {
+ qres_contract.flags |= QOS_F_SOFT;
+ }
+
+ cpu_params->timeout = 0;
+}
+
+int set_cpu_params(contract_t *contract, cpu_params_t *cpu_params)
+{
+ return 0;
+}
-typedef qres_params_t cpu_params_t
-
-int get_cpu_params(contract_t *contract, cpu_params_t *cpu_params)
-{
- /* core contract parameters */
- cpu_params->Q_min = timespec_to_usec(contract->budget_min);
- cpu_params->P = timespec_to_usec(contract->period_max);
- /* non-core contract parameters */
- cpu_params->Q = timespec_to_usec(contract->budget_max);
- /* AQuoSA specific configuration */
- cpu_params->flags = 0x000;
- cpu_params->flags |= QOS_F_PERSISTENT;
- /* if we're negotiating for the service thread create
- * a soft server */
- if (contract == &service_th_contract) {
- qres_contract.flags |= QOS_F_SOFT;
- }
-
- cpu_params->timeout = 0;
-}
int reserve_cpu_contract(contract_t *contract)
{
/* mark contract as negotiated */
- /* get params from contract */
- get_cpu_params(contract, &cpu_params);
- /* create cpu vres */
- qres_status = qres_create_server(&cpu_params, &contract->vres);
- /* create the vres as an AQuoSA resource reservation server */
- if (qres_status == QOS_E_SYSTEM_OVERLOAD)
- return FRSH_ERR_CONTRACT_REJECTED;
- else
- return FRSH_ERR_INTERNAL_ERROR;
- /* qres server was created */
return 0;
}
#include "frsh_scheduler.h"
+#include "cpu_contract.h"
#include "qres_lib.h"
-int aquosa_sched_init()
+int cpu_sched_init()
{
qos_rv rv;
return 0
}
-int aquosa_sched_exit()
+int cpu_vres_create(contract_t contract)
{
- qos_rv rv;
+ cpu_params_t cpu_params;
+ qres_sid_t sid;
- rv = qres_cleanup();
- return qos_rv_int(rv);
+ /* get params from contract */
+ get_cpu_params(contract, &cpu_params);
+ /* create cpu vres */
+ qres_status = qres_create_server(&cpu_params, &sid);
+ /* create the vres as an AQuoSA resource reservation server */
+ if (qres_status == QOS_E_SYSTEM_OVERLOAD)
+ return FRSH_ERR_CONTRACT_REJECTED;
+ else
+ return FRSH_ERR_INTERNAL_ERROR;
+ /* qres server was created */
+ return set_cpu_vres(contract, sid);
}
-int aquosa_create_vres(contract_handle_t contract)
+/*
+ * cpu_vres_cancel(), cancel vres
+ *
+ * The thread bound to the vres are unbound, and so, detached from their
+ * AQuoSA resource reservation servers and continue their execution according
+ * to the standard Linux scheduler policies.
+ *
+ * possible return values:
+ * FRSH_NO_ERROR
+ * FRSH_ERR_BAD_ARGUMENT (invalid_vres)
+ * FRSH_ERR_INTENRAL_ERROR
+ */
+int cpu_vres_cancel(contract_t contract)
{
- // parse contract and create vres by calling
- // qos_rv qres_create_server(qres_params_t *p_params,
- // qres_sid_t *p_sid);
-
+ qres_sid_t sid;
+
+ get_cpu_vres(contract, &sid);
+ if (qres_destroy_server(sid) != QOS_OK)
+ return FRSH_ERR_INTERNAL_ERROR;
+
+ return FRSH_NO_ERR;
+}
+
+/* cpu_vres_change(), change some parameters of a vres
+ *
+ * All is done (of course!) without removing the old vres and creating a new
+ * one, thanks to AQuoSA "change parameters" library API call, but this
+ * actually put an issue in place.
+ * In fact, since that AQuoSA call doesn't deal with _its_ Q_min (budget_min
+ * for in FRSH semantic) parameter all the renegotiation will be accepted but
+ * the new temporal behaviour is not guaranteed!
+ * Obviously this is a bug and should/will be corrected in AQuoSA as soon as
+ * possible.
+ *
+ * possible return values:
+ * FRSH_NO_ERROR
+ * FRSH_ERR_BAD_ARGUMENT (invalid vres or not matching contract types)
+ * FRSH_ERR_INTENRAL_ERROR (something wrong with AQuoSA)
+ */
+int cpu_change_vres(contract_t contract)
+{
+ cpu_params_t cpu_params;
+ qres_sid_t sid;
+
+ get_cpu_vres(contract, &sid);
+ /* get params from contract */
+ get_cpu_params(contract, &cpu_params);
+ /* create cpu vres */
+ qres_status = qres_set_server(&cpu_params, &contract->vres);
+ /* create the vres as an AQuoSA resource reservation server */
+ if (qres_status == QOS_E_SYSTEM_OVERLOAD)
+ return FRSH_ERR_CONTRACT_REJECTED;
+ else
+ return FRSH_ERR_INTERNAL_ERROR;
}
-frsh_sched_ops aquosa_sched_ops = {
+int cpu_sched_exit()
+{
+ qos_rv rv;
+
+ rv = qres_cleanup();
+ return qos_rv_int(rv);
+}
+
+#if 0
+frsh_sched_ops cpu_sched_ops = {
.init = aquosa_init();
.exit = aquosa_exit();
.create_vres = aquosa_create_vres();
*.get_remaining_budget
*/
};
-
+#endif