]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blobdiff - frsh_core.h
Memory contract management V2
[frescor/frsh-include.git] / frsh_core.h
index 227881451d1dd3ed7df5c3d881c01e7011b524fd..d3d443ab3ebd6b4c8dfd14405917d9c5f13c1bd4 100644 (file)
@@ -1,5 +1,5 @@
 // -----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
 //
 //    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
+//   This file is part of FRSH (FRescor ScHeduler)
 //
-//  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 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.
 //
-//  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.
+//  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.
 // -----------------------------------------------------------------------
 
 //==============================================
@@ -84,6 +81,9 @@
 #include "frsh_core_types.h"
 #include "frsh_spare_capacity.h"
 
+
+FRSH_CPP_BEGIN_DECLS
+
 /**
  * @defgroup core Core module
  *
@@ -215,14 +215,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);
 
@@ -246,8 +246,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);
 
@@ -327,7 +327,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,
@@ -347,7 +347,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,
@@ -521,8 +521,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);
 
@@ -553,10 +553,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);
 
@@ -660,13 +660,42 @@ 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);
 
 
+
+/**
+ * frsh_vresperiod_wait()
+ * 
+ * Suspend the calling thread until the start of the specified virtual
+ * resource period, for a synchronized workload.
+ * 
+ * Virtual resource periods are numbered. The number of the current
+ * period can be obtained through the frsh_vres_get_period_number()
+ * operation. 
+ **/
+int frsh_vresperiod_wait
+   (const frsh_vres_id_t vres,
+    long period_num);
+
+
+/**
+ * frsh_vres_get_period()
+ * 
+ * Return the current period number, for a virtual resource of
+ * synchronized workload.
+ **/
+int frsh_vres_get_period_number
+   (const frsh_vres_id_t vres,
+    long *period_num);
+
+
+
+
 /*@}*/
 
 ///////////////////////////////////////////////////////////////////
@@ -906,6 +935,28 @@ int frsh_thread_unbind(const frsh_thread_id_t thread);
 int frsh_thread_get_vres_id(const frsh_thread_id_t       thread,
                     frsh_vres_id_t *vres_id);
 
+/**
+ * frsh_vres_get_priority()
+ *
+ * This operation stores the priority currently associated
+ * with the specified vres in the variable pointed to by
+ * priority. It returns an error if the vres_id is not recognised.
+ *
+ * @return 0 if no error \n
+ *   FRSH_ERR_BAD_ARGUMENT :  if the contract argument is NULL or the value
+ *     of the vres argument is not in range \n
+ *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
+ *     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 of the calling thread
+ *     has been cancelled or it is not valid
+ *
+ **/
+int frsh_vres_get_priority
+     (frsh_vres_id_t            vres_id,
+      int *priority);
+
 /**
  * frsh_vres_get_contract()
  *
@@ -1339,7 +1390,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()
@@ -1361,7 +1424,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);
 
 
 /**
@@ -1385,8 +1448,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);
 
 /*@}*/
 
@@ -1443,8 +1506,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);
 
 /**
@@ -1465,8 +1528,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);
 
 
 /*@}*/
@@ -1492,7 +1555,6 @@ int frsh_service_thread_get_data
 //threads
 
 
-
-
+FRSH_CPP_END_DECLS
 
 #endif // _FRSH_CORE_H_