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 /**************************************************************************/
49 * @author Michal Sojka <sojkam1@fel.cvut.cz>
50 * @date Tue Nov 11 08:34:09 2008
52 * @brief Generic resource manager declarations
60 #include <fres_sa_scenario.h>
61 #include <fra_generic.h>
64 extern ul_log_domain_t ulogd_frm_generic;
67 * Admission test for a given resource.
69 * The admission test is called from
70 * fres::resource_manager::reserve_contracts() to evaluate
71 * schedulability of the scenario given as a parameter. It can use
72 * fres_sa_scenario_for_each_contract() macro to traverse through all
73 * the contracts in the scenario. No constract should be added or
74 * deleted, but any data (blocks) can be added to the contracts. If
75 * the scenario is schedulable, the contracts (with possibly added
76 * data) are sent to resource scheduler, which can use this additional
77 * data as parameters for VRes creation.
79 * During the admission test, the contracts in scenariou can be
80 * processed in any way as the test desires. The contract to be tested
81 * is stored in fres_sa_contract::contract. If the test want to know
82 * about the state of the contract it can compare the value of
83 * fres_sa_contract::contract with fres_sa_contract::new,
84 * fres_sa_contract::reserved and fres_sa_contract::commited.
86 * @param[in] scenario Scenario to check its schedulability.
87 * @param[in] priv Pointer to private data, registered by frm_generic_run().
88 * @param[out] schedulable Set to true if the scenario is schedulable, to false otherwise.
90 * @return Zero on success, non-zero error code on return.
92 typedef int (*frm_adm_test_fnc_t)(struct fres_sa_scenario *scenario, void *priv, bool *schedulable);
94 /** Description of a resource manager */
95 struct fres_res_manager {
96 frsh_resource_type_t res_type;
97 frsh_resource_id_t res_id;
98 frm_adm_test_fnc_t admission_test; /**< Pointer to the admission test routine */
99 void *priv; /**< Any data to be passed to admission test */
103 struct fres_sa_scenario *scenario;
104 const struct fres_res_manager *desc;
107 fres_resource_manager frm_register(forb_orb orb, struct frm_data *frm_data,
108 forb_executor_t *executor,
109 const struct fres_res_manager *desc);
110 int frm_register_and_run(forb_orb orb,
111 const struct fres_res_manager *desc);