]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blobdiff - frsh_core.h
Update transaction API
[frescor/frsh-include.git] / frsh_core.h
index 227881451d1dd3ed7df5c3d881c01e7011b524fd..4681e05232278bacfebfa0d08a1983e465f61561 100644 (file)
@@ -1,5 +1,5 @@
 // -----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//  Copyright (C) 2006 - 2009 FRESCOR consortium partners:
 //
 //    Universidad de Cantabria,              SPAIN
 //    University of York,                    UK
 //   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
  *
  **/
 int frsh_init();
 
+/**
+ * frsh_destroy()
+ *
+ * Reverts the efect of frsh_init().
+ */
+void frsh_destroy();
+
 /*@}*/
 
 
@@ -194,6 +201,17 @@ int frsh_init();
 int frsh_contract_init(frsh_contract_t *contract);
 
 
+/**
+ * frsh_contract_destroy()
+ *
+ * The operation deallocates all memory which might be allocated for
+ * the contract.
+ *
+ * @param contract the pointer to the contract variable.
+ **/
+void frsh_contract_destroy(frsh_contract_t *contract);
+
+
 /**
  * frsh_contract_set_basic_params()
  *
@@ -215,14 +233,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 +264,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);
 
@@ -298,22 +316,6 @@ int frsh_contract_get_resource_and_label
  *                       this parameter is ignored (the contract value
  *                       will be NULL_DEADLINE internally). Otherwise, it
  *                       contains the desired deadline value.
- * @param [in] budget_overrun_signal contains the number of the signal
- *                that must be raised if the budget of the vres is overrun.
- *                If the value of this parameter is FRSH_NULL_SIGNAL, no signal will
- *                be raised.
- * @param [in] budget_overrun_siginfo contains the value that will be
- *               passed to the signal "catcher" when the signal is raised.
- *               This parameters is not used if the budget_overrun_signal
- *               parameter is set to FRSH_NULL_SIGNAL.
- * @param [in] deadline_miss_signal contains the number of the
- *               signal that must be raised if the deadline of the
- *               vres is missed. If the value of this parameter is
- *               FRSH_NULL_SIGNAL, no signal is raised.
- * @param [in] deadline_miss_siginfo contains the value that will be
- *                passed to the signal "catcher" when the signal is
- *                raised.  This parameter is not used if the
- *                deadline_signal parameter is set to NULL_SIGNAL
  *
  * @return  0 if successful\n
  *     FRSH_ERR_BAD_ARGUMENT :  if contract is NULL \b or \n
@@ -327,11 +329,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_signal_t          budget_overrun_signal,
-   const frsh_signal_info_t     budget_overrun_siginfo,
-   const frsh_signal_t          deadline_miss_signal,
-   const frsh_signal_info_t     deadline_miss_siginfo);
+   const frsh_rel_time_t        *deadline);
 
 /**
  * frsh_contract_get_timing_reqs()
@@ -347,11 +345,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_signal_t           *budget_overrun_signal,
-   frsh_signal_info_t      *budget_overrun_siginfo,
-   frsh_signal_t           *deadline_miss_signal,
-   frsh_signal_info_t      *deadline_miss_siginfo);
+   frsh_rel_time_t         *deadline);
 
 
 /*@}*/
@@ -521,8 +515,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 +547,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 +654,44 @@ 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 of a vres_id, 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(unsigned long period_num,
+                         frsh_rel_time_t       *next_budget,
+                         frsh_rel_time_t       *next_period,
+                         bool                  *was_deadline_missed,
+                         bool                  *was_budget_overran);
+
+
+/**
+ * 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);
+
+
+
+
 /*@}*/
 
 ///////////////////////////////////////////////////////////////////
@@ -817,6 +842,42 @@ int frsh_thread_create_in_background
      frsh_vres_id_t *vres_id);
 
 
+
+/**
+ * frsh_thread_join_in_background()
+ *
+ * This function is aimed for external threads to join FRSH in the
+ * least disturbing possible mode.
+ *
+ * Upon calling this function by a thread which has been created
+ * natively in the OS, it joins the framework and gets inmediately
+ * bound to an on-the-fly generated background contract.
+ *
+ * In order to gain a higher priority then it can renegotiate a
+ * contract for its vres with the needed parameters.
+ *
+ * @param[in] resource_id:   Resource (CPU) in which the vres will
+ *                           be associated.
+ *
+ * @param[in] resource_type: Resource type (should be CPU) for the
+ *                           contract.
+ *
+ * @param[in] label:         Label to be added to the contract.
+ *
+ * @param[out] vres_id:      Resulting vres_id from the on-the-fly
+ *                           generated background contract.
+ *
+ * @return  0 if successful\n
+ *          FRSH_ERR_NOT_CONTRACTED_VRES if the thread is already
+ *          bound to a vres.
+ **/
+int frsh_thread_join_in_background(frsh_resource_id_t resource_id,
+                                   frsh_resource_type_t resource_type,
+                                   const char *label,
+                                   frsh_vres_id_t *vres_id);
+
+
+
 /**
  * frsh_thread_bind()
  *
@@ -886,6 +947,38 @@ int frsh_thread_bind
  **/
 int frsh_thread_unbind(const frsh_thread_id_t thread);
 
+/**
+ * frsh_vres_set_notification()
+ *
+ * This function setups notification signals for CPU vres. It is
+ * necessary to call this function before bounding the thread to the
+ * vres.
+ * 
+ * @param [in] budget_overrun_signal contains the number of the signal
+ *                that must be raised if the budget of the vres is
+ *                overrun by the thread.
+ *                If the value of this parameter is FRSH_NULL_SIGNAL, no signal will
+ *                be raised.
+ * @param [in] budget_overrun_siginfo contains the value that will be
+ *               passed to the signal "catcher" when the signal is raised.
+ *               This parameters is not used if the budget_overrun_signal
+ *               parameter is set to FRSH_NULL_SIGNAL.
+ * @param [in] deadline_miss_signal contains the number of the
+ *               signal that must be raised if the deadline of the
+ *               vres is missed. If the value of this parameter is
+ *               FRSH_NULL_SIGNAL, no signal is raised.
+ * @param [in] deadline_miss_siginfo contains the value that will be
+ *                passed to the signal "catcher" when the signal is
+ *                raised.  This parameter is not used if the
+ *                deadline_signal parameter is set to NULL_SIGNAL
+ **/
+int frsh_vres_set_notification(
+       frsh_vres_id_t vres,
+       const frsh_signal_t          budget_overrun_signal,
+       const frsh_signal_info_t     budget_overrun_siginfo,
+       const frsh_signal_t          deadline_miss_signal,
+       const frsh_signal_info_t     deadline_miss_siginfo);
+
 /**
  * frsh_thread_get_vres_id()
  *
@@ -906,6 +999,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()
  *
@@ -1004,7 +1119,7 @@ int frsh_contract_cancel (const frsh_vres_id_t vres);
  *     running \n
  *   FRSH_ERR_NOT_CONTRACTED_VRES : if the vres of the calling thread
  *     has been cancelled or it is not valid \n
- *   FRSH_ERR_REJECTED_CONTRACT : if the renegotiation fails
+ *   FRSH_ERR_CONTRACT_REJECTED : if the renegotiation fails
  *
  **/
 int frsh_contract_renegotiate_sync
@@ -1106,71 +1221,19 @@ int frsh_vres_get_renegotiation_status
  * @{
  **/
 
-/**
- * frsh_group_negotiate()
- *
- * This function negotiates atomically a group of new contracts
- * while giving the possibility of cancellling others.
- *
- * If the on-line admission test is enabled, FRSH analizes the
- * schedulability of the context that results in the new contract
- * situation with removed and added contracts.
- *
- * If the overall negotiation is successful, all actions will be taken
- * inmediatly:  the creation of new vres for the contract_up list
- * and the cancellation of the designated ones.
- *
- * If for any reason one of the contracts is not accepted, a
- * corresponding error will be returned and no actions will be taken,
- * the previous context will be preserved.
- *
- * This call is a synchronous, potentially blocking operation.  It
- * returns when the system has rejected the contracts or accepted them
- * and made them effective.
- *
- * @param[in] contracts_up   List of new proposed contracts
- *
- * @param[in] vres_down   List of vres_id to be canceled
- *
- * @param[out] vres_up    vres_id assigned by the system to the
- *                           corresponding contracts_up.
- *
- * @return 0 if no error \n
- * .
- *   FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not
- *      running \n
- *   FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- *      main scheduler \n
- *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not scheduled
- *      under FRSH \n
- *   FRSH_ERR_BAD_ARGUMENT :  if any of the vres_up or accepted arguments
- *     is NULL, if the contracts_up and vres_down arguments are both NULL,
- *     or any of them has erroneous size or its elements are NULL or not in the
- *      valid range respectively
- **/
-int frsh_group_negotiate
-   (const frsh_contracts_group_t *contracts_up,
-    const frsh_vres_group_t   *vres_down,
-    frsh_vres_group_t         *vres_up);
-
-
-
 /**
  * frsh_group_change_mode_sync()
  *
- * An extension of frsh_group_negotiate() by adding the possibility of
- * specifying also group contract renegotiation and removal.
- *
- * NOTE:  This function will be implemented in a second phase after
- *        having fully implemented frsh_group_negotiate() in order to
- *        better grasp possible issues that the problems it may raise.
+ * This function performs a set of negotiation operations which can
+ * include: adding new contracts (neg), modifying existing vres (reneg)
+ * or cancelling existing vres (cancel).
  *
- *        This is a draft of the specification, it is yet subject to
- *        change.
+ * If one of the group operations has a NULL value, unless it causes an
+ * inconsistency the system will suppose that no operation of that
+ * type (neg, reneg or cancel) should be done.
  *
- * This operation performs a global (re)negotiation of a group of
- * contracts in an atomic way.  Contracts can be added, canceled or
- * renegotiated.  Note that any of the groups can be empty.
+ * The virtual resources resulting from negotiations of new contracts are
+ * returned in the parameter 'new_vres' which must be provided by the user.
  *
  * If the on-line admission test is enabled, FRSH analizes the
  * schedulability of the context that would  result in the new
@@ -1181,116 +1244,131 @@ int frsh_group_negotiate
  * update of vres) have been carried out to reach the new running
  * context.
  *
- * If for any reason one of the contracts is not accepted a
- * corresponding error shall be returned and no changes will be made
- * to the previously running context.
+ * If any of the contracts is not accepted a corresponding error shall be
+ * returned and no changes will be made to the previously running context.
  *
  * This call is a synchronous, potentially blocking operation.  It
- * returns when the system has rejected the contracts or accepted them
- * and made them effective.  There is also an asynchronous
- * (non-blocking) version of this function below.
- *
- * @param[in]  contracts_new_vres  Contracts to be added.
- * @param[out] vres_id_new  vres_id's corresponding to the new
- *                                    contracts.
- * @param[in]  contracts_update_vres New contracts for vres to
- *                                    be updated.
- * @param[in]  vres_update  vres_id's corresponding to the
- *                              contracts that have to be updated.
- * @param[in]  vres_removed Vres_id's to be removed.
+ * returns when the system has rejected the contracts or accepted
+ * and made them effective.
+ *
+ * @param[in] contracts_to_neg    List of new contracts to negotiate
+ * @param[in] contracts_to_reneg  List of contracts to renegotiate
+ * @param[in] vres_to_reneg       List of vres to renegotiate
+ * @param[in] vres_to_cancel      List of vres to cancel
+ * @param[out] new_vres           List of vres of new contracts.
  *
  * @return 0 if no error \n
- *    FRSH_ERR_BAD_ARGUMENT Invalid pointer or vres_id ranges. \n
+ *    FRSH_ERR_BAD_ARGUMENT Invalid pointer or group identifier. \n
  *    FRSH_ERR_CONTRACT_LABEL_ALREADY_EXISTS contract_label not unique. \n
- *    FRSH_ERR_NOT_CONTRACTED_VRES: One of the provided
- *                          vres_ids is not recognised. \n
+ *    FRSH_ERR_NOT_CONTRACTED_VRES: One of the provided vres_ids
+ *       is not recognised. \n
  *    FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD The calling thread
- *                           is not scheduled under FRSH. \n
- *    FRSH_ERR_INVALID_SCHEDULER_REPLY: The scheduler is wrong
- *                           or not running. \n
+ *       is not scheduled under FRSH. \n
+ *    FRSH_ERR_INVALID_SCHEDULER_REPLY: The scheduler is wrong or
+ *       not running. \n
  *    FRSH_ERR_INTERNAL_ERROR:  Erroneous binding or malfunction of
- *                           FRSH main scheduler. \n
+ *       FRSH main scheduler. \n
  *    FRSH_ERR_REJECTED_CONTRACT:  The negotiation of one of the
- *                           proposed contracts has failed.
- *
+ *       proposed contracts has failed.
  **/
 int frsh_group_change_mode_sync
-    (const frsh_contracts_group_t *contracts_new_vres,
-     frsh_vres_group_t *vres_id_new,
-     const frsh_contracts_group_t *contracts_update_vres,
-     const frsh_vres_group_t *vres_update,
-     const frsh_vres_group_t *vres_removed);
-
+                            (const frsh_contracts_group_t *contracts_to_neg,
+                             const frsh_contracts_group_t *contracts_to_reneg,
+                             const frsh_vres_group_t      *vres_to_reneg,
+                             const frsh_vres_group_t      *vres_to_cancel,
+                             frsh_vres_group_t            *new_vres);
 
 /**
  * frsh_group_change_mode_async()
  *
- * This operation enqueues a global renegotiation of a group of
- * contracts (with a possible addition of new vres) and returns
- * immediately.  The renegotiation is performed asynchronously as soon
- * as it is practical.
- *
- * NOTE:  This function will be implemented in a second phase after
- *        having fully implemented frsh_group_negotiate() in order to
- *        better grasp possible issues that the problem may raise.
- *
- *        This is a draft of the specification, it is yet subject to
- *        change.
- *
- * This is an asynchronous (non-blocking) version of
- * frsh_group_change_mode_sync().  Note however that there must
- * be at least one existing thread involved in the operation (to be
- * canceled or have its contract updated).  An operation of puring
- * adding a group of new contracts can only be done synchronously.
- *
- * The status of the operation (in progress, admitted or rejected) can
- * be queried via frsh_vres_get_renegotiation_status() invoked for any of
- * the vres involved in the renegotiation (updated or to be
- * removed).  As an option, a signal can be sent to the caller to
- * notify the end-result  of the operation.
- *
- * @param[in]  contracts_new_vres  Contracts for new vres to be
- *                                    added.
- * @param[in]  contract_labels Contract labels for the corresponding new
- *                          vres to be added.
- * @param[out] vres_id_new  vres_id's corresponding to the new
- *                                    contracts.
- * @param[in]  contracts_update_vres New contracts for vres to
- *                                    be updated.
- * @param[in]  vres_update  vres_id's corresponding to the
- *                              contracts that have to be updated.
- * @param[in]  vres_removed vres_id's to be removed.
- *
- * @param[in] sig_notify  Signal number where the coller expects to
- *                        receive the information.
- * @param[in] sig_value   Signal data associated with that signal.
+ * This is an asynchronous (non-blocking) version of the previous function,
+ * frsh_group_change_mode_sync() and thus, it returns inmediately.
+ *
+ * The status of the change of mode and the identifiers for new virtual
+ * resources must be requested with the function 'frsh_group_get_status'
+ * by using the return parameter 'group'.
+ *
+ * As in the asynchronous renegotiations, when the operation is completed,
+ * the user is notified with a signal so he can check the final result with
+ * 'frsh_group_get_status'. In case that FRSH_NULL_SIGNAL is used, no
+ * signal will be sent to the user.
+ *
+ * @param[in] contracts_to_neg    List of new contracts to negotiate
+ * @param[in] contracts_to_reneg  List of contracts to renegotiate
+ * @param[in] vres_to_reneg       List of vres to renegotiate
+ * @param[in] vres_to_cancel      List of vres to cancel
+ * @param[in] signal              Signal number to notify completion of
+ *                                the change of mode. If FRSH_NULL_SIGNAL,
+ *                                no signal will be raised.
+ * @param[in] signal_info         Data associated to the signal
+ * @param[out] group              The group identifier to get the status
  *
  * @return 0 if no error \n
- *    FRSH_ERR_BAD_ARGUMENT Invalid pointer or vres_id ranges.  Also
- *           when the request is for adding only new contracts. \n
+ *    FRSH_ERR_BAD_ARGUMENT Invalid pointer, signal or group identifier. \n
  *    FRSH_ERR_CONTRACT_LABEL_ALREADY_EXISTS contract_label not unique. \n
- *    FRSH_ERR_NOT_CONTRACTED_VRES: One of the provided
- *                            vres_id's is not recognised. \n
+ *    FRSH_ERR_NOT_CONTRACTED_VRES: One of the provided vres_ids
+ *       is not recognised. \n
  *    FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD The calling thread
- *                           is not scheduled under FRSH. \n
- *    FRSH_ERR_INVALID_SCHEDULER_REPLY: The scheduler is wrong
- *                           or not running. \n
+ *       is not scheduled under FRSH. \n
+ *    FRSH_ERR_INVALID_SCHEDULER_REPLY: The scheduler is wrong or
+ *       not running. \n
  *    FRSH_ERR_INTERNAL_ERROR:  Erroneous binding or malfunction of
- *                           FRSH main scheduler. \n
- *    FRSH_ERR_REJECTED_CONTRACT:  The negotiation of one of the
- *                           proposed contracts has failed.
+ *       FRSH main scheduler.
  **/
 int frsh_group_change_mode_async
-    (const frsh_contracts_group_t *contracts_new_vres,
-     frsh_vres_group_t *vres_id_new,
-     const frsh_contracts_group_t *contracts_update_vres,
-     const frsh_vres_group_t *vres_update,
-     const frsh_vres_group_t *vres_removed,
-     const frsh_signal_t         signal_notify,
-     const frsh_signal_info_t    signal_info);
+                            (const frsh_contracts_group_t *contracts_to_neg,
+                             const frsh_contracts_group_t *contracts_to_reneg,
+                             const frsh_vres_group_t      *vres_to_reneg,
+                             const frsh_vres_group_t      *vres_to_cancel,
+                             const frsh_signal_t          signal,
+                             const frsh_signal_info_t     signal_info,
+                             frsh_group_id_t              *group);
+
+/**
+ * frsh_group_get_status()
+ *
+ * This function is similar to 'frsh_vres_get_renegotiation_status' but it
+ * is intented for group negotiations (changes of mode).
+ *
+ * The operation reports on the status of the last negotiation
+ * operation enqueued for the specified group identifier.
+ *
+ * The status value can be one of the following values:
+ *
+ *    - FRSH_RS_IN_PROGRESS: the change of mode is in progress
+ *    - FRSH_RS_REJECTED: the change of mode was not accepted
+ *    - FRSH_RS_ADMITTED: the change of mode was accepted
+ *    - FRSH_RS_NOT_REQUESTED: no change of mode has been requested yet
+ *
+ * When status returns 'FRSH_RS_ADMITTED', the array 'new_vres' contains
+ * the values for the new virtual resources (if there was any).
+ *
+ * This function frees the group identifier when status returns something
+ * different than FRSH_RS_IN_PROGRESS so further calls to this function may
+ * return inconsistent values.
+ *
+ * @param[in]  group     The group identifier
+ * @param[out] status    The status of the change of mode
+ * @param[out] new_vres  List of vres for the negotiation of new contracts.
+ *
+ * @return 0 if no error \n
+ *    FRSH_ERR_BAD_ARGUMENT Invalid pointer, signal or group identifier. \n
+ *    FRSH_ERR_CONTRACT_LABEL_ALREADY_EXISTS contract_label not unique. \n
+ *    FRSH_ERR_NOT_CONTRACTED_VRES: One of the provided vres_ids
+ *       is not recognised. \n
+ *    FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD The calling thread
+ *       is not scheduled under FRSH. \n
+ *    FRSH_ERR_INVALID_SCHEDULER_REPLY: The scheduler is wrong or
+ *       not running. \n
+ *    FRSH_ERR_INTERNAL_ERROR:  Erroneous binding or malfunction of
+ *       FRSH main scheduler.
+ **/
+int frsh_group_get_status(const frsh_group_id_t       group,
+                          frsh_renegotiation_status_t *status,
+                          frsh_vres_group_t           *new_vres);
 
-/*@}*/
 
+/*@}*/
 
 
 ////////////////////////////////////////////////////
@@ -1339,7 +1417,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 +1451,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 +1475,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 +1533,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 +1555,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 +1582,19 @@ int frsh_service_thread_get_data
 //threads
 
 
+////////////////////////////////////////////////////////////////////////
+//           OTHER
+////////////////////////////////////////////////////////////////////////
 
+/**
+ * Returns resource id of local CPU.
+ *
+ * The ID is determined from environment variable FRSH_CPU_ID or, if
+ * that is not defined, the compile time default (defined in
+ * config.target/omk).
+ */
+frsh_resource_id_t frsh_get_local_cpu_id(void);
 
+FRSH_CPP_END_DECLS
 
 #endif // _FRSH_CORE_H_