]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Stub spare capacity module implementation.
authorDario Faggioli <faggioli@gandalf.sssup.it>
Thu, 2 Apr 2009 15:37:22 +0000 (17:37 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 14 Apr 2009 12:08:33 +0000 (14:08 +0200)
First stub of the implementation of the spare capacity module.
Only the frsh_contract_set_reclamation_params() and
frsh_contract_get_reclamation_params() functions have been implemented
since now, since we need them also for feedback module.

fres/contract/fres_blocks.idl
frsh_api/Makefile.omk
frsh_api/frsh_spare_capacity.c [new file with mode: 0644]

index 52ecd9cdf7e0ac8baed9ece544ad0023f647befe..d943d1a6e514832c8a03aa6cdd6e7999d92572aa 100644 (file)
@@ -152,6 +152,8 @@ module fres {
 
                /// Spare capacity
                struct spare_capacity {
+                       fosa_rel_time_t         budget;
+                       fosa_rel_time_t         period;
                        frsh_granularity_t      granularity;
                        long                    importance;     
                        long                    weight; 
index 51229285ee09c9c354d0c51403c0637e3f4cbdf4..db8abaab8a3221f5e8bd25ad223b29f03eadbb4e 100644 (file)
@@ -1,7 +1,7 @@
 SUBDIRS = tests
 
 shared_LIBRARIES = frsh
-frsh_SOURCES = frsh_contract.c frsh_vres.c frsh_synchobj.c frsh_distributed.c frsh_core.c frsh_error.c frsh_thread.c frsh_sharedobj.c
+frsh_SOURCES = frsh_contract.c frsh_vres.c frsh_synchobj.c frsh_distributed.c frsh_core.c frsh_spare_capacity.c frsh_error.c frsh_thread.c frsh_sharedobj.c
 include_HEADERS = frsh_opaque_types.h frsh_forb.h
 frsh_LIBS = fna fcb_client forb contract synchobj sharedobj fra ulut fosa $(allocator-libs-y)
 
diff --git a/frsh_api/frsh_spare_capacity.c b/frsh_api/frsh_spare_capacity.c
new file mode 100644 (file)
index 0000000..f86d7b7
--- /dev/null
@@ -0,0 +1,190 @@
+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* Copyright (C) 2006 - 2008 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.                                              */
+/*                                                                       */
+/*                                                                       */
+/*  This file is part of FRSH (FRescor ScHeduler)                        */
+/*                                                                       */
+/* 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.                                             */
+/*                                                                       */
+/* 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.                                    */
+/**************************************************************************/
+
+/**
+ * @file   frsh_spare_capacity.c
+ * @author Dario Faggioli <faggioli@gandalf.sssup.it>
+ * 
+ * @brief  Implementation of FRSH contract API on top of FRES contracts.
+ * 
+ * 
+ */
+#include <fres_contract.h>
+#include <fres_contract_idl.h>
+#include <frsh_core.h>
+#include <frsh_error.h>
+#include <fres_blocks.h>
+#include <string.h>
+#include <fcb.h>
+#include "frsh_forb.h"
+#include <fra_generic.h>
+
+int frsh_contract_set_reclamation_params
+  (frsh_contract_t *contract,
+   const struct timespec *stability_time,
+   const struct timespec *budget_max,
+   const struct timespec *period_min,
+   frsh_granularity_t granularity,
+   const frsh_utilization_set_t *utilization_set,
+   int importance,
+   int weight)
+{
+       fres_block_spare_capacity *s;
+       int ret;
+
+       if (!contract || !*contract ||
+           !stability_time || !budget_max || !period_min)
+               return FRSH_ERR_BAD_ARGUMENT;
+
+       if (fosa_rel_time_is_null(*budget_max) ||
+           fosa_rel_time_is_null(*period_min) ||
+           fosa_rel_time_smaller(*period_min, *budget_max))
+               return FRSH_ERR_BAD_ARGUMENT;
+
+       if ((granularity == FRSH_GR_CONTINUOUS && utilization_set != NULL) ||
+           (granularity == FRSH_GR_DISCRETE && utilization_set == NULL))
+               return FRSH_ERR_BAD_ARGUMENT;
+
+       if (granularity != FRSH_GR_CONTINUOUS)
+               return FRSH_ERR_NOT_IMPLEMENTED;
+
+       s = malloc(sizeof(*s));
+       if (!s) return ENOMEM; 
+
+       s->budget = *budget_max;
+       s->period = *period_min;
+       s->granularity = granularity;
+       /*
+        * TODO:
+        *  support utilization-set for discrete spare
+        *  capacity distribution.
+        */
+       s->importance = importance;
+       s->weight = weight;
+       s->stability_time = *stability_time;
+
+       fres_contract_del_spare_capacity(*contract);
+       ret = fres_contract_add_spare_capacity(*contract, s);
+
+       if (ret) {
+               free(s);
+               return errno;
+       }
+
+       return FRSH_NO_ERROR;
+}
+
+int frsh_contract_get_reclamation_params
+  (const frsh_contract_t *contract,
+   struct timespec *stability_time,
+   struct timespec *budget_max,
+   struct timespec *period_min,
+   frsh_granularity_t *granularity,
+   frsh_utilization_set_t *utilization_set,
+   int *importance,
+   int *weight)
+{
+       fres_block_spare_capacity *s;
+
+        if (!contract || !*contract)
+               return FRSH_ERR_BAD_ARGUMENT;
+
+       s = fres_contract_get_spare_capacity(*contract);
+
+       if (budget_max)
+               *budget_max = s->budget;
+        if (period_min)
+               *period_min = s->period;
+       if (granularity)
+               *granularity = s->granularity;
+       /*
+        * TODO:
+        *  support utilization-set for discrete spare
+        *  capacity distribution.
+        */
+       if (importance)
+               *importance = s->importance;
+       if (weight)
+               *weight = s->weight;
+        if (stability_time)
+               *stability_time = s->stability_time;
+
+       return FRSH_NO_ERROR;
+}
+
+int frsh_vres_get_remaining_stability_time
+  (frsh_vres_id_t vres,
+   struct timespec *stability_time)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED;
+}
+
+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)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED;
+}
+
+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 *total_weight)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED;
+}
+
+int frsh_vres_decrease_capacity
+  (frsh_vres_id_t vres_id,
+   struct timespec new_budget,
+   struct timespec new_period)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED;
+}
+