]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Added basic aquosa cpu ops
authorMartin Molnar <molnam1@fel.cvut.cz>
Sun, 14 Sep 2008 21:15:19 +0000 (23:15 +0200)
committerMartin Molnar <molnam1@fel.cvut.cz>
Sun, 14 Sep 2008 21:15:19 +0000 (23:15 +0200)
frsh_aquosa/mngr/contract_ops.c [new file with mode: 0644]
frsh_aquosa/mngr/main.c [new file with mode: 0644]

diff --git a/frsh_aquosa/mngr/contract_ops.c b/frsh_aquosa/mngr/contract_ops.c
new file mode 100644 (file)
index 0000000..bf16c44
--- /dev/null
@@ -0,0 +1,80 @@
+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)
+{
+       if ((contract->contract_type == FRSH_CT_REGULAR) ||
+               (contract->contract_type == FRSH_CT_DUMMY)){
+               
+               /* call admission test 
+                * if test == OK 
+                * cpu_contract_table(contract);
+                * set_contract_status(contract, RESERVED);
+                * */
+               return 0;
+       }
+       
+       if (contract->contract_type == FRSH_CT_BACKGROUND) {
+               return 0;
+       }
+       
+       return -1;
+}
+
+int commit_cpu_contract(contract_t contract)
+{
+       cpu_params_t cpu_params;
+
+       if ((contract->contract_type == FRSH_CT_REGULAR) ||
+               (contract->contract_type == FRSH_CT_DUMMY)){
+               /* create a FRSH_CT_REGULAR or FRSH_CT_DUMMY */
+
+               /* 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;
+       }
+       
+       if (contract->contract_type == FRSH_CT_BACKGROUND) {
+               return 0;
+       }
+       
+       return -1;
+}
+
+int reserve_contract(contract_t contract)
+{
+       if (contract->resource_type == FRSH_RT_PROCESSOR) {
+               return reserve_cpu_contract(contract);
+       }
+       
+       return -1;
+}
diff --git a/frsh_aquosa/mngr/main.c b/frsh_aquosa/mngr/main.c
new file mode 100644 (file)
index 0000000..72a9248
--- /dev/null
@@ -0,0 +1,27 @@
+
+int aquosa_cpu_init()
+{
+       /* (try to) initialize the AQuoSA Framework */
+       if (qres_init() != QOS_OK || qsup_init() != QOS_OK)
+               FRSH_ERR_RET(FRSH_ERR_INTERNAL_ERROR, 
+                               "can't initialize AQuoSA framework");
+       /* connect to DTM manager */
+       return 0;
+       
+}
+
+int main_loop()
+{
+       
+       
+       return 0;
+
+}
+
+int main()
+{
+       if (aquosa_cpu_init() != 0)
+               exit(1);
+       main_loop();
+       return 0;
+}