]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_frescan/frescan_sched_analysis.c
add the modules for the frescan sched analysis with an initial API that we are discus...
[frescor/fna.git] / src_frescan / frescan_sched_analysis.c
1 /*!
2  * @file frescan_sched_analysis.c
3  *
4  * @brief FRESCAN sched analysis queue
5  *
6  * This module contains the scheduling analysis data and functions for the
7  * admission tests and spare capacity distribution of the negotiation layer.
8  * It provides an easy API easy to understand and in the implementation part
9  * it makes call to the general sched analysis module of FRSH which is shared
10  * with the CPU contracts layer in FRSH.
11  *
12  * EXAMPLE of utilization:
13  *
14  * INITIALIZATION
15  * --------------
16  * params.min_prio = 0;
17  * params.max_prio = 16;
18  * params.overhead = ...;
19  * frescan_sa_init(&scenario, &params);
20  *
21  * NEGOTIATE
22  * ---------
23  * fadt_freelist_alloc(&freelist_contracts, &id);
24  * frescan_sa_add_contract(&scenario, &contracts[id], id);
25  * frescan_sa_sched_test(&scenario, &success);
26  *
27  * if (!success) {
28  *      frescan_sa_remove_contract(&scenario, id);
29  * } else {
30  *      frescan_sa_spare_capacity(&scenario);
31  *      vres_id = to_vres(resource_type, resource_id, id);
32  *      create vres runtime structures;
33  *
34  *      for vres_id in active_vres_id {
35  *                frescan_sa_get_final_values(&scenario,
36  *                                            to_index(vres_id),
37  *                                            &final_values);
38  *                update vres runtime structures if necessary;
39  *      }
40  * }
41  *
42  * RENEGOTIATE
43  * -----------
44  * copy old_contract
45  * frescan_sa_update_contract(&scenario, to_index(vres_id), &contract);
46  * frescan_sa_sched_test(&scenario, &success);
47  *
48  * if (!success) {
49  *         frescan_sa_update_contract(&sa_data,
50  *                                    to_index(vres_id),
51  *                                    &old_contract);
52  * } else {
53  *      frescan_sa_spare_capacity(&scenario);
54  *      for vres_id in active_vres_id {
55  *              frescan_sa_get_final_values(&scenario,
56  *                                          to_index(vres_id),
57  *                                          &final_values);
58  *              update vres runtime structures if necessary;
59  *      }
60  * }
61  *
62  * CANCEL
63  * ------
64  * frescan_sa_remove_contract(&scenario, to_index(vres_id));
65  * frescan_sa_spare_capacity(&scenario);
66  *
67  * @version 0.01
68  *
69  * @date 15-Apr-2008
70  *
71  * @author Daniel Sangorrin <daniel.sangorrin@unican.es>
72  *
73  */
74
75 #include "frescan_sched_analysis.h"
76 #undef ERROR
77 #include "frescan_debug.h"
78 // #include "frsh_sa_tools.h"
79
80
81 /**
82  * frescan_sa_init() - init the scenario
83  */
84
85 int frescan_sa_init(frsh_sa_scenario_t *scenario,         // in out
86                     const frsh_sa_init_params_t *params)  // in
87 {
88 //         int ret;
89 //
90 //         ret = frsh_sa_scenario_init(scenario, params);
91 //         return ret;
92         WARNING("not implemented, returning 0\n");
93         return 0;
94 }
95
96 /**
97  * frescan_sa_add_contract() - add a contract to the scenario
98  */
99
100 int frescan_sa_add_contract(frsh_sa_scenario_t    *scenario, // in out
101                             const frsh_contract_t *contract, // in
102                             frsh_vres_index_t     id)        // in
103 {
104 //         int ret;
105 //
106 //         ret = frsh_sa_scenario_add_vres(scenario, contract, id);
107 //         return ret;
108         WARNING("not implemented, returning 0\n");
109         return 0;
110 }
111
112 /**
113  * frescan_sa_update_contract() - update a contract in the scenario
114  */
115
116 int frescan_sa_update_contract(frsh_sa_scenario_t    *scenario, // in out
117                                frsh_vres_index_t     id,        // in
118                                const frsh_contract_t *contract) // in
119 {
120 //         int ret;
121 //
122 //         ret = frsh_sa_scenario_modify_vres(scenario, id, *contract);
123 //         return ret;
124         WARNING("not implemented, returning 0\n");
125         return 0;
126 }
127
128 /**
129  * frescan_sa_remove_contract() - remove a contract from the scenario
130  */
131
132 int frescan_sa_remove_contract(frsh_sa_scenario_t *scenario,  // in out
133                                frsh_vres_index_t id)          // in
134 {
135 //         int ret;
136 //
137 //         ret = frsh_sa_scenario_del_vres(scenario, id);
138 //         return ret;
139         WARNING("not implemented, returning 0\n");
140         return 0;
141 }
142
143 /**
144  * frescan_sa_sched_test() - perform a scheduling test on the scenario
145  */
146
147 int frescan_sa_sched_test(frsh_sa_scenario_t *scenario,  // in out
148                           bool *success)                 // out
149 {
150 //         int ret;
151 //
152 //         ret = frsh_sa_scenario_reset_to_min(scenario, NULL, NULL);
153 //         if (ret != 0) goto error;
154 //
155 //         ret = frsh_sa_assign_priorities(scenario, NULL, NULL, NULL, NULL);
156 //         if (ret != 0) goto error;
157 //
158 //         ret = frsh_sa_ceilings_ok(scenario);
159 //         if (ret != 0) goto error;
160 //
161 //         ret = frsh_sa_calculate_blockings(scenario);
162 //         if (ret != 0) goto error;
163 //
164 //         ret = frsh_sa_sched_test(scenario, success);
165 //         if (ret != 0) goto error;
166 //
167 //         return 0;
168 //
169 // error:
170 //         *success = false;
171 //         return ret;
172         WARNING("not implemented, returning 0\n");
173         return 0;
174 }
175
176 /**
177  * frescan_sa_spare_capacity() - distribute the remaining spare capacity
178  */
179
180 int frescan_sa_spare_capacity(frsh_sa_scenario_t *scenario) // in out
181 {
182 //         int ret;
183 //
184 //         ret = frsh_sa_distribute_spare(scenario,
185 //                                        NULL, NULL, NULL, NULL, NULL, NULL);
186 //         return ret;
187         WARNING("not implemented, returning 0\n");
188         return 0;
189 }
190
191 /**
192  * sa_get_final_values() - get the final values
193  */
194
195 int sa_get_final_values(const frsh_sa_scenario_t *scenario,      // in
196                         frsh_vres_index_t id,                    // in
197                         frescan_sa_final_values_t *final_values) // out
198 {
199 //         final_values->budget   = scenario->sa_vres_alloc[id].c;
200 //         final_values->period   = scenario->sa_vres_alloc[id].t;
201 //         final_values->deadline = scenario->sa_vres_alloc[id].d;
202 //         final_values->priority = scenario->sa_vres_alloc[id].p;
203 //         return 0;
204         WARNING("not implemented, returning 0\n");
205         return 0;
206 }