1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2007 FRESCOR consortium partners:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politécnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org for a link to partners' websites
18 // FRESCOR project (FP6/2005/IST/5-034026) is funded
19 // in part by the European Union Sixth Framework Programme
20 // The European Union is not liable of any use that may be
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // FSF API web pages: http://marte.unican.es/fsf/docs
32 // http://shark.sssup.it/contrib/first/docs/
34 // This file is part of FRSH API
36 // FRSH API is free software; you can redistribute it and/or modify
37 // it under the terms of the GNU General Public License as published by
38 // the Free Software Foundation; either version 2, or (at your option)
41 // FRSH API is distributed in the hope that it will be useful, but
42 // WITHOUT ANY WARRANTY; without even the implied warranty of
43 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 // General Public License for more details.
46 // You should have received a copy of the GNU General Public License
47 // distributed with FRSH API; see file COPYING. If not, write to the
48 // Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
51 // As a special exception, if you include this header file into source
52 // files to be compiled, this header file does not by itself cause
53 // the resulting executable to be covered by the GNU General Public
54 // License. This exception does not however invalidate any other
55 // reasons why the executable file might be covered by the GNU General
57 // -----------------------------------------------------------------------
58 //frsh_spare_capacity.h
59 //==============================================
60 // ******** ******* ******** ** **
61 // **///// /**////** **////// /** /**
62 // ** /** /** /** /** /**
63 // ******* /******* /********* /**********
64 // **//// /**///** ////////** /**//////**
65 // ** /** //** /** /** /**
66 // ** /** //** ******** /** /**
67 // // // // //////// // //
69 // FRSH(FRescor ScHeduler), pronounced "fresh"
70 //==============================================
71 #ifndef _FRSH_SPARE_CAPACITY_H_
72 #define _FRSH_SPARE_CAPACITY_H_
76 #include "frsh_spare_capacity_types.h"
77 #include "frsh_core_types.h"
78 #include "frsh_core.h"
82 * @file frsh_spare_capacity.h
85 #define FRSH_SPARE_CAPACITY_MODULE_SUPPORTED 1
89 * @file frsh_spare_capacity.h
91 * This file contains the function prototypes for the usage of
92 * spare capacity and dynamic reclamation.
96 * @defgroup sparecapacity Spare Capacity module
98 * This module manages the partition of exceeding capacity at
99 * negotiation time between the vres that express their desire of
100 * optional requirements.
104 * - Allowing to define a range of budget and period instead of
105 * giving WCET values only. This range can be continuous or
108 * - Specifying a fairness measurement to compete with other vres in the
109 * division of the share.
111 * - Specifying a stability_time time for vres that need to have
112 * a assigned capacity remain const during time (they would be
113 * annoyed if their budget or period would change).
115 * There are no specific negotiation calls because the algorithms used
116 * in the core module take already these min-max ranges into account.
118 * An operation is available for applications to ask for a stability
119 * period of a specified length. The framework will then return the
120 * total capacity (execution time budget and virtual resource period)
121 * that the application is guaranteed to receive in this stability
122 * period. The rationale for this service is that jobs may span a
123 * number of virtual resource periods, and need to have a guaranteed
124 * amount of capacity before they can choose a higher quality (longer
125 * execution time) method, when multiple methods are available. Also
126 * applications may require that the capacity provided to them and
127 * hence the quality of results produced remains consistent for a
128 * period of time, so that consistent behaviour is provided for the
129 * user (e.g. multimedia applications).
131 * Requesting a new stability period has the effect of cancelling any
132 * previous one. So a subsequent request for stability up to the same
133 * point in time could return a lower total capacity, if spare capacity
134 * re-allocation is in progress due to the admission of a new
135 * application. If a stability period expires without having explicitly
136 * set a new one, the system may decide to perform a reallocation of
137 * spare resources at that point, or may defer this decision to some
138 * future point in time when it is appropriate. In both cases, a new
139 * stability period will start when the new spare capacity assignment
143 * NOTE: When we talk here about "spare capacity" we mean STATIC extra
144 * capacity at NEGOTIATION TIME. This is the minimum capacity
145 * that the vres will get based on contract negotiation.
146 * This capacity is distributed based on the importance and
147 * weight values and is known before-hand at the beginning of
150 * Besides this extra capacity, there is the DYNAMIC extra
151 * capacity that results at RUN TIME from earlier job endings of
152 * bounded-workload vres. This extra capacity can vary
153 * between each execution period and is not known beforehand.
155 * This extra run-time capacity is assigned if the following 2
156 * conditions are met:
158 * - FRSH_DYNAMIC_RECLAIMING_MODULE_SUPPORTED is defined to 1
159 * (in frsh_dynamic_reclaiming.h).
161 * - There is at least one vres willing to accept this extra
163 * - A FRSH_BOUNDED workload vres with a range of Budget
164 * and Period that can absorb the extra capacity and
165 * whose static_time period is not active.
166 * - An INDETERMINATE workload vres with an active
167 * static_time period.
174 * frsh_contract_set_reclamation_params()
176 * The operation updates the specified contract parameters object by
177 * setting its maximum usable budget, minimum period, granularity,
178 * utilization set, weight, and importance to the specified input
181 * @param contract Contract object
182 * @param stability_time Time in which FRSH guarantees that the
183 * assigned budget and period will remain permanent
184 * even across renegotiations.
185 * @param budget_max The maximum budget that the vres aspires to
187 * @param period_min The minimum period (therefore minimal
188 * interarrival time) that the vres may get for
189 * awakening and replenishment periods.
190 * @param granularity FRSH_CONTINUOUS: Use min-max values,
191 * FRSH_DISCRETE: Use utilization_set.
192 * @param utilization_set A structure of discrete pairs (budget,period)
193 * @param importance non-cooperative urgency indicator. Vres with
194 * higher importance will get all spare capacity des
195 * @param weight cooperative urgency indicator. At equal
196 * importance, spare capacity will be distributed
197 * proportionally to weight levels.
199 * @return 0 if successful \n
200 * FRSH_ERR_BAD_ARGUMENT : if contract is NULL \b or \n
201 * (budget_max value is grater than period_max or smaller than budget_min) \b or \n
202 * (period_min is smaller than budget_mint or larger than period_max) \b or \n
203 * (granularity is neither FRSH_CONTINUOUS nor FRSH_DISCRETE) \b or \n
204 * (granularity is FRSH_CONTINUOUS and
205 * utilization_set is not FRSH_NULL_UTILIZATION_SET) \b or \n
206 * (granularity is FRSH_DISCRETE and
207 * utilization_set is FRSH_NULL_UTILIZATION_SET \b or \n
208 * (utilization_set is not FRSH_NULL_UTILIZATION_SET and
209 * (size of utilization_set less than 2 or greater
210 * than FRSH_MAX_N_UTILIZATION_VALUES) ) \b or \n
211 * (weight < 0) \b or \n
212 * (importance is less than 1 or greater than FRSH_N_IMPORTANCE_LEVELS) \b or \n
213 * (the utilization_set elements are not in increasing utilization order) \b or \n
214 * (the first utilization value in the utilization_set does not match
215 * the pair (budget_min, period_max) of the contract) \b or \n
216 * (the last utilization value in the utilization_set does not match
217 * the pair (budget_max, period_min) of the contract)
220 int frsh_contract_set_reclamation_params(frsh_contract_t *contract,
221 const struct timespec *stability_time,
222 const struct timespec *budget_max,
223 const struct timespec *period_min,
224 frsh_granularity_t granularity,
225 const frsh_utilization_set_t *utilization_set,
230 * frsh_contract_get_reclamation_params()
232 * The operation obtains the sparecapacity contract parameters from
233 * the contract object.
235 * @see frsh_set_contract_reclamation_parameters() for the meaning of
238 * Only the utilization_values of the utilization_set
239 * that are in use, are copied (according to its size field).
242 * @return 0 if successful \n
243 * FRSH_ERR_BAD_ARGUMENT : if contract is NULL
246 int frsh_contract_get_reclamation_params
247 (const frsh_contract_t *contract,
248 struct timespec *stability_time,
249 struct timespec *budget_max,
250 struct timespec *period_min,
251 frsh_granularity_t *granularity,
252 frsh_utilization_set_t *utilization_set,
258 * frsh_vres_get_remaining_stability_time()
260 * This operation returns the stability_time for the vres.
262 * @return 0 if successful \n
263 * FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
264 * capacity is NULL \n
265 * FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
266 * scheduled under FRSH \n
267 * FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not
269 * FRSH_ERR_NOT_CONTRACTED_VRES : if the vres has been cancelled or it
273 int frsh_vres_get_remaining_stability_time(frsh_vres_id_t vres,
274 struct timespec *stability_time);
277 * frsh_resource_get_capacity()
279 * This operation gets the spare capacity currently assigned to an
280 * importance level. The capacity is the number obtained divided by
281 * UINT32_MAX, and it represents the processor or network
284 * @return 0 if successful \n
285 * FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
286 * capacity is NULL \n
287 * FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
288 * scheduled under the FRSH \n
289 * FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not
291 * FRSH_ERR_NOT_CONTRACTED_VRES : if the vres has been cancelled or it
295 int frsh_resource_get_capacity(const frsh_resource_type_t resource_type,
296 const frsh_resource_id_t resource_id,
297 const int importance,
302 * frsh_resource_get_total_weight()
304 * This operation calculates the sum of the weight parameters for all
305 * vres in the system for a certain importance level at a specific
308 * @return 0 if successful \n
309 * FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
310 * total_weight is NULL \n
311 * FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
312 * scheduled under FRSH \n
313 * FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not
315 * FRSH_ERR_NOT_CONTRACTED_VRES : if the vres has been cancelled or it
318 int frsh_resource_get_total_weight
319 (const frsh_resource_type_t resource_type,
320 const frsh_resource_id_t resource_id,
321 const int importance,
322 uint32_t *total_weight);
326 * frsh_vres_decrease_capacity()
328 * This operation is mainly intended for distributed systems but may
329 * also be useful for control application in uniprocessor systems.
331 * It allows the vres to ask for less budget and period that what he
332 * has actually received. The request must be compatible with the
333 * rest of contract parameters.
336 int frsh_vres_decrease_capacity(frsh_vres_id_t vres,
337 struct timespec new_budget,
338 struct timespec new_period);
343 #endif // _FRSH_SPARE_CAPACITY_H_