]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blobdiff - frsh_energy_management.h
Adding energy management module and correcting errors with feedback_control
[frescor/frsh-include.git] / frsh_energy_management.h
diff --git a/frsh_energy_management.h b/frsh_energy_management.h
new file mode 100644 (file)
index 0000000..306d6f8
--- /dev/null
@@ -0,0 +1,242 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politécnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    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
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//
+//  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
+//                       University of York, UK
+//
+//   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.
+//
+//  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.
+//
+//  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.
+// -----------------------------------------------------------------------
+//frsh_energy_management.h
+
+//==============================================
+//  ******** *******    ********  **      **
+//  **///// /**////**  **//////  /**     /**
+//  **      /**   /** /**        /**     /**
+//  ******* /*******  /********* /**********
+//  **////  /**///**  ////////** /**//////**
+//  **      /**  //**        /** /**     /**
+//  **      /**   //** ********  /**     /**
+//  //       //     // ////////   //      // 
+//
+// FRSH(FRescor ScHeduler), pronounced "fresh"
+//==============================================
+
+#ifndef  _FRSH_ENERGY_MANAGEMENT_H_
+#define  _FRSH_ENERGY_MANAGEMENT_H_
+
+#include <time.h>
+
+#include "frsh_fosa.h"
+#include "frsh_energy_management_types.h"
+#include "frsh_core_types.h"
+
+
+#define FRSH_ENERGY_MANAGEMENT_MODULE_SUPPORTED       1
+
+/**
+ * @file frsh_energy_management.h
+ **/
+
+/**
+ * @defgroup energymgmnt Energy Management Module
+ *
+ * This module provides the ability to specify different budgets for
+ * different CPU power levels.
+ *
+ * We model the situation by specifying budget values per power
+ * level.  Thus switching in the power-level would be done by changing
+ * the budget of the vres.  In all cases the period remains the same.
+ *
+ * All global FRSH contract operations (those done with the core
+ * module without specifying the power level) are considered to be
+ * applies to the higest power level.
+ *
+ * @{
+ *
+ **/
+
+
+
+//////////////////////////////////////////////////////////////////////
+//           CONTRACT SERVICES
+//////////////////////////////////////////////////////////////////////
+
+
+/**
+ * frsh_contract_set_min_duration()
+ * 
+ * This function sets the minimum duration that the application must
+ * be able to run without finishing battery power.  0 would mean no 
+ **/
+int frsh_contract_set_min_duration(struct timespec min_duration,
+                                   frsh_contract_t *contract);
+
+/**
+ * frsh_contract_get_min_duration()
+ * 
+ * Get version of the previous function.
+ **/
+int frsh_contract_get_min_duration(const frsh_contract_t *contract,
+                                   struct timespec *min_duration);
+
+/**
+ * frsh_contract_set_min_budget_pow()
+ *
+ * Here we specify the minimum budget values corresponding to the
+ * 3 power levels.  The element order of the array goes from highest
+ * power level to the lowest.
+ *
+ * @param[in] pow_min_budget Pointer to the first element of the
+ *                           minimum budget array.  Elements
+ *                           correspond to [0]->Highest PW,
+ *                           [1]->Medium PW, [2]->Lowest PW.
+ *
+ * @return 0 if no error \n
+ *        FRSH_ERR_BAD_ARGUMENT if any of the pointers is NULL or the
+ *            budget values don't go in descending order.
+ **/
+int frsh_contract_set_min_budget_pow(const struct timespec pow_min_budget[],
+                                        frsh_contract_t *contract);
+
+/**
+ * frsh_contract_get_min_budget_pow()
+ *
+ * Get version of the previous function.
+ **/
+int frsh_contract_get_min_budget_pow(const frsh_contract_t *contract,
+                                       struct timespec pow_min_budget[]);
+
+/**
+ * frsh_contract_set_max_budget_pow()
+ *
+ * Here we specify the maximum budget values corresponding to the 3
+ * power levels.  The element order of the array goes from highest
+ * power level to the lowest. 
+ *
+ * @param[in] pow_max_budget  Pointer to the first element of the
+ *                            maximum budget array.  Elements
+ *                            correspond to [0]->Highest PW,
+ *                            [1]->Medium PW, [2]->Lowest PW.
+ *  
+ * @param     contract        (in/out) Contract
+ *
+ * @return 0 if no error \n
+ *        FRSH_ERR_BAD_ARGUMENT if any of the pointers is NULL or the
+ *             budget values don't go in ascending order.
+ *
+ **/
+int frsh_contract_set_max_budget_pow(const struct timespec pow_max_budget[],
+                                       frsh_contract_t *contract);
+
+/**
+ * frsh_contract_get_max_budget_pow()
+ *
+ * Get version of the previous function.
+ **/
+int frsh_contract_get_max_budget_pow(const frsh_contract_t *contract,
+                                       struct timespec pow_max_budget[]);
+
+
+/**
+ * frsh_contract_set_utilizations_pow()
+ *
+ * Here we specify pairs of 
+ *    [ (budget_pmax, budget_pmedium, budget_plow) ,  Period ]
+ *
+ *    for contracts of discrete granularity.
+ *
+ * param[in] utilization_set  Discrete series of utilization values.
+ * param contract (in/out) Contract object.
+ **/
+int frsh_contract_set_utilizations_pow(const frsh_utilization_set_pow_t *utilization_set_pow,
+                                       frsh_contract_t *contract);
+
+/**
+ * frsh_contract_get_utilizations_pow()
+ *
+ * Get version of the previous function.
+ **/
+int frsh_contract_get_utilizations_pow(const frsh_utilization_set_pow_t *utilization_set_pow,
+                                       frsh_contract_t *contract);
+
+
+//////////////////////////////////////////////////////////////////////
+//           MANAGING THE POWER LEVEL
+//////////////////////////////////////////////////////////////////////
+
+/**
+ * frsh_resource_set_power_level()
+ *
+ * Set the powerlevel of the CPU given by resource_id. We assume
+ * resource_type = FRSH_RT_PROCESSOR.
+ **/
+int frsh_resource_set_power_level(frsh_resource_id_t resource_id,
+                                  int power_level);
+
+
+
+//////////////////////////////////////////////////////////////////////
+//           BATTERY DURATION AND MANAGING POWER LEVELS
+//////////////////////////////////////////////////////////////////////
+
+/**
+ * frsh_resource_get_battery_duration()
+ *
+ * Get the remaining battery duration of the CPU given by resource_id.
+ * We assume resource_type = FRSH_RT_PROCESSOR.
+ **/
+int frsh_resource_get_battery_duration(frsh_resource_id_t resource_id,
+                                       struct timespec *duration);
+
+/*@}*/
+
+#endif             /* _FRSH_ENERGY_MANAGEMENT_H_ */