]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Added cpu_contract.c which contains special routines for handling cpu contract. Added...
authorMartin <molnar@sum.(none)>
Mon, 15 Sep 2008 13:43:45 +0000 (15:43 +0200)
committerMartin <molnar@sum.(none)>
Mon, 15 Sep 2008 13:43:45 +0000 (15:43 +0200)
frsh_aquosa/cpu_contract.c [new file with mode: 0644]
frsh_aquosa/cpu_contract.h [new file with mode: 0644]
frsh_aquosa/mngr/contract_ops.c
frsh_aquosa/scheduler.c

diff --git a/frsh_aquosa/cpu_contract.c b/frsh_aquosa/cpu_contract.c
new file mode 100644 (file)
index 0000000..e71132e
--- /dev/null
@@ -0,0 +1,35 @@
+#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;
+}
diff --git a/frsh_aquosa/cpu_contract.h b/frsh_aquosa/cpu_contract.h
new file mode 100644 (file)
index 0000000..8601699
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef CPU_CONTRACT_H
+typedef qres_params_t cpu_params_t;
+
+int get_cpu_vres(contract_t contract, qres_sid_t *vres);
+int set_cpu_vres(contract_t contract, qres_sid_t vres);
+
+int get_cpu_params(contract_t *contract, cpu_params_t *cpu_params);
+int set_cpu_params(contract_t *contract, cpu_params_t *cpu_params);
+
+#endif /* CPU_CONTRACT_H */
index bf16c44b223e9a96b022c5e5e2ded1f444b8bd60..12af39b341267c10ca9fef7ad49428384ef63160 100644 (file)
@@ -1,23 +1,3 @@
-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)
 {
@@ -49,16 +29,6 @@ int commit_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;
        }
index c9accf16519e8115e9d2b7aa35a55abeae4471ff..5f9b5eff78b36eb408ec1463c21a0cc6ee950de0 100644 (file)
@@ -1,7 +1,8 @@
 #include "frsh_scheduler.h"
+#include "cpu_contract.h"
 #include "qres_lib.h"
 
-int aquosa_sched_init()
+int cpu_sched_init()
 {
        qos_rv rv;
 
@@ -13,23 +14,90 @@ int aquosa_sched_init()
        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();
@@ -40,4 +108,4 @@ frsh_sched_ops aquosa_sched_ops = {
         *.get_remaining_budget
         */
 };
-
+#endif