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 /**************************************************************************/
48 * @file fres_sa_scenario.h
49 * @author Michal Sojka <sojkam1@fel.cvut.cz>
50 * @date Tue Nov 11 08:37:29 2008
52 * @brief Schedulability analysis data structures declarations.
56 #ifndef FRES_SA_SCENARIO_H
57 #define FRES_SA_SCENARIO_H
59 #include <fres_contract.h>
60 #include <ul_gavlcust.h>
63 * Represenation of a contract in a scenario.
66 struct fres_sa_contract {
67 fres_contract_id_t id; /**< ID of all contract versions stored here. */
69 /** If the contract was already committed, the committed version
70 * is stored here. The contract is moved here from @a reserved
71 * field in fres_resource_manager::commit_contracts(). */
72 struct fres_contract *committed;
74 /** The reserved (and not yet committed) version of the
75 * contract. If a new contract is to be negotiated or an old
76 * one is to be changed, the new version is stored here after
77 * successful admission test. */
78 struct fres_contract *reserved;
80 /** If a new contract is to be negotiated it is stored
81 * here. After sucessfull admission test, the contract is
82 * moved to @a reserved field. If the contract is to be
83 * changed, the admission test can compare the committed and
84 * new version and analyze not only the target state but also
86 struct fres_contract *new;
88 /** Convenience pointer, which has the same value as one of @a
89 * new, @a reserved and @a committed. It is meant for simpler
90 * admission tests, which do not evaluate mode changes and
91 * therefore have no need for comparison of committed and new
92 * version of contact. */
93 struct fres_contract *contract;
96 void *priv; /**< Private data for use by admission test */
101 * Scenario for schedulability analysis.
103 * Basically it represents a set of contracts.
105 * @warning Do not manipulate the tree direcly through this macros,
106 * instead use fres_sa_scenario_add_contract(),
107 * fres_sa_scenario_del_contract() and
108 * fres_sa_scenario_find_contract().
111 struct fres_sa_scenario {
112 gavl_cust_root_field_t contracts; /**< GAVL tree of contracts. */
113 unsigned num_contracts; /**< The number if contracts in scenario */
114 int utilization; /**< Utilization (0-100) used by GUI */
118 GAVL_CUST_NODE_INT_DEC(fres_sa_scenario_contract /* cust_prefix */,
119 struct fres_sa_scenario /* cust_root_t */,
120 struct fres_sa_contract /* cust_item_t */,
121 fres_contract_id_t /* cust_key_t */,
122 contracts /* cust_root_node */,
123 node /* cust_item_node */,
124 id /* cust_item_key */,
125 fres_contract_id_cmp /* cust_cmp_fnc */);
129 * Expands to for-cycle for traversing all contracts in a
130 * scenario. The actual contract is stored in @a contract variable.
133 #define fres_sa_scenario_for_each_contract(scenario, contract) \
134 gavl_cust_for_each(fres_sa_scenario_contract, scenario, contract)
137 struct fres_sa_contract *
138 fres_sa_contract_new(void);
141 fres_sa_contract_destroy(struct fres_sa_contract *sa_contract);
143 struct fres_sa_contract *
144 fres_sa_contract_duplicate(const struct fres_sa_contract *sa_contract);
146 struct fres_sa_scenario *
147 fres_sa_scenario_new(void);
149 void fres_sa_scenario_destroy(struct fres_sa_scenario *scenario);
151 struct fres_sa_scenario *
152 fres_sa_scenario_duplicate(const struct fres_sa_scenario *scenario);
154 int fres_sa_scenario_add_contract(struct fres_sa_scenario *scenario,
155 struct fres_sa_contract *contract);
157 int fres_sa_scenario_del_contract(struct fres_sa_scenario *scenario,
158 struct fres_sa_contract *contract);
160 struct fres_sa_contract *
161 fres_sa_scenario_find_contract(const struct fres_sa_scenario *scenario,
162 fres_contract_id_t *id);