]> rtime.felk.cvut.cz Git - frescor/frsh.git/blob - frsh_api/frsh_feedback.c
Remove "Setup" header from tests
[frescor/frsh.git] / frsh_api / frsh_feedback.c
1 /**************************************************************************/
2 /* ---------------------------------------------------------------------- */
3 /* Copyright (C) 2006 - 2008 FRESCOR consortium partners:                 */
4 /*                                                                        */
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                */
11 /*   ENEA                                   SWEDEN                        */
12 /*   Thales Communication S.A.              FRANCE                        */
13 /*   Visual Tools S.A.                      SPAIN                         */
14 /*   Rapita Systems Ltd                     UK                            */
15 /*   Evidence                               ITALY                         */
16 /*                                                                        */
17 /*   See http://www.frescor.org for a link to partners' websites          */
18 /*                                                                        */
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.                                               */
23 /*                                                                        */
24 /*                                                                        */
25 /*  This file is part of FRSH (FRescor ScHeduler)                         */
26 /*                                                                        */
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.                                              */
37 /*                                                                        */
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 /**************************************************************************/
46
47 /**
48  * @file   frsh_feedback.c
49  * @author Dario Faggioli <faggioli@gandalf.sssup.it>
50  * @date   Wed Feb 20 14:53:22 2009
51  * 
52  * @brief  Feedback module of FRSH_FORB framework
53  * 
54  */
55
56 #include <frsh_core.h>
57 #include <fra_generic.h>
58 #include "frsh_forb.h"
59 #include <frsh_resources.h>
60
61 #ifdef CONFIG_AQUOSA
62 #include <aqcpu_res.h>
63 #endif
64 #ifdef CONFIG_CPUCG
65 #include <cpucg_res.h>
66 #endif
67 #ifdef CONFIG_DISKBFQ
68 #include <diskbfq_res.h>
69 #endif
70
71 static frsh_vres_id_t spare_vres;
72
73 int frsh_feedback_get_spare(frsh_contract_t *spare_contract)
74 {
75         return frsh_vres_get_contract(spare_vres, spare_contract);
76 }
77
78 int frsh_feedback_set_spare
79   (const frsh_contract_t *spare_contract)
80 {
81         int ret = 0;
82         frsh_vres_id_t spare_vres;
83
84         if (!spare_contract || !*spare_contract)
85                 return FRSH_ERR_BAD_ARGUMENT;
86
87         ret = frsh_contract_negotiate(spare_contract, &spare_vres);
88         if (ret) return ret;
89
90
91         if (spare_vres->allocator->set_spare_bandwidth) {
92                 ret = spare_vres->allocator->set_spare_bandwidth(spare_vres);
93         } else {
94                 ret = FRSH_ERR_NOT_IMPLEMENTED;
95         }
96
97         return ret;
98 }
99
100 int frsh_feedback_get_desired_budget
101   (frsh_vres_id_t vres_id,
102    frsh_rel_time_t *p_budget_out)
103 {
104         if (vres_id->allocator->get_desired_budget) {
105                 return vres_id->allocator->get_desired_budget(vres_id, p_budget_out);
106         } else {
107                 return FRSH_ERR_NOT_IMPLEMENTED;
108         }
109 }
110
111 int frsh_feedback_set_desired_budget
112   (frsh_vres_id_t vres_id,
113    frsh_rel_time_t *p_budget_in)
114 {
115         if (vres_id->allocator->set_desired_budget) {
116                 return vres_id->allocator->set_desired_budget(vres_id, p_budget_in);
117         } else {
118                 return FRSH_ERR_NOT_IMPLEMENTED;
119         }
120 }
121
122 int frsh_feedback_get_actual_budget
123   (frsh_vres_id_t vres_id,
124    frsh_rel_time_t *budget)
125 {
126         if (vres_id->allocator->get_actual_budget) {
127                 return vres_id->allocator->get_actual_budget(vres_id, budget);
128         } else {
129                 return FRSH_ERR_NOT_IMPLEMENTED;
130         }
131 }
132