Subversion Repositories shark

Rev

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

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