--- /dev/null
+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;
+}