]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blobdiff - frsh_spare_capacity.h
Update transaction API
[frescor/frsh-include.git] / frsh_spare_capacity.h
index cf40d235d8a43353d936edb5e7932d3f369a33e5..443ea694eac49140e6f664219b588742028721a2 100644 (file)
@@ -1,5 +1,5 @@
 // -----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//  Copyright (C) 2006 - 2009 FRESCOR consortium partners:
 //
 //    Universidad de Cantabria,              SPAIN
 //    University of York,                    UK
@@ -12,7 +12,7 @@
 //    Visual Tools S.A.                      SPAIN
 //    Rapita Systems Ltd                     UK
 //    Evidence                               ITALY
-//    
+//
 //    See http://www.frescor.org for a link to partners' websites
 //
 //           FRESCOR project (FP6/2005/IST/5-034026) is funded
@@ -22,7 +22,7 @@
 //
 //
 //  based on previous work (FSF) done in the FIRST project
-//                       
+//
 //   Copyright (C) 2005  Mälardalen University, SWEDEN
 //                       Scuola Superiore S.Anna, ITALY
 //                       Universidad de Cantabria, SPAIN
 //   FSF API web pages: http://marte.unican.es/fsf/docs
 //                      http://shark.sssup.it/contrib/first/docs/
 //
-//  This file is part of FRSH API
-//
-//  FRSH API is free software; you can  redistribute it and/or  modify
-//  it under the terms of  the GNU General Public License as published by
-//  the Free Software Foundation;  either  version 2, or (at  your option)
-//  any later version.
+//   This file is part of FRSH (FRescor ScHeduler)
 //
-//  FRSH API  is distributed  in  the hope  that  it  will  be useful,  but
-//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
-//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
-//  General Public License for more details.
+//  FRSH is free software; you can redistribute it and/or modify it
+//  under terms of the GNU General Public License as published by the
+//  Free Software Foundation; either version 2, or (at your option) any
+//  later version.  FRSH is distributed in the hope that it will be
+//  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+//  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//  General Public License for more details. You should have received a
+//  copy of the GNU General Public License along with FRSH; see file
+//  COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+//  Cambridge, MA 02139, USA.
 //
-//  You should have  received a  copy of  the  GNU  General Public License
-//  distributed  with  FRSH API;  see file COPYING.   If not,  write to the
-//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
-//  02111-1307, USA.
-//
-//  As a special exception, if you include this header file into source
-//  files to be compiled, this header file does not by itself cause
-//  the resulting executable to be covered by the GNU General Public
-//  License.  This exception does not however invalidate any other
-//  reasons why the executable file might be covered by the GNU General
-//  Public License.
+//  As a special exception, including FRSH header files in a file,
+//  instantiating FRSH generics or templates, or linking other files
+//  with FRSH objects to produce an executable application, does not
+//  by itself cause the resulting executable application to be covered
+//  by the GNU General Public License. This exception does not
+//  however invalidate any other reasons why the executable file might be
+//  covered by the GNU Public License.
 // -----------------------------------------------------------------------
 //frsh_spare_capacity.h
 //==============================================
 #include "frsh_core_types.h"
 #include "frsh_core.h"
 
+FRSH_CPP_BEGIN_DECLS
+
+/**
+ * @file frsh_spare_capacity.h
+ **/
 
 #define FRSH_SPARE_CAPACITY_MODULE_SUPPORTED       1
 
  * There are no specific negotiation calls because the algorithms used
  * in the core module take already these min-max ranges into account.
  *
+ * An operation is available for applications to ask for a stability
+ * period of a specified length. The framework will then return the
+ * total capacity (execution time budget and virtual resource period)
+ * that the application is guaranteed to receive in this stability
+ * period. The rationale for this service is that jobs may span a
+ * number of virtual resource periods, and need to have a guaranteed
+ * amount of capacity before they can choose a higher quality (longer
+ * execution time) method, when multiple methods are available. Also
+ * applications may require that the capacity provided to them and
+ * hence the quality of results produced remains consistent for a
+ * period of time, so that consistent behaviour is provided for the
+ * user (e.g. multimedia applications).
+ *
+ * Requesting a new stability period has the effect of cancelling any
+ * previous one. So a subsequent request for stability up to the same
+ * point in time could return a lower total capacity, if spare capacity
+ * re-allocation is in progress due to the admission of a new
+ * application. If a stability period expires without having explicitly
+ * set a new one, the system may decide to perform a reallocation of
+ * spare resources at that point, or may defer this decision to some
+ * future point in time when it is appropriate. In both cases, a new
+ * stability period will start when the new spare capacity assignment
+ * is in effect.
+ *
+ *
  * NOTE:  When we talk here about "spare capacity" we mean STATIC extra
  *        capacity at NEGOTIATION TIME.  This is the minimum capacity
  *        that the vres will get based on contract negotiation.
  * parameters.
  *
  * @param contract  Contract object
- * @param remaining_stability_time Time in which FRSH guarantees that the
+ * @param stability_time Time in which FRSH guarantees that the
  *                   assigned budget and period will remain permanent
  *                   even across renegotiations.
  * @param budget_max The maximum budget that the vres aspires to
  *                   awakening and replenishment periods.
  * @param granularity FRSH_CONTINUOUS:  Use  min-max values,
  *                    FRSH_DISCRETE: Use utilization_set.
- * @param utilization_set A structure of discrete pairs (budget,period)
+ * @param utilization_set A structure of discrete triples (budget,
+ *                          period, deadline)
  * @param importance non-cooperative urgency indicator.  Vres with
  *                   higher importance will get all spare capacity des
  * @param weight    cooperative urgency indicator.  At equal
  *                   importance, spare capacity will be distributed
  *                   proportionally to weight levels.
  *
- * @return 0 if successful
- *   FRSH_ERR_BAD_ARGUMENT :  if contract is NULL or  
- *     (budget_max value is grater than period_max or smaller than budget_min)  or
- *      (period_min is smaller than budget_mint or larger than period_max)      or
- *      (granularity is neither FRSH_CONTINUOUS nor FRSH_DISCRETE)              or
+ *
+ * @return 0 if successful \n
+ *   FRSH_ERR_BAD_ARGUMENT :  if contract is NULL  \b or \n
+ *     (budget_max value is grater than period_max or smaller than budget_min) \b or \n
+ *      (period_min is smaller than budget_mint or larger than period_max)     \b or \n
+ *      (granularity is neither FRSH_CONTINUOUS nor FRSH_DISCRETE)     \b or \n
  *      (granularity is FRSH_CONTINUOUS and 
- *       utilization_set is not FRSH_NULL_UTILIZATION_SET)                      or
+ *       utilization_set is not FRSH_NULL_UTILIZATION_SET)            \b or \n
  *      (granularity is FRSH_DISCRETE and
- *       utilization_set is FRSH_NULL_UTILIZATION_SET)                          or
+ *       utilization_set is FRSH_NULL_UTILIZATION_SET                 \b or \n
  *      (utilization_set is not FRSH_NULL_UTILIZATION_SET and
  *       (size of utilization_set less than 2 or greater 
- *        than FRSH_MAX_N_UTILIZATION_VALUES)                )                  or
- *      (weight < 0)                                                           or
- *      (importance is less than 1 or greater than FRSH_N_IMPORTANCE_LEVELS)    or
- *      (the utilization_set elements are not in increasing utilization order)  or
+ *        than FRSH_MAX_N_UTILIZATION_VALUES)                )        \b or \n
+ *      (weight < 0)                                                  \b or \n
+ *      (importance is less than 1 or greater than FRSH_N_IMPORTANCE_LEVELS) \b or \n
+ *      (the utilization_set elements are not in increasing utilization order) \b or \n
  *      (the first utilization value in the utilization_set does not match
- *       the pair (budget_min, period_max) of the contract)                     or
+ *       the pair (budget_min, period_max) of the contract)           \b or \n
  *      (the last utilization value in the utilization_set does not match
  *       the pair (budget_max, period_min) of the contract)
  * 
  **/
 int frsh_contract_set_reclamation_params(frsh_contract_t   *contract,
-                                         const struct timespec       *remaining_stability_time,
-                                         const struct timespec       *budget_max,
-                                         const struct timespec       *period_min,
+                                         const frsh_rel_time_t       *stability_time,
+                                         const frsh_rel_time_t       *budget_max,
+                                         const frsh_rel_time_t       *period_min,
                                          frsh_granularity_t            granularity,
                                          const frsh_utilization_set_t *utilization_set,
                                          int                          importance,
@@ -210,15 +239,15 @@ int frsh_contract_set_reclamation_params(frsh_contract_t   *contract,
  * that are in use, are copied (according to its size field).
  *
  *
- * @return 0 if successful
+ * @return 0 if successful \n
  *   FRSH_ERR_BAD_ARGUMENT :  if contract is NULL
  * 
  **/
 int frsh_contract_get_reclamation_params
   (const frsh_contract_t *contract,
-   struct timespec                 *remaining_stability_time,
-   struct timespec                 *budget_max,
-   struct timespec                 *period_min,
+   frsh_rel_time_t                 *stability_time,
+   frsh_rel_time_t                 *budget_max,
+   frsh_rel_time_t                 *period_min,
    frsh_granularity_t               *granularity,
    frsh_utilization_set_t           *utilization_set,
    int                             *importance,
@@ -228,52 +257,78 @@ int frsh_contract_get_reclamation_params
 /**
  * frsh_vres_get_remaining_stability_time()
  *
- * This operation returns the remaining_stability_time for the vres.
+ * This operation returns the stability_time for the vres.
  *
- * @return 0 if successful
+ * @return 0 if successful \n
  *   FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
- *       capacity is NULL
+ *       capacity is NULL \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- *       scheduled under the FRSH
- *   FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
+ *       scheduled under FRSH \n
+ *   FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not
+ *       running \n
  *   FRSH_ERR_NOT_CONTRACTED_VRES : if the vres has been cancelled or it
- *       is not valid
+ *       is not valid \n
  * 
  **/
 int frsh_vres_get_remaining_stability_time(frsh_vres_id_t vres, 
-                                      struct timespec *remaining_stability_time);
+                                      frsh_rel_time_t *stability_time);
+
 
 /**
- * frsh_spare_get_capacity()
+ * frsh_vres_set_stability_time: 
+ * 
+ * Dynamically set the stability time for a given virtual resource to
+ * the specified interval. This operation sets a new value for the
+ * stability time associated with the virtual resource. As a result of
+ * this call the system may change the allocation of resources to the
+ * current virtual resource. Regardless of whether the resources are
+ * reallocated or not, the call resets the stability period so that
+ * the level of resources allocated to the virtual resource is kept
+ * stable for at least the duration of the requested interval.  The
+ * possibly new values of budget and period are returned in the
+ * corresponding parameters
+ */
+
+int frsh_vres_set_stability_time 
+      (frsh_vres_id_t vres,
+       const frsh_rel_time_t *stability_time,
+       frsh_rel_time_t *budget,
+       frsh_rel_time_t *period);
+
+
+/**
+ * frsh_resource_get_capacity()
  *
  * This operation gets the spare capacity currently assigned to an
  * importance level.  The capacity is the number obtained divided by
  * UINT32_MAX, and it represents the processor or network
  * utilization.
  *
- * @return 0 if successful
+ * @return 0 if successful \n
  *   FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
- *       capacity is NULL
+ *       capacity is NULL \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- *       scheduled under the FRSH
- *   FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
+ *       scheduled under the FRSH \n
+ *   FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not
+ *       running \n
  *   FRSH_ERR_NOT_CONTRACTED_VRES : if the vres has been cancelled or it
- *       is not valid
+ *       is not valid \n
  * 
  **/
-int frsh_spare_get_capacity(const frsh_resource_id_t resource_id,
-                                     const int importance,
-                                     uint32_t *capacity);
+int frsh_resource_get_capacity(const frsh_resource_type_t resource_type,
+                               const frsh_resource_id_t resource_id,
+                               const int importance,
+                               uint32_t *capacity);
 
 
 /**
- * frsh_spare_get_total_weight()
+ * frsh_resource_get_total_weight()
  *
  * This operation calculates the sum of the weight parameters for all
  * vres in the system for a certain importance level at a specific
  * resource_id.
  *
- * @return 0 if successful
+ * @return 0 if successful \n
  *    FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
  *       total_weight is NULL \n
  *    FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
@@ -283,10 +338,11 @@ int frsh_spare_get_capacity(const frsh_resource_id_t resource_id,
  *    FRSH_ERR_NOT_CONTRACTED_VRES : if the vres has been cancelled or it
  *       is not valid \n
  **/
-int frsh_spare_get_total_weight 
-   (const frsh_resource_id_t resource_id,
+int frsh_resource_get_total_weight 
+   (const frsh_resource_type_t resource_type,
+    const frsh_resource_id_t resource_id,
     const int importance,
-    uint32_t *capacity);
+    uint32_t *total_weight);
 
 
 /**
@@ -301,10 +357,12 @@ int frsh_spare_get_total_weight
  *
  **/
 int frsh_vres_decrease_capacity(frsh_vres_id_t vres,
-                           struct timespec new_budget,
-                           struct timespec new_period);
+                           frsh_rel_time_t new_budget,
+                           frsh_rel_time_t new_period);
 
 
 /*@}*/
 
+FRSH_CPP_END_DECLS
+
 #endif // _FRSH_SPARE_CAPACITY_H_