Subversion Repositories shark

Rev

Rev 928 | Rev 985 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
929 lipari 1
/**
2
   @file Spare capacity file.
3
 */
881 trimarchi 4
//fsf_spare_capacity.h
5
//===================================================
6
//       FFFFFFIII   RRRRR      SSTTTTTTT
7
//      FF         IIR   RR    SS
8
//     FF           IR        SS
9
//    FFFFFF         RRRR    SSSSST
10
//   FF       FI       RRR  SS
11
//  FF         II     RRR  SS
12
// FF           IIIIIR    RS
13
//
14
// FSF(FIRST Scheduling Framework)
15
// spare capacity sharing functionality
16
//===================================================
17
 
18
#include <time.h>
19
#include <stdint.h>
20
#include "fsf_basic_types.h"
21
#include "fsf_core.h"
22
 
23
#ifndef _FSF_SPARE_CAPACITY_H_
24
#define _FSF_SPARE_CAPACITY_H_
25
 
26
#define FSF_SPARE_CAPACITY_MODULE_SUPPORTED       1
27
 
928 trimarchi 28
 
29
#define FSF_MAX_QUALITY     100
30
#define FSF_MIN_QUALITY     0
31
#define FSF_MAX_IMPORTANCE  5
32
#define FSF_MIN_IMPORTANCE  1
33
 
881 trimarchi 34
//// The definition of this types is in fsf_basic_types.h
35
//
36
//// Granularity of spare capacity requirements
37
//typedef enum {FSF_CONTINUOUS, FSF_DISCRETE} fsf_granularity_t;
38
//
39
//// Utilization (budget and period) value
40
//typedef struct {
41
//  struct timespec    budget;    // Execution time
42
//  struct timespec    period;    // Period
43
//} fsf_utilization_value_t;
44
//
45
////List of utilization values
46
//typedef struct {
47
//  int                         size; // = 0
48
//  fsf_utilization_value_t
49
//      value[FSF_MAX_N_UTILIZATION_VALUES];
50
//      //unit change to value.....
51
//} fsf_utilization_set_t;
52
//
53
//
54
//// Constants for assigning default values
55
//#define FSF_DEFAULT_GRANULARITY         FSF_CONTINUOUS
56
//#define FSF_DEFAULT_QUALITY             0
57
//#define FSF_DEFAULT_IMPORTANCE          1
58
//
59
//
60
//// Constants for omitting the assignment of values to specific
61
//// arguments in calls to initialization functions
62
//
63
//#define FSF_NULL_UTILIZATION_SET     (fsf_utilization_set_t *)NULL
64
//
65
 
928 trimarchi 66
/**
67
   \ingroup sparemodule
881 trimarchi 68
 
928 trimarchi 69
   The operation updates the specified contract parameters object by
70
   setting its maximum usable budget, minimum period, granularity,
71
   utilization set, quality, and importance to the specified input
72
   parameters.
73
 
74
   @param [in] contract pointer ot the contract
75
   @param [in] budget_max  maximum budget this contract can obtain
76
   @param [in] period_min  minimum period this contract can obtain
77
   @param [in] granularity can be either FSF_CONTINUOUS or FSF_DISCRETE
78
   @param [in] utilization_set in case the granularity is set to
79
      FSF_DISCRETE it contains a list possible pairs (budget,period)
80
   @param [in] quality a number between FSF_MIN_QUALITY and FSF_MAX_QUALITY,
81
               to control how the spare capacity is shared between
82
               contracts with the same importance. The higher
83
               is this number, the more likely we get a large increase
84
               in the capacity
85
   @param [in] importance a numer between FSF_MIN_IMPORTANCE and
86
               FSF_MAX_IMPORTANCE, used to control how the spare capacity
87
               is shared. The higher the number, the more likely we get
88
               some spare capacity.
89
 
90
   @retval 0 if the call is succesful
91
   @retval FSF_ERR_BAD_ARGUMENT if contract is NULL or one of the
92
       following conditions is true:
93
       - (budget_max value is grater than period_max or smaller than
94
         budget_min);
95
       - (period_min is smaller than budget_mint or larger than period_max);
96
       - (granularity is neither FSF_CONTINUOUS nor FSF_DISCRETE);
97
       - (granularity is FSF_CONTINUOUS and
98
        utilization_set is not FSF_NULL_UTILIZATION_SET)
99
       - (granularity is FSF_DISCRETE and utilization_set is
100
          FSF_NULL_UTILIZATION_SET)
101
       - (utilization_set is not FSF_NULL_UTILIZATION_SET and
102
         (size of utilization_set less than 2 or greater
103
          than FSF_MAX_N_UTILIZATION_VALUES)
104
       - (quality < 0)
105
       - (importance is less than 1 or greater than FSF_N_IMPORTANCE_LEVELS)
106
       - (the utilization_set elements are not in increasing utilization order)
107
       - (the first utilization value in the utilization_set does not match
108
        the pair (budget_min, period_max) of the contract);
109
       - (the last utilization value in the utilization_set does not match
110
        the pair (budget_max, period_min) of the contract).
881 trimarchi 111
*/
112
int
113
fsf_set_contract_reclamation_parameters
114
  (fsf_contract_parameters_t   *contract,
115
   const struct timespec       *budget_max,
116
   const struct timespec       *period_min,
117
   fsf_granularity_t            granularity,
118
   const fsf_utilization_set_t *utilization_set,
119
   int                          quality,
120
   int                          importance);
121
 
122
 
928 trimarchi 123
/**
124
   \ingroup sparemodule
125
 
126
    The operation obtains from the specified contract parameters
127
    object its granularity, utilization set, quality, and
128
    importance. Then copies them to the variables pointed to by the
129
    specified input parameters.  Only the utilization_values of the
130
    utilization_set that are in use, are copied (according to its size
131
    field).
132
 
133
    @retval 0 if the operation is succesful
134
    @retval FSF_ERR_BAD_ARGUMENT :  if contract is NULL
135
 
136
    @see fsf_set_contract_reclamation_parameters
881 trimarchi 137
*/
138
int
139
fsf_get_contract_reclamation_parameters
140
  (const fsf_contract_parameters_t *contract,
141
   struct timespec                 *budget_max,
142
   struct timespec                 *period_min,
143
   fsf_granularity_t               *granularity,
144
   fsf_utilization_set_t           *utilization_set,
145
   int                             *quality,
146
   int                             *importance);
147
 
148
 
928 trimarchi 149
/**
150
   \ingroup sparemodule
151
 
152
   The operation enqueues a request to change the quality and
153
   importance parameters of the specified server, and returns
154
   immediately. The change operation is performed as soon as it is
155
   practical; meanwhile the system operation will continue normally.
156
 
157
   @param server server id
158
   @param new_importance  the new importance
159
   @param new_quality   the new requested quality
160
 
161
   @retval FSF_ERR_BAD_ARGUMENT if
162
       - the value of the server argument is not in range or
163
       - (quality < 0)
164
       - (importance is less than 1 or greater than FSF_N_IMPORTANCE_LEVELS).
165
 
166
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 167
       scheduled under the FSF
928 trimarchi 168
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
169
       not running
170
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server has been cancelled
171
       or it is not valid
881 trimarchi 172
*/
173
int
174
fsf_request_change_quality_and_importance
175
  (fsf_server_id_t server,
176
   int new_importance,
177
   int new_quality);
178
 
179
 
928 trimarchi 180
/**
181
   \ingroup sparemodule
182
 
183
   This operation calculates the sum of the quality parameters for all
184
   servers in the system of importance level equal to that of the
185
   specified server, and stores it in the variable pointed to by
186
   total_quality.
187
 
188
   @param [in] server server id
189
   @param [out] total_quality the total quality in the system
190
 
191
   @retval FSF_ERR_BAD_ARGUMENT if the value of the server argument
192
           is not in range or total_quality is NULL
193
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 194
       scheduled under the FSF
928 trimarchi 195
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
196
       not running
197
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server has been
198
       cancelled or it is not valid
881 trimarchi 199
*/
200
int
201
fsf_get_total_quality
202
   (fsf_server_id_t server, int *total_quality);
203
 
204
 
928 trimarchi 205
/**
206
   \ingroup sparemodule
207
 
208
    This operation stores in the variable pointed to by capacity the
209
    spare capacity currently available for the importance level of the
210
    specified server. The capacity is the utilization (of the
211
    processor or of the network) and it is represented by an integer
212
    number between 0 (no utilization) and UINT32_MAX (all
213
    utilization).
214
 
215
    @retval FSF_ERR_BAD_ARGUMENT if the value of the server argument is
216
            not in range or capacity is NULL
217
    @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
218
            scheduled under the FSF
219
    @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
220
            not running
221
    @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server has been cancelled
222
            or it is not valid
889 trimarchi 223
*/
881 trimarchi 224
int
225
fsf_get_available_capacity (
226
    fsf_server_id_t server, uint32_t *capacity);
227
 
928 trimarchi 228
/* @} */
881 trimarchi 229
 
230
#endif // _FSF_SPARE_CAPACITY_H_