1 /**************************************************************************/
2 /* ---------------------------------------------------------------------- */
3 /* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
5 /* Universidad de Cantabria, SPAIN */
6 /* University of York, UK */
7 /* Scuola Superiore Sant'Anna, ITALY */
8 /* Kaiserslautern University, GERMANY */
9 /* Univ. Politécnica Valencia, SPAIN */
10 /* Czech Technical University in Prague, CZECH REPUBLIC */
12 /* Thales Communication S.A. FRANCE */
13 /* Visual Tools S.A. SPAIN */
14 /* Rapita Systems Ltd UK */
17 /* See http://www.frescor.org for a link to partners' websites */
19 /* FRESCOR project (FP6/2005/IST/5-034026) is funded */
20 /* in part by the European Union Sixth Framework Programme */
21 /* The European Union is not liable of any use that may be */
22 /* made of this code. */
25 /* This file is part of FRSH (FRescor ScHeduler) */
27 /* FRSH is free software; you can redistribute it and/or modify it */
28 /* under terms of the GNU General Public License as published by the */
29 /* Free Software Foundation; either version 2, or (at your option) any */
30 /* later version. FRSH is distributed in the hope that it will be */
31 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
32 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
33 /* General Public License for more details. You should have received a */
34 /* copy of the GNU General Public License along with FRSH; see file */
35 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
36 /* Cambridge, MA 02139, USA. */
38 /* As a special exception, including FRSH header files in a file, */
39 /* instantiating FRSH generics or templates, or linking other files */
40 /* with FRSH objects to produce an executable application, does not */
41 /* by itself cause the resulting executable application to be covered */
42 /* by the GNU General Public License. This exception does not */
43 /* however invalidate any other reasons why the executable file might be */
44 /* covered by the GNU Public License. */
45 /**************************************************************************/
49 * @author Dario Faggioli <faggioli@gandalf.sssup.it>
50 * @date Wed Feb 20 14:53:22 2009
52 * @brief Core of FRSH_FORB framework
57 #include <frsh_core.h>
58 #include <fra_generic.h>
59 #include <frsh_resources.h>
61 #include "frsh_forb.h"
64 #include <aqcpu_res.h>
67 #include <cpucg_res.h>
70 #include <diskbfq_res.h>
73 int frsh_vres_get_priority
74 (frsh_vres_id_t vres_id,
77 return FRSH_ERR_NOT_IMPLEMENTED;
80 int frsh_vres_get_contract
81 (const frsh_vres_id_t vres,
82 frsh_contract_t *contract)
84 if (!vres) return FRSH_ERR_BAD_ARGUMENT;
86 /* TODO: Reference counting */
87 *contract = vres->perceived;
92 int frsh_resource_get_vres_from_label
93 (const char *contract_label,
94 const frsh_resource_type_t resource_type,
95 const frsh_resource_id_t resource_id,
98 fres_block_resource *r;
99 fres_block_label *label;
101 if (!contract_label || !vres) {
102 return FRSH_ERR_BAD_ARGUMENT;
104 r = malloc(sizeof(*r));
105 if (!r) return ENOMEM;
106 r->resource_type = resource_type;
107 r->resource_id = resource_id;
109 label = malloc(sizeof(*label));
114 strncpy(label->label, contract_label, sizeof(label->label));
115 label->label[sizeof(label->label)-1] = '\0';
117 *vres = fres_vreses_find_label(label, r);
118 if (*vres) return FRSH_NO_ERROR;
120 return FRSH_ERR_CONTRACT_LABEL_UNKNOWN;
123 int frsh_vres_get_renegotiation_status
124 (const frsh_vres_id_t vres,
125 frsh_renegotiation_status_t *renegotiation_status)
127 return FRSH_ERR_NOT_IMPLEMENTED;
130 int frsh_group_get_status
131 (const frsh_group_id_t group,
132 frsh_renegotiation_status_t *status,
133 frsh_vres_group_t *new_vres)
135 return FRSH_ERR_NOT_IMPLEMENTED;
138 int frsh_vres_get_budget_and_period
139 (const frsh_vres_id_t vres,
140 frsh_rel_time_t *budget,
141 frsh_rel_time_t *period)
143 fres_block_basic *basic;
145 if (!vres) return FRSH_ERR_BAD_ARGUMENT;
147 /* TODO: Reference counting */
148 basic = fres_contract_get_basic(vres->perceived);
149 if (!basic) return FRSH_ERR_NOT_INITIALIZED;
152 *budget = basic->budget;
154 *period = basic->period;
159 int frsh_vres_get_usage
160 (const frsh_vres_id_t vres,
161 frsh_rel_time_t *spent)
163 if (!vres || !spent) {
164 return FRSH_ERR_BAD_ARGUMENT;
166 if (vres->allocator->vres_get_usage) {
167 return vres->allocator->vres_get_usage(vres, spent);
169 return FRSH_ERR_NOT_IMPLEMENTED;
173 int frsh_vres_get_job_usage
174 (const frsh_vres_id_t vres,
175 frsh_rel_time_t *spent)
177 if (!vres || !spent) {
178 return FRSH_ERR_BAD_ARGUMENT;
180 if (vres->allocator->vres_get_job_usage) {
181 return vres->allocator->vres_get_job_usage(vres, spent);
183 return FRSH_ERR_NOT_IMPLEMENTED;
187 int frsh_vres_get_remaining_budget
188 (const frsh_vres_id_t vres,
189 frsh_rel_time_t *budget)
191 if (!vres || !budget) {
192 return FRSH_ERR_BAD_ARGUMENT;
194 if (vres->allocator->vres_get_remaining_budget) {
195 return vres->allocator->vres_get_remaining_budget(vres, budget);
197 return FRSH_ERR_NOT_IMPLEMENTED;