]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/commitdiff
Adapting FRSH to the new time types and synchronising headers with phase 2
authortelleriam <telleriam@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Wed, 12 Mar 2008 12:35:58 +0000 (12:35 +0000)
committertelleriam <telleriam@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Wed, 12 Mar 2008 12:35:58 +0000 (12:35 +0000)
API.

git-svn-id: http://www.frescor.org/private/svn/frescor/frsh/trunk/include@1043 35b4ef3e-fd22-0410-ab77-dab3279adceb

20 files changed:
eat.h [deleted file]
frsh_configuration_parameters.h
frsh_core.h
frsh_core_types.h
frsh_debug_and_trace.h
frsh_distributed.h
frsh_energy_management.h
frsh_energy_management_types.h
frsh_feedback_control.h
frsh_hash_table.h [deleted file]
frsh_hierarchical_types.h
frsh_memory_management.h
frsh_opaque_types.h
frsh_shared_objects.h
frsh_shared_objects_types.h
frsh_spare_capacity.h
frsh_spare_capacity_types.h
frsh_time.h
frsh_time_types.h [moved from frsh_freelist.h with 66% similarity]
timespec_operations.h [deleted file]

diff --git a/eat.h b/eat.h
deleted file mode 100644 (file)
index 00ed323..0000000
--- a/eat.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// -----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
-//
-//    Universidad de Cantabria,              SPAIN
-//    University of York,                    UK
-//    Scuola Superiore Sant'Anna,            ITALY
-//    Kaiserslautern University,             GERMANY
-//    Univ. Politecnica  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 the FRSH implementation
-//
-//  FRSH 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  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;  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.
-// -----------------------------------------------------------------------
-// 13-Jul-2007 SANGORRIN Create this function to consume time in tests using
-// the cpu time clocks.
-// -----------------------------------------------------------------------
-
-#ifndef _EAT_H
-#define _EAT_H
-
-
-#include <time.h>
-#include <frsh_cpp_macros.h>
-
-FRSH_CPP_BEGIN_DECLS
-/**
- * @file eat.h
- **/
-
-extern void inline eat(const struct timespec *cpu_time);
-
-FRSH_CPP_END_DECLS
-
-#endif
index fe9e0ee93da17c5afbf0df9022e67512b2b678a4..58d8358d49a6b66303e26f41ac2d811c8fbec80c 100644 (file)
@@ -246,10 +246,10 @@ FRSH_CPP_BEGIN_DECLS
  **/
 
 /** Initial period of the service thread (timespec) **/
-#define FRSH_SERVICE_THREAD_PERIOD  {5,0}
+#define FRSH_SERVICE_THREAD_PERIOD_USECS 5000000 /* 5 secs */
 
 /** Initial budget of the service thread (timespec) **/
-#define FRSH_SERVICE_THREAD_BUDGET  {0,1000000}
+#define FRSH_SERVICE_THREAD_BUDGET_USECS 1000 /* 1 msec */
 
 /**
  * Initial priority of the service thread, it has to be lower than the
@@ -298,7 +298,7 @@ FRSH_CPP_BEGIN_DECLS
  * The cpu time given by the round robin scheduler
  * to the threads in the background (timespec)
  **/
-#define FRSH_RR_SLICE_CPU_TIME               {0,100000000}  //3  0.1 sec
+#define FRSH_RR_SLICE_CPU_TIME_USECS 100000 // 0.1 sec
 
 /**
  * This function must be supplied by the user to map the preemption
index d3db7dbdcdb35c131ac4264f4527b2d46a14cd73..0440e4bee6baf18b6ce29623d312177cf3449529 100644 (file)
@@ -218,14 +218,14 @@ int frsh_contract_init(frsh_contract_t *contract);
  *
  * @return 0 if no error \n
  *    FRSH_ERR_BAD_ARGUMENT :  if any of the pointers is NULL
- *    or if only one of the timespec values is 0, and also if the
+ *    or if only one of the time values is 0, and also if the
  *    workload or the contract type values are unknown in the
  *    enumerations.
  **/
 int frsh_contract_set_basic_params
   (frsh_contract_t *contract,
-   const struct timespec      *budget_min,
-   const struct timespec      *period_max,
+   const frsh_rel_time_t      *budget_min,
+   const frsh_rel_time_t      *period_max,
    const frsh_workload_t      workload,
    const frsh_contract_type_t contract_type);
 
@@ -249,8 +249,8 @@ int frsh_contract_set_basic_params
  **/
 int frsh_contract_get_basic_params
   (const frsh_contract_t *contract,
-   struct timespec  *budget_min,
-   struct timespec  *period_max,
+   frsh_rel_time_t  *budget_min,
+   frsh_rel_time_t  *period_max,
    frsh_workload_t   *workload,
    frsh_contract_type_t *contract_type);
 
@@ -330,7 +330,7 @@ int frsh_contract_get_resource_and_label
 int frsh_contract_set_timing_reqs
   (frsh_contract_t *contract,
    const bool                   d_equals_t,
-   const struct timespec        *deadline,
+   const frsh_rel_time_t        *deadline,
    const frsh_signal_t          budget_overrun_signal,
    const frsh_signal_info_t     budget_overrun_siginfo,
    const frsh_signal_t          deadline_miss_signal,
@@ -350,7 +350,7 @@ int frsh_contract_set_timing_reqs
 int frsh_contract_get_timing_reqs
   (const frsh_contract_t *contract,
    bool                    *d_equals_t,
-   struct timespec         *deadline,
+   frsh_rel_time_t         *deadline,
    frsh_signal_t           *budget_overrun_signal,
    frsh_signal_info_t      *budget_overrun_siginfo,
    frsh_signal_t           *deadline_miss_signal,
@@ -524,8 +524,8 @@ int frsh_synchobj_destroy
  **/
 int frsh_synchobj_wait
   (const frsh_synchobj_handle_t  synch_handle,
-   struct timespec               *next_budget,
-   struct timespec               *next_period,
+   frsh_rel_time_t               *next_budget,
+   frsh_rel_time_t               *next_period,
    bool                          *was_deadline_missed,
    bool                          *was_budget_overran);
 
@@ -556,10 +556,10 @@ int frsh_synchobj_wait
  **/
 int frsh_synchobj_wait_with_timeout
   (const frsh_synchobj_handle_t  synch_handle,
-   const struct timespec         *abs_timeout,
+   const frsh_abs_time_t         *abs_timeout,
    bool                          *timed_out,
-   struct timespec               *next_budget,
-   struct timespec               *next_period,
+   frsh_rel_time_t               *next_budget,
+   frsh_rel_time_t               *next_period,
    bool                          *was_deadline_missed,
    bool                          *was_budget_overran);
 
@@ -663,9 +663,9 @@ int frsh_synchobj_signal
  * @sa frsh_synchobj_wait, frsh_synchobj_wait_with_timeout
  **/
 int frsh_timed_wait
-  (const struct timespec *abs_time,
-   struct timespec       *next_budget,
-   struct timespec       *next_period,
+  (const frsh_abs_time_t *abs_time,
+   frsh_rel_time_t       *next_budget,
+   frsh_rel_time_t       *next_period,
    bool                  *was_deadline_missed,
    bool                  *was_budget_overran);
 
@@ -1371,7 +1371,19 @@ bool frsh_config_is_admission_test_enabled();
  **/
 int frsh_vres_get_usage
    (const frsh_vres_id_t vres,
-    struct timespec *spent);
+    frsh_rel_time_t *spent);
+
+
+/**
+ * frsh_vres_get_job_usage()
+ *
+ * Get the execution time of the current job of the specified virtual
+ * resource for a bounded or synchronized workload.
+ **/
+int frsh_vres_get_job_usage
+    (const frsh_vres_id_t vres,
+     frsh_rel_time_t *spent);
+
 
 /**
  * frsh_vres_get_remaining_budget()
@@ -1393,7 +1405,7 @@ int frsh_vres_get_usage
  **/
 int frsh_vres_get_remaining_budget
    (const frsh_vres_id_t vres,
-    struct timespec *budget);
+    frsh_rel_time_t *budget);
 
 
 /**
@@ -1417,8 +1429,8 @@ int frsh_vres_get_remaining_budget
  **/
 int frsh_vres_get_budget_and_period
    (const frsh_vres_id_t vres,
-    struct timespec *budget,
-    struct timespec *period);
+    frsh_rel_time_t *budget,
+    frsh_rel_time_t *period);
 
 /*@}*/
 
@@ -1475,8 +1487,8 @@ int frsh_vres_get_budget_and_period
  *     has been cancelled or it is not valid
  *
  **/
-int frsh_service_thread_set_data (const struct timespec *budget,
-                                  const struct timespec *period,
+int frsh_service_thread_set_data (const frsh_rel_time_t *budget,
+                                  const frsh_rel_time_t *period,
                                   bool                  *accepted);
 
 /**
@@ -1497,8 +1509,8 @@ int frsh_service_thread_set_data (const struct timespec *budget,
  *
  **/
 int frsh_service_thread_get_data
-   (struct timespec *budget,
-    struct timespec *period);
+   (frsh_rel_time_t *budget,
+    frsh_rel_time_t *period);
 
 
 /*@}*/
index e727fdd9cce111f586e42a87900aca25cd2e679c..cad57f87073fa504ae8abb197e3c64923db4b622 100644 (file)
@@ -74,6 +74,7 @@
 #define   FRSH_CORE_TYPES_H_
 
 #include <stdbool.h>
+#include "frsh_time_types.h"
 #include "frsh_configuration_parameters.h"
 #include "frsh_opaque_types.h"
 #include "frsh_shared_objects_types.h"
@@ -123,18 +124,26 @@ typedef fosa_signal_t frsh_signal_t;
 
 typedef fosa_signal_info_t frsh_signal_info_t;
 
-/* Temporary placement */
-typedef struct timespec frsh_rel_time_t;
-typedef struct timespec frsh_abs_time_t;
-
 
 /** Kind of workload expected in vres: bounded or indeterminate **/
 typedef enum {
     FRSH_WT_BOUNDED       = 0,
-    FRSH_WT_INDETERMINATE = 1
+    FRSH_WT_INDETERMINATE = 1,
+    FRSH_WT_SYNCHRONIZED  = 2
 } frsh_workload_t;
+/**
+ * In the synchronized workload the virtual resource hosts one or more
+ * threads that synchronize the execution of their jobs with the start
+ * of the virtual resource's period. In this kind of workload, once
+ * the threads that were activated at the beginning of the period
+ * finish their current job, the virtual resource may return any
+ * unused capacity to the system. This kind of workload can be
+ * scheduled using a regular periodic server that has the properties
+ * of being simple, having less overhead, and being able to increase
+ * the schedulability of periodic synchronized threads
+ **/
 
-#define FRSH_NULL_DEADLINE     (struct timespec *)NULL
+#define FRSH_NULL_DEADLINE     (frsh_rel_time_t *)NULL
 // #define FRSH_NULL_SIGNAL       0 /* Defined at frsh_adaption.h */
 
 /** Negotiation status: In_progress, rejected, admitted, not_requested **/
index 9d19e9ef4457646e467f9a46098f8629b9eaf188..bcb2be375fe5774d7abef1db2b87449a844d7ece 100644 (file)
@@ -77,8 +77,8 @@
 #include <stdio.h> // for vprintf
 #include <stdbool.h> // for bool
 #include <stdarg.h> // for va_list, va_start and va_end
+#include "fosa.h"
 #include "frsh_debug_and_trace_types.h"
-#include "timespec_operations.h"
 #include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
 #include "fosa_clocks_and_timers.h"
 
@@ -117,7 +117,7 @@ int frsh_trace_point_insert(frsh_trace_point_id_t ipoint);
 
 /* These variables live defined in frsh_error.c */
 /************************************************/
-extern struct timespec frsh_trace_init_timespec;
+extern fosa_abs_time_t frsh_trace_init_timespec;
 extern long frsh_trace_init_timemsec;
 
 extern int global_error_condition;  /* Used to propagate error
@@ -126,23 +126,23 @@ extern int global_error_condition;  /* Used to propagate error
 static inline long int FRSH_GET_TIMESTAMP_MSECS()
 {
     int terror = -1;
-    struct timespec current_time = {-1, -1};
+    fosa_abs_time_t current_time;
     long int current_time_msec = -1;
     long int result = -1;
 
     PRW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &current_time)  );
-    current_time_msec = timespec2msec(&current_time);
+    current_time_msec = fosa_abs_time_to_msec(current_time);
 
     result = current_time_msec - frsh_trace_init_timemsec;
 
     return result;
 }
 
-static inline long int FRSH_TIMESPEC_TO_RELATIVE_MSECS(const struct timespec *tspec)
+static inline long int FRSH_TIMESTAMP_TO_RELATIVE_MSECS(const fosa_abs_time_t *timestamp)
 {
     long int time_msecs = -1;
 
-    time_msecs = timespec2msec(tspec);
+    time_msecs = fosa_abs_time_to_msec(*timestamp);
 
     return time_msecs - frsh_trace_init_timemsec;
 }
index 1c5e4ca0438fc58ccbc97ff85f9612011aa2c672..c27161d3767a7616003dad66b2bddce4b1cc776a 100644 (file)
@@ -229,7 +229,7 @@ int frsh_network_get_max_message_size
 int frsh_network_bytes_to_budget
    (const frsh_resource_id_t resource_id,
     const size_t nbytes,
-    struct timespec *budget);
+    frsh_rel_time_t *budget);
 
 /**
  * frsh_network_budget_to_bytes()
@@ -253,7 +253,7 @@ int frsh_network_bytes_to_budget
  **/
 int frsh_network_budget_to_bytes
    (const frsh_resource_id_t resource_id,
-    const struct timespec *budget,
+    const frsh_rel_time_t *budget,
     size_t *nbytes);
 
 /**
@@ -286,7 +286,7 @@ int frsh_network_budget_to_bytes
  **/
 int frsh_network_get_min_effective_budget
    (const frsh_resource_id_t resource_id,
-    struct timespec *budget);
+    frsh_rel_time_t *budget);
 
 /**
  * frsh_contract_set_queueing_info()
index 626c22606505666ee3abbf80ec3e67a12080f559..1c834a24d52b85445609181049752bec4b03586c 100644 (file)
@@ -90,7 +90,7 @@ FRSH_CPP_BEGIN_DECLS
  * @defgroup energymgmnt Energy Management Module
  *
  * This module provides the ability to specify different budgets for
- * different CPU power levels.
+ * different power levels.
  *
  * We model the situation by specifying budget values per power
  * level.  Thus switching in the power-level would be done by changing
@@ -98,7 +98,20 @@ FRSH_CPP_BEGIN_DECLS
  *
  * 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.
+ * applied to the higest power level, corresponding to a power_level_t
+ * value of 0.
+ *
+ * @note
+ * For all functions that operate on a contract, the resource is
+ * implicitly identified by the contract core parameters resource_type
+ * and resource_id that are either set through the
+ * frsh_contract_set_resource_and_label() function, or implicitly
+ * defined if no such call is made.
+ *
+ * @note
+ * For the power level management operations, only
+ * implementation for resource_type = FRSH_RT_PROCESSOR is mandatory,
+ * if the energy management module is present.
  *
  * @{
  *
@@ -112,40 +125,48 @@ FRSH_CPP_BEGIN_DECLS
 
 
 /**
- * frsh_contract_set_min_duration()
+ * frsh_contract_set_min_expiration()
  * 
- * This function sets the minimum duration that the application must
- * be able to run without finishing battery power.  0 would mean no 
+ * This function sets the minimum battery expiration time that the
+ * system must be able to sustain without finishing battery power. A
+ * value of (0,0) would mean that the application does not have such
+ * requirement (this is the default if this parameter is not explicitly
+ * set).
  **/
-int frsh_contract_set_min_duration(struct timespec min_duration,
-                                   frsh_contract_t *contract);
+int frsh_contract_set_min_expiration(frsh_contract_t *contract,
+                                    frsh_rel_time_t min_expiration);
 
 /**
- * frsh_contract_get_min_duration()
+ * frsh_contract_get_min_expiration()
  * 
  * Get version of the previous function.
  **/
-int frsh_contract_get_min_duration(const frsh_contract_t *contract,
-                                   struct timespec *min_duration);
+int frsh_contract_get_min_expiration(const frsh_contract_t *contract,
+                                    frsh_rel_time_t *min_expiration);
 
 /**
  * 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.
+ * Here we specify the minimum budget value corresponding to a single
+ * power level.
  *
- * @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.
+ * @param contract             The affected contract.
+ * @param power_level          The power level for which we are specifying the minimum budget.
+ * @param pow_min_budget       The minimum budget requested for the power level.
  *
  * @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.
+ *     FRSH_ERR_BAD_ARGUMENT if power_level is greater than or equal to the value
+ *     returned by frsh_get_power_levels  budget value is not correct.
+ *
+ * @note
+ * If the minimum budget relative to one or more power levels has not been specified, then
+ * the framework may attempt to perform interpolation of the supplied values in
+ * order to infer them, if an accurate model for such operation is available.
+ * Otherwise, the contract is rejected at frsh_negotiate() time.
  **/
-int frsh_contract_set_min_budget_pow(const struct timespec pow_min_budget[],
-                                        frsh_contract_t *contract);
+int frsh_contract_set_min_budget_pow(frsh_contract_t *contract,
+                                    frsh_power_level_t power_level,
+                                    const frsh_rel_time_t *pow_min_budget);
 
 /**
  * frsh_contract_get_min_budget_pow()
@@ -153,29 +174,26 @@ int frsh_contract_set_min_budget_pow(const struct timespec pow_min_budget[],
  * Get version of the previous function.
  **/
 int frsh_contract_get_min_budget_pow(const frsh_contract_t *contract,
-                                       struct timespec pow_min_budget[]);
+                                    frsh_power_level_t power_level,
+                                    frsh_rel_time_t *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. 
+ * Here we specify the maximum budget for a single power level.
  *
- * @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
+ * @param contract             The affected contract object.
+ * @param power_level          The power level for which we are specifying the maximum budget.
+ * @param pow_max_budget       The maximum budget requested for the power level.
  *
  * @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);
+int frsh_contract_set_max_budget_pow(frsh_contract_t *contract,
+                                    frsh_power_level_t power_level,
+                                    const frsh_rel_time_t *pow_max_budget);
 
 /**
  * frsh_contract_get_max_budget_pow()
@@ -183,30 +201,39 @@ int frsh_contract_set_max_budget_pow(const struct timespec pow_max_budget[],
  * Get version of the previous function.
  **/
 int frsh_contract_get_max_budget_pow(const frsh_contract_t *contract,
-                                       struct timespec pow_max_budget[]);
+                                    frsh_power_level_t power_level,
+                                    frsh_rel_time_t *pow_max_budget);
 
 
 /**
- * frsh_contract_set_utilizations_pow()
- *
- * Here we specify pairs of 
- *    [ (budget_pmax, budget_pmedium, budget_plow) ,  Period ]
+ * frsh_contract_set_utilization_pow()
  *
- *    for contracts of discrete granularity.
+ * This function should be used for contracts with a period of
+ * discrete granularity.  Here we specify, for each allowed period,
+ * the budget to be used for each power level.
  *
- * param[in] utilization_set  Discrete series of utilization values.
- * param contract (in/out) Contract object.
+ * @param contract     The affected contract object.
+ * @param power_level  The power level for which we specify budget and period.
+ * @param budget       The budget to be used for the supplied power level and period.
+ * @param period       One of the allowed periods (from the discrete set).
+ * @param period       The deadline used with the associated period (from the discrete set).
  **/
-int frsh_contract_set_utilizations_pow(const frsh_utilization_set_pow_t *utilization_set_pow,
-                                       frsh_contract_t *contract);
+int frsh_contract_set_utilization_pow(frsh_contract_t *contract,
+                                     frsh_power_level_t power_level,
+                                     const frsh_rel_time_t *budget,
+                                     const frsh_rel_time_t *period,
+                                     const frsh_rel_time_t *deadline);
 
 /**
- * frsh_contract_get_utilizations_pow()
+ * frsh_contract_get_utilization_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);
+int frsh_contract_get_utilization_pow(const frsh_contract_t *contract,
+                                     frsh_power_level_t power_level,
+                                     frsh_rel_time_t *budget,
+                                     frsh_rel_time_t *period,
+                                     frsh_rel_time_t *deadline);
 
 
 //////////////////////////////////////////////////////////////////////
@@ -277,7 +304,7 @@ int frsh_resource_get_num_power_levels(frsh_resource_type_t resource_type,
  *
  * Get the foreseen expiration time of the system battery(ies).
  **/
-int frsh_battery_get_expiration(struct timespec *expiration);
+int frsh_battery_get_expiration(frsh_abs_time_t *expiration);
 
 /*@}*/
 
index 212a4c14f9653aca7cd9a11e5482232e3abdd277..03ff26ae553f968940094765374c6b05a769623e 100644 (file)
@@ -104,8 +104,8 @@ typedef enum {
  * Here we define a capacity specification for all power levels.
  **/
 typedef struct {
-    struct timespec budget[3];
-    struct timespec period;
+    frsh_rel_time_t budget[3];
+    frsh_rel_time_t period;
 } frsh_utilization_line_pow_t;
 
 /**
index af697fcce3d5117bd0da374a7c9604d1145c9e71..812ba283682902b383169c9733be211f005625f4 100644 (file)
@@ -133,14 +133,14 @@ FRSH_CPP_BEGIN_DECLS
  * No threads must be ever attached to the contract identified by
  * spare_id.
  **/
-int frsh_feedback_set_spare(const frsh_contract_t *spare_contract);
+int frsh_feedback_set_spare(frsh_vres_id_t spare_id);
 
 /**
  * frsh_feedback_get_spare()
  *
  * Get version of the frsh_feedback_set_spare() function.
  **/
-int frsh_feedback_get_spare(frsh_contract_t *spare_contract);
+int frsh_feedback_get_spare(frsh_vres_id_t *p_spare_id);
 
 /**
  * frsh_feedback_set_desired_budget()
@@ -183,7 +183,7 @@ int frsh_feedback_get_spare(frsh_contract_t *spare_contract);
  * @param[in] p_budget_in
  * The new budget to set as desired.
  **/
-int frsh_feedback_set_desired_budget(frsh_vres_id_t vres_id, struct timespec *p_budget_in);
+int frsh_feedback_set_desired_budget(frsh_vres_id_t vres_id, frsh_rel_time_t *p_budget_in);
 
 /**
  * frsh_feedback_get_desired_budget()
@@ -195,7 +195,7 @@ int frsh_feedback_set_desired_budget(frsh_vres_id_t vres_id, struct timespec *p_
  * call, or the maximum budget set during contract negotiation, if no such
  * call ever occurred.
  **/
-int frsh_feedback_get_desired_budget(frsh_vres_id_t vres_id, struct timespec *p_budget_out);
+int frsh_feedback_get_desired_budget(frsh_vres_id_t vres_id, frsh_rel_time_t *p_budget_out);
 
 /**
  * frsh_feedback_get_actual_budget()
@@ -205,7 +205,7 @@ int frsh_feedback_get_desired_budget(frsh_vres_id_t vres_id, struct timespec *p_
  * for a given vres may change dynamically as a result of a call to the
  * frsh_feedback_set_desired_budget() function for the same or other virtual resources.
  **/
-int frsh_feedback_get_actual_budget(frsh_vres_id_t vres_id, struct timespec *budget);
+int frsh_feedback_get_actual_budget(frsh_vres_id_t vres_id, frsh_rel_time_t *budget);
 
 /*@}*/
 
diff --git a/frsh_hash_table.h b/frsh_hash_table.h
deleted file mode 100644 (file)
index 1551d3c..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-// -----------------------------------------------------------------------
-//  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.
-//
-//
-//  This file is part of FRSH Implementation
-//
-//  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(FRescor ScHeduler), pronounced "fresh"
-//==============================================
-//
-
-// This header file defines the interface to a hash table used to map
-// from a string key into an integer value. The number of entries in
-// the hash table is bounded by a maximum value, and therefore it is
-// not necessary to have a dynamic size table. The integer values are
-// non negative, so a negative value can be used as an error
-// indication. The key strings are assumed constant, so there is no
-// need to copy them.
-
-
-#ifndef FRSH_HASH_TABLE
-#define FRSH_HASH_TABLE
-
-#include <stdbool.h>
-
-/**
- * A configurable constant that defines the maximum length of the string keys
- */
-
-#define FRSH_HASH_TABLE_MAX_CHARS 21
-
-// Type that contains the status of an entry
-typedef enum {frsh_hash_empty, frsh_hash_valid, frsh_hash_cleaned}
-frsh_hash_entry_status_t;
-
-/**
- * Type that defines a table entry
- */
-typedef struct {
-  char key[FRSH_HASH_TABLE_MAX_CHARS]; // array where the key is stored
-  unsigned int value;                  // unsigned integer value 
-  frsh_hash_entry_status_t status;     // indicates the entry status
-} frsh_hash_entry_t;
-
-/**
- * Type that defines a hash table
- */
-typedef struct {
-  int size;                      // size of the table
-  int max_chars;                 // maximum characters of the key strings
-  int num;                       // current number of entries
-  int cleaned;                   // current number of cleaned entries
-  frsh_hash_entry_t * entry;     // pointer to table of entries
-  frsh_hash_entry_t * old_entry; // pointer to old table of entries, used
-                                 // to recreate the table when necessary
-} frsh_hash_table_t;
-
-/**
- * Function that maps a string key into an integer value
- */
-unsigned int frsh_hash_function (const char *str, int max_chars);
-
-
-/**
- * Create a hash table to store up to the specified number of
- * keys equal to max_size. The maximum size of the String values
- * is specified in max_chars.
- * Returns: 0 if successful
- *          FRSH_ERR_NO_SPACE if there is not enough memory available
- *          FRSH_ERR_TOO_LARGE if max_chars exceeds FRSH_HASH_TABLE_MAX_CHARS
- */ 
-int frsh_hash_table_init (frsh_hash_table_t *table, 
-                         int max_size, int max_chars);
-
-/**
- * Delete a hash table, eliminating the resources allocated to it
- */
-void frsh_hash_table_destroy (frsh_hash_table_t *table);
-
-/**
- * Empty a hash table, eliminating all entries from it
- */
-void frsh_hash_table_clean (frsh_hash_table_t *table);
-
-/**
- * Assign a value to a key. An older value is removed if present
- * Returns: 0 if successful
- *          FRSH_ERR_NO_SPACE if the maximum number of keys would be exceeded
- */
-int frsh_hash_table_put (frsh_hash_table_t *table, 
-                        const char * key, unsigned int value);
-
-/**
- * Get the value assigned to a key. 
- * Returns 0 if successful or -1 if the key is not present
- */
-int frsh_hash_table_get (frsh_hash_table_t *table,
-                        const char * key, unsigned int * value);
-
-/**
- * Indicate whether or not the specified key is contained in the table
- */
-bool frsh_hash_table_contains_key (frsh_hash_table_t *table, const char * key);
-
-/**
- * Remove an entry from the table given a key
- * Returns 0 if successful, or -1 if the key is not contained in the table
- */
-int frsh_hash_table_remove (frsh_hash_table_t *table, const char * key);
-
-
-#endif // FRSH_HASH_TABLE
-
-
-
index ee2d16ec543160a226edfa8789e965fec5c0f8dc..8eaa53bd47522c5cf1bd838509954ba0367e3348 100644 (file)
@@ -97,7 +97,7 @@ typedef enum {FRSH_FP, FRSH_EDF, FRSH_TABLE_DRIVEN, FRSH_RR, FRSH_NONE}
  * The params member is a pointer to one of the 
  * following:
  *    FP:  int (priority)
- *    EDF: struct timespec (deadline)
+ *    EDF: frsh_rel_time_t (deadline)
  *    RR:  none
  *    TABLE_DRIVEN : struct frsh_table_driven_params_t
  **/
@@ -112,9 +112,9 @@ typedef struct {
  * list of target windows 
  **/
 typedef struct {
-   struct timespec   start;
-   struct timespec   end;
-   struct timespec   comp_time;
+   frsh_rel_time_t   start;
+   frsh_rel_time_t   end;
+   frsh_rel_time_t   comp_time;
 } frsh_target_window_t;
 
 /**
@@ -132,8 +132,8 @@ typedef struct {
  * It shall be one of the following:
  *    FP:  none
  *    EDF: none
- *    RR: struct timespec (slice duration)
- *    TABLE_DRIVEN : struct timespec (schedule duration)
+ *    RR: frsh_rel_time_t (slice duration)
+ *    TABLE_DRIVEN : frsh_rel_time_t (schedule duration)
  **/
 typedef void * frsh_sched_init_info_t;
 
index c5d3bc33920ed1f9520a59affe1505bacbabfbb1..f173e1ce9610cd07b1c1e03a9b9bb96fe81b6538 100644 (file)
@@ -95,9 +95,9 @@ FRSH_CPP_BEGIN_DECLS
  **/
 
 /**
- * frsh_contract_set_memory_reqs()
+ * frsh_contract_set_min_memory()
  *
- * This function specifies in the contract the minimum and maximum
+ * This function specifies in the contract the minimum
  * memory needed by the application.
  *
  * @param[in] min_memory  Minimum needed memory in bytes.
@@ -105,29 +105,59 @@ FRSH_CPP_BEGIN_DECLS
  * @param  contract   Contract, in-out argument.
  *
  * @return 0 if no error \n
- *     FRSH_ERR_BAD_ARGUMENT if min_memory > max_memory
+ *     FRSH_ERR_BAD_ARGUMENT if min_memory <0
  * 
  **/
-int frsh_contract_set_memory_reqs(size_t min_memory,
-                                  size_t max_memory,
+int frsh_contract_set_min_memory(size_t min_memory,
                                   frsh_contract_t *contract);
 
 /**
- * frsh_contract_get_memory_reqs()
+ * frsh_contract_get_min_memory()
  *
- * This function gets the memory parameters from the contract.
+ * This function gets the minimum memory parameter from the contract.
  *
  * @param[in] contract Contract object
  * @param[out] min_memory  Placeholder for the minimum required
  *                         memory.
+ *
+ * @return 0 if no error \n
+ *      FRSH_ERR_BAD_ARGUMENT if one of the pointers is NULL
+ **/
+int frsh_contract_get_min_memory(const frsh_contract_t *contract,
+                                  size_t *min_memory);
+
+// frsh_contract_set_max_memory() is new 
+// frsh_contract_get_max_memory() is new
+
+/**
+ * frsh_contract_set_max_memory()
+ *
+ * This function specifies in the contract the minimum
+ * memory needed by the application.
+ *
+ * @param[in] max_memory  Maximum needed memory in bytes.
+ * @param  contract   Contract, in-out argument.
+ *
+ *     FRSH_ERR_BAD_ARGUMENT if min_memory > max_memory
+ * 
+ **/
+int frsh_contract_set_max_memory(size_t max_memory,
+                                  frsh_contract_t *contract);
+
+
+/**
+ * frsh_contract_get_max_memory()
+ *
+ * This function gets the maximum memory parameter from the contract.
+ *
+ * @param[in] contract Contract object
  * @param[out] max_memory  Placeholder for the maximum required
  *                         memory.
  *
  * @return 0 if no error \n
  *      FRSH_ERR_BAD_ARGUMENT if one of the pointers is NULL
  **/
-int frsh_contract_get_memory_reqs(const frsh_contract_t *contract,
-                                  size_t *min_memory,
+int frsh_contract_get_max_memory(const frsh_contract_t *contract,
                                   size_t *max_memory);
 
 
index c6ee66d411d3d018acae9911b05569c171d30bc5..11f4de992967b740860fedc2cbf5ce01964733dc 100644 (file)
@@ -109,19 +109,19 @@ FRSH_CPP_BEGIN_DECLS
 \
   /** Minimum budget needed to perform a job.  With the energy 
       module this will be an array **/              \
-  struct timespec         budget_min;                         \
+  frsh_rel_time_t         budget_min;                         \
 \
   /** Maximum period that the system system can sustain **/   \
-  struct timespec         period_max;                         \
+  frsh_rel_time_t         period_max;                         \
 \
   /** Maximum budget that the vres can use
      (and would be happy to have).  With the energy module
      this will be an array **/              \
-  struct timespec         budget_max;                         \
+  frsh_rel_time_t         budget_max;                         \
 \
   /** Minimum period for that
      the system can use (and would be happy to have) **/     \
-  struct timespec         period_min;                         \
+  frsh_rel_time_t         period_min;                         \
 \
   /** Set of discrete values for budget and period.  With the
       energy module this will be an array **/        \
@@ -138,7 +138,7 @@ FRSH_CPP_BEGIN_DECLS
   bool                    d_equals_t;                         \
 \
   /** Deadline (will be ignored if d_equals_t is TRUE **/     \
-  struct timespec         deadline;                           \
+  frsh_rel_time_t         deadline;                           \
 \
   /** Signal parameters for the case of
       attempting to use too much budget       **/             \
@@ -167,7 +167,7 @@ FRSH_CPP_BEGIN_DECLS
       the allocated budget and capacity will be
       maintained across negotiations  and will
       not be affected for dynamic spare capacity    **/       \
-  struct timespec         stability_time;  \
+  frsh_rel_time_t         stability_time;  \
 \
   /** Low level parameter related with the elegibility
       preempt other threads                            **/    \
@@ -220,8 +220,8 @@ typedef int FRSH_SHAREDOBJ_HANDLE_T_OPAQUE;
 #define FRSH_CSECT_T_OPAQUE struct { \
   frsh_csect_op_kind_t op_kind;                 \
   frsh_sharedobj_handle_t obj_handle;               \
-  struct timespec wcet;                              \
-  struct timespec blocking;                              \
+  frsh_rel_time_t wcet;                              \
+  frsh_rel_time_t blocking;                              \
   frsh_csect_op_t op;                           \
   frsh_memory_areas_t areas;                         \
   frsh_memory_areas_t storage;                         \
index 6492aad21cc7dca65b929f1906e237ff333635cd..76e0d893e4af6dbef2e897f6214aa3e1146f9ce1 100644 (file)
@@ -375,7 +375,7 @@ int frsh_sharedobj_remove
  **/
 int frsh_csect_init
     (frsh_sharedobj_handle_t obj_handle,
-     struct timespec wcet,
+     frsh_rel_time_t wcet,
      frsh_csect_t *csect);
 
 
@@ -419,7 +419,7 @@ int frsh_csect_get_sharedobj_handle
  **/
 int frsh_csect_get_wcet
     (const frsh_csect_t *csect,
-     struct timespec *wcet);
+     frsh_rel_time_t *wcet);
 
 
 /**
@@ -618,7 +618,7 @@ int frsh_csect_invoke
  **/
 int frsh_csect_get_blocking_time
     (const frsh_csect_t *csect,
-     struct timespec *blocking);
+     frsh_rel_time_t *blocking);
 
 
 /**
index b0f86669795e8edd31ec09546cd5c9d1cdf67359..582c59c175c504516b46baa1333a679f96095fcd 100644 (file)
@@ -73,7 +73,7 @@
 #define        FRSH_SHARED_OBJECTS_TYPES_H_
 
 #include <time.h>
-#include "frsh_opaque_types.h"
+#include "frsh_core_types.h"
 #include "frsh_configuration_parameters.h"
 
 FRSH_CPP_BEGIN_DECLS
index 700797ce426bb72bdff1090ad6ad88cb143b8288..bed3edec7123bcbe2245d6e6ba8f3c9391685bc7 100644 (file)
@@ -190,13 +190,15 @@ FRSH_CPP_BEGIN_DECLS
  *                   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 \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
@@ -219,9 +221,9 @@ FRSH_CPP_BEGIN_DECLS
  * 
  **/
 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,
+                                         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,
@@ -246,9 +248,9 @@ int frsh_contract_set_reclamation_params(frsh_contract_t   *contract,
  **/
 int frsh_contract_get_reclamation_params
   (const frsh_contract_t *contract,
-   struct timespec                 *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,
@@ -272,7 +274,30 @@ int frsh_contract_get_reclamation_params
  * 
  **/
 int frsh_vres_get_remaining_stability_time(frsh_vres_id_t vres, 
-                                      struct timespec *stability_time);
+                                      frsh_rel_time_t *stability_time);
+
+
+/**
+ * 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()
@@ -335,8 +360,8 @@ int frsh_resource_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);
 
 
 /*@}*/
index d002aa999842d2b7fcfca9bb708bff3c77215a53..fd72815ad1cc69d6a6049b5a29089a9eeda1ae3a 100644 (file)
@@ -93,10 +93,11 @@ FRSH_CPP_BEGIN_DECLS
 /** Granularity of spare capacity requirements: continuous or discrete **/
 typedef enum {FRSH_GR_CONTINUOUS, FRSH_GR_DISCRETE} frsh_granularity_t;
 
-/** Utilization (C and T) **/
+/** Utilization (C, T, and D) **/
 typedef struct {
-    struct timespec    budget;    // Execution time
-    struct timespec    period;    // Period
+    frsh_rel_time_t    budget;    // Execution time
+    frsh_rel_time_t    period;    // Period
+    frsh_rel_time_t    deadline;  // Deadline
 } frsh_utilization_t;
 
 /** List of utilization values **/
index 8e71621e895825ffdee1c4a08e6280d542df0960..b31f4b359e696fd7cdfafed04c61480cc3ee7e6f 100644 (file)
-/*
-** fosa_time.h
-** 
-** Made by Miguel marciano
-** Login   <miguel@namir.ctr.unican.es>
-** 
-** Started on  Mon Jan 21 20:01:04 2008 Miguel marciano
-** Last update Mon Jan 21 20:01:04 2008 Miguel marciano
-*/
+// -----------------------------------------------------------------------
+//  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_spare_capacity_types.h
+//==============================================
+//  ******** *******    ********  **      **
+//  **///// /**////**  **//////  /**     /**
+//  **      /**   /** /**        /**     /**
+//  ******* /*******  /********* /**********
+//  **////  /**///**  ////////** /**//////**
+//  **      /**  //**        /** /**     /**
+//  **      /**   //** ********  /**     /**
+//  //       //     // ////////   //      // 
+//
+// FRSH(FRescor ScHeduler), pronounced "fresh"
+//==============================================
+
 #ifndef        FRSH_TIME_H_
 #define        FRSH_TIME_H_
 
-#include <frsh_core_types.h>
-#include <frsh_core.h>
+#include "frsh_core_types.h"
+#include "frsh_core.h"
 
 FRSH_CPP_BEGIN_DECLS
 
+/**
+ * @file frsh_time.h
+ **/
+
+
+/**
+ * \addtogroup core
+ **/
+/*@{*/
+
+/***********************
+ * Relational operations
+ ***********************/  
+
+/**
+ * frsh_abs_time_smaller()
+ *
+ * Check if an absolute time is smaller than another one.
+ **/
+static inline bool frsh_abs_time_smaller(frsh_abs_time_t t1, frsh_abs_time_t t2)
+{
+    return fosa_abs_time_smaller(t1, t2);
+}
+
+/**
+ * frsh_rel_time_smaller()
+ *
+ * Check if a relative interval is smaller than another one.
+ **/
+static inline bool frsh_rel_time_smaller(frsh_rel_time_t t1, frsh_rel_time_t t2)
+{
+    return fosa_rel_time_smaller(t1, t2);
+}
+
+/**
+ * frsh_abs_time_smaller_or_equal()
+ *
+ * Check if an absolute time is smaller than or equal to another one.
+ **/
+static inline bool frsh_abs_time_smaller_or_equal(frsh_abs_time_t t1, frsh_abs_time_t t2)
+{
+    return fosa_abs_time_smaller_or_equal(t1, t2);
+}
+
+/**
+ * frsh_rel_time_smaller_or_equal()
+ *
+ * Check if a relative interval is smaller than or equal to another one.
+ **/
+static inline bool frsh_rel_time_smaller_or_equal(frsh_rel_time_t t1, frsh_rel_time_t t2)
+{
+    return fosa_rel_time_smaller_or_equal(t1, t2);
+}
+
+
+/***********************
+ * Arithmetic operations
+ ***********************/  
+
+/**
+ * frsh_abs_time_incr()
+ *
+ * Add a relative interval to an absolute time.
+ */
+static inline frsh_abs_time_t frsh_abs_time_incr(frsh_abs_time_t base, frsh_rel_time_t interval)
+{
+    return fosa_abs_time_incr(base, interval);
+}
+
+/**
+ * frsh_rel_time_add()
+ *
+ * Add a relative interval to another one.
+ */
+static inline frsh_rel_time_t frsh_rel_time_add(frsh_rel_time_t t1, frsh_rel_time_t t2)
+{
+    return fosa_rel_time_add(t1, t2);
+}
+
+/**
+ * frsh_abs_time_decr
+ *
+ * Subtract a relative interval from an absolute time.
+ */
+static inline frsh_abs_time_t frsh_abs_time_decr(frsh_abs_time_t time, frsh_rel_time_t interval)
+{
+    return fosa_abs_time_decr(time, interval);
+}
+
+/**
+ * frsh_rel_time_decr()
+ *
+ * Subtract a relative interval from another one.
+ */
+static inline frsh_rel_time_t frsh_rel_time_decr(frsh_rel_time_t total, frsh_rel_time_t part)
+{
+    return fosa_rel_time_decr(total, part);
+}
+    
+
+/**
+ * frsh_abs_time_extract_interval()
+ * 
+ * Subtract two absolute times to get a relative interval.
+ */
+static inline frsh_rel_time_t frsh_abs_time_extract_interval(frsh_abs_time_t past, frsh_abs_time_t future)
+{
+    return frsh_abs_time_extract_interval(past, future);
+}
+
+/**
+ * frsh_rel_time_times_integer()
+ * 
+ * Multiplies a relative time by an integer
+ */
+static inline frsh_rel_time_t frsh_rel_time_times_integer(frsh_rel_time_t time, long multiplier)
+{
+    return fosa_rel_time_times_integer(time, multiplier);
+}
+
+/**
+ * frsh_rel_time_times_integer()
+ * 
+ * Multiplies a relative time by an integer
+ **/
+static inline frsh_rel_time_t frsh_rel_time_divided_by_integer(frsh_rel_time_t time, long divider)
+{
+    return fosa_rel_time_divided_by_integer(time, divider);
+}
+
+
+/************************************
+ * Conversion to-from natural formats
+ * Note: Overflows may occur
+ ************************************/
+
+/**
+ * frsh_msec_to_rel_time()
+ *
+ * Convert an integer value of milliseconds into a relative time interval.
+ */
+static inline frsh_rel_time_t frsh_msec_to_rel_time(long msec)
+{
+    return fosa_msec_to_rel_time(msec);
+}
+
+/**
+ * frsh_rel_time_to_msec()
+ *
+ * Convert a relative interval into an integer number of milliseconds.
+ */
+static inline long frsh_rel_time_to_msec(frsh_rel_time_t interval)
+{
+    return fosa_rel_time_to_msec(interval);
+}
+
+/**
+ * frsh_msec_to_abs_time()
+ *
+ * Convert an integer value of milliseconds into an absolute time instant
+ */
+static inline frsh_abs_time_t frsh_msec_to_abs_time(long msec)
+{
+    return fosa_msec_to_abs_time(msec);
+}
+
+/**
+ * frsh_abs_time_to_msec()
+ *
+ * Convert an absolute instant into an integer number of milliseconds.
+ */
+static inline long frsh_abs_time_to_msec(frsh_abs_time_t instant)
+{
+    return fosa_abs_time_to_msec(instant);
+}
+
+/**
+ * frsh_usec_to_abs_time() 
+ *
+ * Convert an integer value of microseconds into an absolute instant.
+ */
+static inline frsh_abs_time_t frsh_usec_to_abs_time(long usec)
+{
+    return fosa_usec_to_abs_time(usec);
+}
+
+
+/**
+ * frsh_rel_time_to_usec() 
+ *
+ * Convert a relative interval into an integer number of microseconds.
+ */
+static inline long frsh_rel_time_to_usec(frsh_rel_time_t interval)
+{
+    return fosa_rel_time_to_usec(interval);
+}
+
+/******************************************
+ * Conversion to-from POSIX timespec format
+ ******************************************/
+
+/**
+ * frsh_timespec_to_rel_time()
+ * 
+ * Convert a POSIX timespec value into a relative time interval.
+ */
+static inline frsh_rel_time_t frsh_timespec_to_rel_time(struct timespec interval)
+{
+    return fosa_timespec_to_rel_time(interval);
+}
+
+/**
+ * frsh_rel_time_to_timespec() 
+ *
+ * Convert a relative interval into a POSIX timespec value.
+ */
+static inline struct timespec frsh_rel_time_to_timespec(frsh_rel_time_t interval)
+{
+    return fosa_rel_time_to_timespec(interval);
+}
+
+/**
+ * frsh_timespec_to_abs_time()
+ * 
+ * Convert a POSIX timespec value into an absolute time.
+ */
+static inline frsh_abs_time_t frsh_timespec_to_abs_time(struct timespec time)
+{
+    return fosa_timespec_to_abs_time(time);
+}
+
+/**
+ * frsh_abs_time_to_timespec()
+ * 
+ * Convert an absolute time into a POSIX timespec value.
+ */
+static inline struct timespec frsh_abs_time_to_timespec(frsh_abs_time_t time)
+{
+    return fosa_abs_time_to_timespec(time);
+}
+
+
 /**
  * frsh_eat()
  *
- * Eat some time using system clock facilities
+ * Keep the thread busy executing for a given period of time.
  **/
-static void inline frsh_eat(const struct timespec *cpu_time)
+static inline void  frsh_eat(frsh_rel_time_t *cpu_time)
 {
     fosa_eat(cpu_time);
 }
 
+/*@}*/
+
 FRSH_CPP_END_DECLS
 
 #endif             /* !FOSA_TIME_H_ */
similarity index 66%
rename from frsh_freelist.h
rename to frsh_time_types.h
index c6d6898d54f4e661123a85ba0564e3ac3d48c69e..92522302459b1a3b47ca0e62b8cf4b3340dfbd28 100644 (file)
 //        made of this code.
 //
 //
-//  This file is part of FRSH Implementation
+//  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
@@ -45,6 +55,7 @@
 //  reasons why the executable file might be covered by the GNU General
 //  Public License.
 // -----------------------------------------------------------------------
+//frsh_spare_capacity_types.h
 //==============================================
 //  ******** *******    ********  **      **
 //  **///// /**////**  **//////  /**     /**
 //
 // FRSH(FRescor ScHeduler), pronounced "fresh"
 //==============================================
-//
 
-// This header file defines the interface to a pair of functions used
-// to manage a sinly linked list that is used to find free cells in
-// some external table.
-//
-// Parallel to the external table, there is a table of indexes
-// organized as a singly linked list; it is the free list. A separate
-// index, free_cell, indicates which is the first element of the sibly
-// linked list. The list is terminated with an index of -1.
+#ifndef        FRSH_TIME_TYPES_H_
+#define        FRSH_TIME_TYPES_H_
 
 
-#ifndef FRSH_FREELIST
-#define FRSH_FREELIST
+/**
+ * @file frsh_time_types.h
+ **/
 
-typedef struct {
-  int * freelist;
-  int first_free;
-} frsh_freelist_t;
 
 /**
- *  Initialize a free list adding all the cells to the list of free cells
- *  The size of the list is specified by size.
- *  Returns: 0 if successful
- *           FRSH_ERR_NO_SPACE if there is not enough memory available
- */
-int frsh_freelist_init(frsh_freelist_t *list, int size);
+ * \addtogroup core
+ **/
+/*@{*/
 
-/**
- *  Obtain the index of a free cell from the free list specified by list
- *  the cell is removed from the list 
- *  Returns the index to the requested cell, or -1 if there are no free cells
- */
-int frsh_freelist_alloc(frsh_freelist_t *list);
+/** the time types shall have assignment and equal operators **/
+typedef fosa_abs_time_t frsh_abs_time_t;
+typedef fosa_rel_time_t frsh_rel_time_t;
 
 
-/**
- * Deallocate the cell specified by index cell adding it to the list
- * of free cells specified by list
- * Returns 0 if successful, or -1 if the cell was already free
- */
-int frsh_freelist_free(frsh_freelist_t *list, int cell);
+/*@}*/
 
-#endif // FRSH_FREELIST
+#endif             /* !FRSH_TIME_TYPES_H_ */
diff --git a/timespec_operations.h b/timespec_operations.h
deleted file mode 100644 (file)
index 2a4cf27..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-// -----------------------------------------------------------------------
-//  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.
-// -----------------------------------------------------------------------
-/*-----------------------------------------------------------------------
- *                                                         V1.0  Dec 2001
- *
- *                    't i m e s p e c _ o p e r a t i o n s'
- *
- *                                      H
- *
- * File 'timespec_operations.h'                                   by MAR.
- *                           (july 2002)  transformed into macros by Jul.
- * Some basic operations with the type 'timespec'.
- *
- * ----------------------------------------------------------------------
- *  Copyright (C) 2001   Universidad de Cantabria, SPAIN
- *
- *  Authors: Mario Aldea Rivas          aldeam@ctr.unican.es
- *           Michael Gonzalez Harbour      mgh@ctr.unican.es
- *
- * MaRTE OS  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.
- *
- * MaRTE OS  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 MaRTE  OS;  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  link this  unit  with other  files to
- * produce an   executable,   this unit  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 Public License.
- *
- *---------------------------------------------------------------------------*/
-// 16-Jul-2007 SANGORRIN corrections to msec_addto_timespec and msec2timespec
-// 23-Jul-2007 SANGORRIN moved t2d and d2t from frsh_time_operations
-// (TODO: test for __ALL__ the functions)
-// -----------------------------------------------------------------------
-
-#ifndef        _MARTE_MISC_TIMESPEC_OPERATIONS_H_
-#define _MARTE_MISC_TIMESPEC_OPERATIONS_H_
-
-/**
- * @file timespec_operations.h
- **/
-
-#include <time.h> // for timespec
-#include <string.h> // for memset
-
-#define smaller_timespec(t1, t2) \
- ( \
-  (t1)->tv_sec < (t2)->tv_sec || ((t1)->tv_sec == (t2)->tv_sec &&   \
-  (t1)->tv_nsec < (t2)->tv_nsec) \
- )
-
-#define smaller_or_equal_timespec(t1, t2) \
- ( \
-  (t1)->tv_sec < (t2)->tv_sec || ((t1)->tv_sec == (t2)->tv_sec &&    \
-  (t1)->tv_nsec <= (t2)->tv_nsec) \
- )
-
-#define incr_timespec(t1, t2) \
-do { \
-  (t1)->tv_sec += (t2)->tv_sec; \
-  (t1)->tv_nsec += (t2)->tv_nsec; \
-  if ((t1)->tv_nsec >= 1000000000) { \
-    (t1)->tv_sec ++; \
-    (t1)->tv_nsec -= 1000000000; \
-  } \
-} while (0)
-
-#define decr_timespec(t1, t2) \
-do { \
-  if ((t1)->tv_nsec < (t2)->tv_nsec) { \
-    (t1)->tv_sec -= (t2)->tv_sec + 1; \
-    (t1)->tv_nsec = (t1)->tv_nsec + 1000000000 - (t2)->tv_nsec; \
-  } else { \
-    (t1)->tv_sec -= (t2)->tv_sec; \
-    (t1)->tv_nsec -= (t2)->tv_nsec; \
-  } \
-} while (0)
-
-#define  add_timespec( sum , t1 , t2 ) \
-do { \
-  (sum)->tv_sec  = (t1)->tv_sec  + (t2)->tv_sec; \
-  (sum)->tv_nsec = (t1)->tv_nsec + (t2)->tv_nsec; \
-  if ((sum)->tv_nsec >= 1000000000) { \
-    (sum)->tv_sec ++; \
-    (sum)->tv_nsec -= 1000000000; \
-  } \
-} while (0)
-
-#define float_to_timespec( f1 , t1 ) \
-( \
-  (t1)->tv_sec = (int)(f1), \
-  (t1)->tv_nsec = (int)(((f1)-(float)((t1)->tv_sec))*1000000000.0), \
-  (t1) \
-)
-
-#define float_to_timespec_value(f1, t1) \
-( \
-  (t1).tv_sec = (int)(f1), \
-  (t1).tv_nsec = (int)(((f1)-(float)((t1).tv_sec))*1000000000.0), \
-  (t1) \
-)
-
-//---------------//
-// msec2timespec //
-//---------------//
-
-static inline struct timespec msec2timespec(long msec)
-{
-    struct timespec result = {-1, -1};
-
-    if (msec >= 1000) {
-        result.tv_sec = msec/1000;
-        result.tv_nsec = (msec % 1000) * 1000000;
-    } else {
-        result.tv_sec = 0;
-        result.tv_nsec = msec * 1000000;
-    }
-
-    return result;
-}
-
-static inline long timespec2msec(const struct timespec *timespec)
-{
-    
-    return (timespec->tv_sec % 2147482) * 1000 + timespec->tv_nsec/1000000;
-}
-
-
-#define HOURS_IN_MSECS 3600000
-#define MINUTES_IN_MSECS 60000
-
-#define HOURS_IN_TS     1000000
-#define MINUTES_IN_TS    100000
-
-static inline long timespec2msects(const struct timespec *timespec)
-{
-    long msec_total = -1;
-    long minutes = -1;
-    long hours = -1;
-
-    long remainder_msecs = -1;
-    long timestamp = -1;
-
-    msec_total = (timespec->tv_sec % 2147482) * 1000 + timespec->tv_nsec/1000000;
-
-    hours = msec_total / HOURS_IN_MSECS;
-    minutes = (msec_total % HOURS_IN_MSECS) / MINUTES_IN_MSECS;
-    remainder_msecs = ( (msec_total % HOURS_IN_MSECS) % MINUTES_IN_MSECS);
-    
-    timestamp = hours*HOURS_IN_TS + minutes*MINUTES_IN_TS + remainder_msecs;
-
-    return timestamp;
-}
-    
-
-//------------------------//
-// timespec_lessthan_msec //
-//------------------------//
-
-static inline int timespec_lessthan_msec(struct timespec *timespec, long msec)
-{
-    struct timespec msec_timespec = {0, 0};
-
-    msec_timespec = msec2timespec(msec);
-    return smaller_timespec(timespec, &msec_timespec);
-}
-
-//---------------------//
-// msec_addto_timespec //
-//---------------------//
-
-static inline void msec_addto_timespec(long msec, struct timespec *timespec)
-{
-    struct timespec msec_timespec = {0, 0};
-
-    msec_timespec = msec2timespec(msec);
-    incr_timespec(timespec, &msec_timespec);
-}
-
-//--------------------------//
-// t2d (timespec to double) //
-//--------------------------//
-
-static inline double t2d(struct timespec time)
-{
-    return time.tv_nsec*0.000000001 + (double)time.tv_sec;
-}
-
-//--------------------------//
-// d2t (double to timespec) //
-//--------------------------//
-
-static inline struct timespec d2t(double time)
-{
-    struct timespec tmp;
-
-    tmp.tv_sec = (long) time;
-    tmp.tv_nsec = (long)((time - (double)tmp.tv_sec) * 1000000000);
-
-    return tmp;
-}
-
-#endif /* _MARTE_MISC_TIMESPEC_OPERATIONS_H_ */