]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blob - frsh_memory_management.h
Adding frsh_usec_to_rel_time()
[frescor/frsh-include.git] / frsh_memory_management.h
1 // -----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2007 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 API
35 //
36 //  FRSH API is free software; you can  redistribute it and/or  modify
37 //  it under the terms of  the GNU General Public License as published by
38 //  the Free Software Foundation;  either  version 2, or (at  your option)
39 //  any later version.
40 //
41 //  FRSH API  is distributed  in  the hope  that  it  will  be useful,  but
42 //  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
43 //  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
44 //  General Public License for more details.
45 //
46 //  You should have  received a  copy of  the  GNU  General Public License
47 //  distributed  with  FRSH API;  see file COPYING.   If not,  write to the
48 //  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
49 //  02111-1307, USA.
50 //
51 //  As a special exception, if you include this header file into source
52 //  files to be compiled, this header file does not by itself cause
53 //  the resulting executable to be covered by the GNU General Public
54 //  License.  This exception does not however invalidate any other
55 //  reasons why the executable file might be covered by the GNU General
56 //  Public License.
57 // -----------------------------------------------------------------------
58 //frsh_memory_management.h
59
60 //==============================================
61 //  ******** *******    ********  **      **
62 //  **///// /**////**  **//////  /**     /**
63 //  **      /**   /** /**        /**     /**
64 //  ******* /*******  /********* /**********
65 //  **////  /**///**  ////////** /**//////**
66 //  **      /**  //**        /** /**     /**
67 //  **      /**   //** ********  /**     /**
68 //  //       //     // ////////   //      // 
69 //
70 // FRSH(FRescor ScHeduler), pronounced "fresh"
71 //==============================================
72
73 #ifndef _FRSH_MEMORY_MANAGEMENT_H_
74 #define _FRSH_MEMORY_MANAGEMENT_H_
75
76 #include "frsh_core_types.h"
77
78
79 #define FRSH_MEMORY_MANAGEMENT_SUPPORTED 1
80
81 FRSH_CPP_BEGIN_DECLS
82
83 /**
84  * @file frsh_memory_management.h
85  **/
86
87 /**
88  * @defgroup memmanagement Memory Management
89  *
90  * This module provides the types and the functions to add memory
91  * management support to FRSH contracts.
92  *
93  * @{
94  *
95  **/
96
97 /**
98  * frsh_contract_set_min_memory()
99  *
100  * This function specifies in the contract the minimum
101  * memory needed by the application.
102  *
103  * @param[in] min_memory  Minimum needed memory in bytes.
104  * @param[in] max_memory  Maximum needed memory in bytes.
105  * @param  contract   Contract, in-out argument.
106  *
107  * @return 0 if no error \n
108  *     FRSH_ERR_BAD_ARGUMENT if min_memory <0
109  * 
110  **/
111 int frsh_contract_set_min_memory(size_t min_memory,
112                                   frsh_contract_t *contract);
113
114 /**
115  * frsh_contract_get_min_memory()
116  *
117  * This function gets the minimum memory parameter from the contract.
118  *
119  * @param[in] contract Contract object
120  * @param[out] min_memory  Placeholder for the minimum required
121  *                         memory.
122  *
123  * @return 0 if no error \n
124  *      FRSH_ERR_BAD_ARGUMENT if one of the pointers is NULL
125  **/
126 int frsh_contract_get_min_memory(const frsh_contract_t *contract,
127                                   size_t *min_memory);
128
129 // frsh_contract_set_max_memory() is new 
130 // frsh_contract_get_max_memory() is new
131
132 /**
133  * frsh_contract_set_max_memory()
134  *
135  * This function specifies in the contract the minimum
136  * memory needed by the application.
137  *
138  * @param[in] max_memory  Maximum needed memory in bytes.
139  * @param  contract   Contract, in-out argument.
140  *
141  *     FRSH_ERR_BAD_ARGUMENT if min_memory > max_memory
142  * 
143  **/
144 int frsh_contract_set_max_memory(size_t max_memory,
145                                   frsh_contract_t *contract);
146
147
148 /**
149  * frsh_contract_get_max_memory()
150  *
151  * This function gets the maximum memory parameter from the contract.
152  *
153  * @param[in] contract Contract object
154  * @param[out] max_memory  Placeholder for the maximum required
155  *                         memory.
156  *
157  * @return 0 if no error \n
158  *      FRSH_ERR_BAD_ARGUMENT if one of the pointers is NULL
159  **/
160 int frsh_contract_get_max_memory(const frsh_contract_t *contract,
161                                   size_t *max_memory);
162
163
164 /**
165  * frsh_vres_get_memory_info()
166  *
167  * This function gives us the runtime info of memory usage and
168  * reservation.
169  *
170  * @param[in] vres_id Identifier of vres
171  * @param[out] mem_allocated Memory currently allocated to the vres
172  * @param[out] mem_budget Total pool of memory reserved for the vres
173  *             (until next renegotiation).
174  *
175  * @return 0 if no error \n
176  *      FRSH_ERR_BAD_ARGUMENT if one of the pointers is NULL
177  **/ 
178 int frsh_vres_get_memory_info(frsh_vres_id_t vres_id,
179                               size_t *mem_allocated,
180                               size_t *mem_budget);
181
182
183 /**
184  * frsh_vres_memalloc()
185  *
186  * This function reserves some memory from the memory to this virtual
187  * resource. 
188  *
189  * @param[in] vres_id Identifier of vres.
190  * @param[in] Number of bytes
191  * @param[out] Valid pointer for the allocation
192  *
193  * @return 0 if no error \n
194  *      FRSH_ERR_BAD_ARGUMENT if the area pointer is NULL
195  *      FRSH_ERR_OUT_OF_BUDGET if no budget is available
196  **/
197 int frsh_vres_malloc(frsh_vres_id_t vres_id,
198                      size_t num_bytes,
199                      void **area);
200
201 /**
202  * frsh_vres_memfree()
203  *
204  * This function returns the previously allocated memory area for this
205  * virtual_resource to the main memory.
206  *
207  * @param[in] vres_id Identifier of vres.
208  * @param[in] area    Memory area to return
209  *
210  * @return 0 if no error \n
211  *      FRSH_ERR_BAD_ARGUMENT if the area pointer is NULL
212  **/
213 int frsh_vres_memfree(frsh_vres_id_t vres_id,
214                       void *area);
215
216
217
218
219 /*@}*/
220
221 FRSH_CPP_END_DECLS
222
223 #endif      /* !FRSH_MEMORY_MANAGEMENT_H_ */