]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blob - frsh_energy_management.h
Update transaction API
[frescor/frsh-include.git] / frsh_energy_management.h
1 // -----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2009 FRESCOR consortium partners:
3 //
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
10 //    ENEA                                   SWEDEN
11 //    Thales Communication S.A.              FRANCE
12 //    Visual Tools S.A.                      SPAIN
13 //    Rapita Systems Ltd                     UK
14 //    Evidence                               ITALY
15 //
16 //    See http://www.frescor.org for a link to partners' websites
17 //
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
21 //        made of this code.
22 //
23 //
24 //  based on previous work (FSF) done in the FIRST project
25 //
26 //   Copyright (C) 2005  Mälardalen University, SWEDEN
27 //                       Scuola Superiore S.Anna, ITALY
28 //                       Universidad de Cantabria, SPAIN
29 //                       University of York, UK
30 //
31 //   FSF API web pages: http://marte.unican.es/fsf/docs
32 //                      http://shark.sssup.it/contrib/first/docs/
33 //
34 //   This file is part of FRSH (FRescor ScHeduler)
35 //
36 //  FRSH is free software; you can redistribute it and/or modify it
37 //  under terms of the GNU General Public License as published by the
38 //  Free Software Foundation; either version 2, or (at your option) any
39 //  later version.  FRSH is distributed in the hope that it will be
40 //  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
41 //  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 //  General Public License for more details. You should have received a
43 //  copy of the GNU General Public License along with FRSH; see file
44 //  COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
45 //  Cambridge, MA 02139, USA.
46 //
47 //  As a special exception, including FRSH header files in a file,
48 //  instantiating FRSH generics or templates, or linking other files
49 //  with FRSH objects to produce an executable application, does not
50 //  by itself cause the resulting executable application to be covered
51 //  by the GNU General Public License. This exception does not
52 //  however invalidate any other reasons why the executable file might be
53 //  covered by the GNU Public License.
54 // -----------------------------------------------------------------------
55 //frsh_energy_management.h
56
57 //==============================================
58 //  ******** *******    ********  **      **
59 //  **///// /**////**  **//////  /**     /**
60 //  **      /**   /** /**        /**     /**
61 //  ******* /*******  /********* /**********
62 //  **////  /**///**  ////////** /**//////**
63 //  **      /**  //**        /** /**     /**
64 //  **      /**   //** ********  /**     /**
65 //  //       //     // ////////   //      // 
66 //
67 // FRSH(FRescor ScHeduler), pronounced "fresh"
68 //==============================================
69
70 #ifndef  _FRSH_ENERGY_MANAGEMENT_H_
71 #define  _FRSH_ENERGY_MANAGEMENT_H_
72
73 #include <time.h>
74
75 #include "frsh_energy_management_types.h"
76 #include "frsh_core_types.h"
77
78 FRSH_CPP_BEGIN_DECLS
79
80 #define FRSH_ENERGY_MANAGEMENT_MODULE_SUPPORTED       1
81
82 /**
83  * @file frsh_energy_management.h
84  **/
85
86 /**
87  * @defgroup energymgmnt Energy Management Module
88  *
89  * This module provides the ability to specify different budgets for
90  * different power levels.
91  *
92  * We model the situation by specifying budget values per power
93  * level.  Thus switching in the power-level would be done by changing
94  * the budget of the vres.  In all cases the period remains the same.
95  *
96  * All global FRSH contract operations (those done with the core
97  * module without specifying the power level) are considered to be
98  * applied to the higest power level, corresponding to a power_level_t
99  * value of 0.
100  *
101  * @note
102  * For all functions that operate on a contract, the resource is
103  * implicitly identified by the contract core parameters resource_type
104  * and resource_id that are either set through the
105  * frsh_contract_set_resource_and_label() function, or implicitly
106  * defined if no such call is made.
107  *
108  * @note
109  * For the power level management operations, only
110  * implementation for resource_type = FRSH_RT_PROCESSOR is mandatory,
111  * if the energy management module is present.
112  *
113  * @{
114  *
115  **/
116
117
118
119 //////////////////////////////////////////////////////////////////////
120 //           CONTRACT SERVICES
121 //////////////////////////////////////////////////////////////////////
122
123
124 /**
125  * frsh_contract_set_min_expiration()
126  * 
127  * This function sets the minimum battery expiration time that the
128  * system must be able to sustain without finishing battery power. A
129  * value of (0,0) would mean that the application does not have such
130  * requirement (this is the default if this parameter is not explicitly
131  * set).
132  **/
133 int frsh_contract_set_min_expiration(frsh_contract_t *contract,
134                                      frsh_rel_time_t min_expiration);
135
136 /**
137  * frsh_contract_get_min_expiration()
138  * 
139  * Get version of the previous function.
140  **/
141 int frsh_contract_get_min_expiration(const frsh_contract_t *contract,
142                                      frsh_rel_time_t *min_expiration);
143
144 /**
145  * frsh_contract_set_min_budget_pow()
146  *
147  * Here we specify the minimum budget value corresponding to a single
148  * power level.
149  *
150  * @param contract              The affected contract.
151  * @param power_level           The power level for which we are specifying the minimum budget.
152  * @param pow_min_budget        The minimum budget requested for the power level.
153  *
154  * @return 0 if no error \n
155  *      FRSH_ERR_BAD_ARGUMENT if power_level is greater than or equal to the value
156  *      returned by frsh_get_power_levels  budget value is not correct.
157  *
158  * @note
159  * If the minimum budget relative to one or more power levels has not been specified, then
160  * the framework may attempt to perform interpolation of the supplied values in
161  * order to infer them, if an accurate model for such operation is available.
162  * Otherwise, the contract is rejected at frsh_negotiate() time.
163  **/
164 int frsh_contract_set_min_budget_pow(frsh_contract_t *contract,
165                                      frsh_power_level_t power_level,
166                                      const frsh_rel_time_t *pow_min_budget);
167
168 /**
169  * frsh_contract_get_min_budget_pow()
170  *
171  * Get version of the previous function.
172  **/
173 int frsh_contract_get_min_budget_pow(const frsh_contract_t *contract,
174                                      frsh_power_level_t power_level,
175                                      frsh_rel_time_t *pow_min_budget);
176
177 /**
178  * frsh_contract_set_max_budget_pow()
179  *
180  * Here we specify the maximum budget for a single power level.
181  *
182  * @param contract              The affected contract object.
183  * @param power_level           The power level for which we are specifying the maximum budget.
184  * @param pow_max_budget        The maximum budget requested for the power level.
185  *
186  * @return 0 if no error \n
187  *        FRSH_ERR_BAD_ARGUMENT if any of the pointers is NULL or the
188  *             budget values don't go in ascending order.
189  *
190  **/
191 int frsh_contract_set_max_budget_pow(frsh_contract_t *contract,
192                                      frsh_power_level_t power_level,
193                                      const frsh_rel_time_t *pow_max_budget);
194
195 /**
196  * frsh_contract_get_max_budget_pow()
197  *
198  * Get version of the previous function.
199  **/
200 int frsh_contract_get_max_budget_pow(const frsh_contract_t *contract,
201                                      frsh_power_level_t power_level,
202                                      frsh_rel_time_t *pow_max_budget);
203
204
205 /**
206  * frsh_contract_set_utilization_pow()
207  *
208  * This function should be used for contracts with a period of
209  * discrete granularity.  Here we specify, for each allowed period,
210  * the budget to be used for each power level.
211  *
212  * @param contract      The affected contract object.
213  * @param power_level   The power level for which we specify budget and period.
214  * @param budget        The budget to be used for the supplied power level and period.
215  * @param period        One of the allowed periods (from the discrete set).
216  * @param period        The deadline used with the associated period (from the discrete set).
217  **/
218 int frsh_contract_set_utilization_pow(frsh_contract_t *contract,
219                                       frsh_power_level_t power_level,
220                                       const frsh_rel_time_t *budget,
221                                       const frsh_rel_time_t *period,
222                                       const frsh_rel_time_t *deadline);
223
224 /**
225  * frsh_contract_get_utilization_pow()
226  *
227  * Get version of the previous function.
228  **/
229 int frsh_contract_get_utilization_pow(const frsh_contract_t *contract,
230                                       frsh_power_level_t power_level,
231                                       frsh_rel_time_t *budget,
232                                       frsh_rel_time_t *period,
233                                       frsh_rel_time_t *deadline);
234
235
236 //////////////////////////////////////////////////////////////////////
237 //           MANAGING THE POWER LEVEL
238 //////////////////////////////////////////////////////////////////////
239
240 /**
241  * frsh_resource_set_power_level()
242  *
243  * Set the power level of the resource identified by the supplied type and id.
244  *
245  * @note
246  * Only implementation for resource_type = FRSH_RT_PROCESSOR is mandatory,
247  * if the energy management module is present.
248  **/
249 int frsh_resource_set_power_level(frsh_resource_type_t resource_type,
250                                   frsh_resource_id_t resource_id,
251                                   frsh_power_level_t power_level);
252
253 /**
254  * frsh_resource_get_power_level()
255  *
256  * Get version of the previous function.
257  **/
258 int frsh_resource_get_power_level(frsh_resource_type_t resource_type,
259                                   frsh_resource_id_t resource_id,
260                                   frsh_power_level_t *power_level);
261
262 /**
263  * frsh_resource_get_speed()
264  *
265  * Get in speed_ratio representative value for the speed of the specified
266  * resource, with respect to the maximum possible speed for such resource.
267  *
268  * @note
269  * Only implementation for resource_type = FRSH_RT_PROCESSOR is mandatory,
270  * if the energy management module is present.
271  **/
272 int frsh_resource_get_speed(frsh_resource_type_t resource_type,
273                             frsh_resource_id_t resource_id,
274                             frsh_power_level_t power_level,
275                             double *speed_ratio);
276
277 /**
278  * frsh_resource_get_num_power_levels()
279  *
280  * Get the number of power levels available for the resource identified
281  * by the supplied type and id.
282  *
283  * @note
284  * The power levels that may be used, for the identified resource,
285  * in other functions through a power_level_t type, range from 0
286  * to the value returned by this function minus 1.
287  *
288  * @note
289  * The power level 0 identifies the configuration with the maximum
290  * performance (and energy consumption) for the resource.
291  *
292  * @note
293  * Only implementation for resource_type = FRSH_RT_PROCESSOR is mandatory,
294  * if the energy management module is present.
295  */
296 int frsh_resource_get_num_power_levels(frsh_resource_type_t resource_type,
297                                        frsh_resource_id_t resource_id,
298                                        int *num_power_levels);
299
300 //////////////////////////////////////////////////////////////////////
301 //           BATTERY EXPIRATION AND MANAGING POWER LEVELS
302 //////////////////////////////////////////////////////////////////////
303
304 /* /\** IS THIS NEEDED AT ALL ? I GUESS NOT - COMMENTED */
305 /*  * frsh_resource_get_battery_expiration() */
306 /*  * */
307 /*  * Get the foreseen expiration time of the battery for the resource */
308 /*  * identified by the supplied type and id. */
309 /*  * */
310 /* int frsh_battery_get_expiration(frsh_resource_type_t resource_type, */
311 /*                               frsh_resource_id_t resource_id, */
312 /*                               frsh_rel_time_t *expiration); */
313
314 /**
315  * frsh_battery_get_expiration()
316  *
317  * Get the foreseen expiration time of the system battery(ies).
318  **/
319 int frsh_battery_get_expiration(frsh_abs_time_t *expiration);
320
321 /*@}*/
322
323 FRSH_CPP_END_DECLS
324
325 #endif      /* _FRSH_ENERGY_MANAGEMENT_H_ */