// -----------------------------------------------------------------------
-// Copyright (C) 2005 Mälardalen University, SWEDEN
+// Copyright (C) 2006 - 2008 FRESCOR consortium partners:
+//
+// Universidad de Cantabria, SPAIN
+// University of York, UK
+// Scuola Superiore Sant'Anna, ITALY
+// Kaiserslautern University, GERMANY
+// Univ. Politécnica Valencia, SPAIN
+// Czech Technical University in Prague, CZECH REPUBLIC
+// ENEA SWEDEN
+// Thales Communication S.A. FRANCE
+// Visual Tools S.A. SPAIN
+// Rapita Systems Ltd UK
+// Evidence ITALY
+//
+// See http://www.frescor.org for a link to partners' websites
+//
+// FRESCOR project (FP6/2005/IST/5-034026) is funded
+// in part by the European Union Sixth Framework Programme
+// The European Union is not liable of any use that may be
+// made of this code.
+//
+//
+// 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
//
-// FRSH API web pages: http://marte.unican.es/frsh/docs/
+// 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.
+// This file is part of FRSH (FRescor ScHeduler)
//
-// 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.
+// 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.
//
-// 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.
// -----------------------------------------------------------------------
-//frsh_core.h
-//=================================================================
-// FFFFFFIII RRRRR SSTTTTTTT
-// FF IIR RR SS
-// FF IR SS
-// FFFFFF RRRR SSSSST
-// FF FI RRR SS
-// FF II RRR SS
-// FF IIIIIR RS
-//
-// Basic FRSH(FIRST Scheduling Framework) contract management
-//================================================================
-/**
- \defgroup core Core module
+//==============================================
+// ******** ******* ******** ** **
+// **///// /**////** **////// /** /**
+// ** /** /** /** /** /**
+// ******* /******* /********* /**********
+// **//// /**///** ////////** /**//////**
+// ** /** //** /** /** /**
+// ** /** //** ******** /** /**
+// // // // //////// // //
+//
+// FRSH(FRescor ScHeduler), pronounced "fresh"
+//==============================================
- This module includes the basic functions and services that are
- provided by any FRSH implementation. This module includes basic type
- definitions, and functions to
+#ifndef _FRSH_CORE_H_
+#define _FRSH_CORE_H_
- - create a contract and initialize it
- - set/get the basic parameters of a contract
- - negotiate a service contract, obtaining a server id
- - create and bind threads to servers
- - create/destroy a synchronization object
- - manage bounded workloads
-*/
-/*@{*/
/**
- \file frsh_core.h
+ * @file frsh_core.h
+ **/
- This file contains the types, definitions and function prototypes
- for the core module of the First Scheduling Framework.
- */
#include <time.h>
-#include <pthread.h>
#include <sys/types.h>
-#include "stdbool.h"
-#include "frsh_configuration_parameters.h"
-#include "frsh_opaque_types.h"
-#include "frsh_basic_types.h"
+#include "frsh_core_types.h"
+#include "frsh_spare_capacity.h"
-#ifndef _FRSH_CORE_H_
-#define _FRSH_CORE_H_
+FRSH_CPP_BEGIN_DECLS
-/////////////////////////////////////////////////////////////////
-// BASIC TYPES AND CONSTANTS are in frsh_basic_types.h
-/////////////////////////////////////////////////////////////////
+/**
+ * @defgroup core Core module
+ *
+ * This module includes the basic functions and services that are
+ * provided by any FRSH implementation. This module includes basic type
+ * definitions, and functions to
+ *
+ * - create a contract and initialize it
+ * - set/get the basic parameters of a contract
+ * - negotiate a service contract, obtaining a vres id
+ * - create and bind threads to vres
+ * - create/destroy a synchronization object
+ * - manage bounded workloads
+ *
+ **/
+//////////////////////////////////////////////////////////////////////
+// INITIALIZATION SERVICES
+//////////////////////////////////////////////////////////////////////
+
+/**
+ * @defgroup initialization Initialization services
+ * @ingroup core
+ *
+ * These functions need to be called before doing any FRSH operation
+ * (including contract initialization).
+ *
+ * @{
+ **/
+
+
+/**
+ * frsh_init()
+ *
+ * We cannot call any frsh functions before frsh_init. After calling
+ * frsh_init, the main will be executing in the background. Then, it
+ * can do the negotiations and create new threads if needed. The
+ * second time this function is called it fails.
+ *
+ * @return 0 if no error. \n
+ * FRSH_ERR_SYSTEM_ALREADY_INITIALIZED : if the function has already
+ * been called before\n
+ * .
+ * It may also return any of the errors that may be returned by the
+ * underlying operating system primitives required to perform the
+ * FRSH system start up
+ *
+ **/
+int frsh_init();
+
+/*@}*/
-/**
- This function converts an error code to an error message that is
- stored in the buffer starting at the location pointed to by
- message. The size of this buffer is specified by the size
- argument. If the error message is longer than size-1, it is
- truncated to that length. Regardless of whether the message is
- truncated or not, a final zero character that marks the end of the
- string is stored in the buffer. The function fails if the error
- code passed does not correspond to any of the frsh error codes.
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : error is not a valid value
- ]
-*/
-int frsh_strerror (int error, char *message, size_t size);
/////////////////////////////////////////////////////////////
// CONTRACT PARAMETERS
/////////////////////////////////////////////////////////////
+/**
+ * @defgroup contract Contract Creation and Initialization.
+ * @ingroup core
+ *
+ * These functions are used to create and initialize a contract, and
+ * set its parameters.
+ *
+ * @{
+ **/
+
/**
- \defgroup contract Contract Creation and Initialization.
-
- These functions are used to create and initialize a contract, and
- set its parameters.
- */
-/*@{*/
-/**
- Contract parameters type; it is an opaque type (i.e. the internal
- structure of this data type is implementation dependent). The user
- can access and modify the parameters of a contract only with the
- proper functions, and should never access the data directly.
-*/
-typedef FRSH_CONTRACT_PARAMETERS_T_OPAQUE frsh_contract_parameters_t;
-
-/**
- The operation receives a pointer to a contract parameters object
- and initializes it, setting it to the default values.
- The default values are:
- - budget min and max are set to 0
- - period min and max are set to 0
- - the workload is unbounded (FRSH_INDETERMINATE)
- - the server deadline is equal to the period
- - the budget and deadline overrun are not notified
- - the granularity is set to "continuous"
- - the quality and importance are set to the default values
- (PEPPE: implementation dependent??)
- - the scheduling policy is FRSH_NONE
-
- @param contract the pointer to the contract variable.
- @returns (PEPPE: should not return anything! change to void??)
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : contract is NULL
- ]
-*/
-int frsh_initialize_contract (frsh_contract_parameters_t *contract);
-
-// budget_min => {0,0};
-// period_max => {0,0};
-// budget_max => {0,0};
-// period_min => {0,0};
-// workload => DEFAULT_WORKLOAD;
-
-// d_equals_t => DEFAULT_D_EQUALS_T; (false or true)
-// deadline => DEFAULT_DEADLINE;
-// budget_overrun_sig_notify => 0; (signal number)
-// budget_overrun_sig_value => {0, NULL};
-// deadline_miss_sig_notify => 0; (signal number)
-// deadline_miss_sig_value => {0, NULL};
-//
-// granularity => DEFAULT_GRANULARITY;
-// utilization_set; => size = 0
-// quality => DEFAULT_QUALITY; (range 0..100)
-// importance => DEFAULT_IMPORTANCE; (range 1..5)
-//
-// preemption_level => 0; (range 1..2**32-1)
-// critical_sections; => size = 0
-
-// sched_policy => DEFAULT_SCHED_POLICY
-// (FRSH_NONE)
-
-
-/**
- The operation updates the specified contract parameters object by
- setting its budget, period, and workload to the specified input
- parameters. (Note: the workload is a basic parameter because
- bounded tasks are triggered by the scheduler (see the
- frsh_schedule_timed_job() operation), while indeterminate tasks are
- not; therefore, their programming model is quite different).
-
- @param contract the pointer to the contract object
- @param [in] budget_min the minimum budget for the contract
- @param [in] period_max the maximum period for the contract
- @param [in] workload the kind of workload (can be FRSH_BOUNDED,
- FRSH_INDETERMINATE or FRSH_OVERHEAD)
-
- @returns 0 if the operation is succesful
- @returns FRSH_ERR_BAD_ARGUMENT if some of the arguments is not in
- the expected range
- [ERR@RETURNED:
- 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 workload
- is not a proper value (FRSH_INDETERMINATE, FRSH_BOUNDED, or FRSH_OVERHEAD)
- ]
-*/
-int
-frsh_set_contract_basic_parameters
- (frsh_contract_parameters_t *contract,
- const struct timespec *budget_min,
- const struct timespec *period_max,
- frsh_workload_t workload);
+ * frsh_contract_init()
+ *
+ * The operation receives a pointer to a contract object
+ * and initializes it, setting it to the default values.
+ *
+ * The default values are:
+ *
+ * - resource_id => 0
+ * - ressource_type => FRSH_CRT_PROCESSOR
+ * - contract_label => ""
+ * - budget_min => {0,0};
+ * - period_max => {0,0};
+ * - budget_max => {0,0};
+ * - period_min => {0,0};
+ * - workload => FRSH_WT_INDETERMINATE
+ * - d_equals_t => true
+ * - contract_type => FRSH_CT_REGULAR;
+ * - deadline => {0,0};
+ * - budget_overrun_signal => 0; (signal number)
+ * - budget_overrun_siginfo => {0, NULL};
+ * - deadline_miss_signal => 0; (signal number)
+ * - deadline_miss_siginfo => {0, NULL};
+ *
+ * - granularity => DEFAULT_GRANULARITY;
+ * - utilization_set; => size = 0
+ * - quality => DEFAULT_QUALITY; (range 0..100)
+ * - importance => DEFAULT_IMPORTANCE; (range 1..5)
+ * - preemption_level => 0; (range 1..2**32-1)
+ * - critical_sections; => size = 0
+ *
+ * - sched_policy => DEFAULT_SCHED_POLICY (FRSH_NONE)
+ *
+ * @param contract the pointer to the contract variable.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : contract is NULL
+ *
+ **/
+int frsh_contract_init(frsh_contract_t *contract);
+
+
+/**
+ * frsh_contract_set_basic_params()
+ *
+ * The operation updates the specified contract parameters object by
+ * setting its budget, period, workload and type to the specified
+ * input parameters. (Note: the workload is a basic parameter because
+ * bounded tasks are triggered by the scheduler (see the
+ * frsh_timed_wait() and frsh_synchobj_wait* operations), while
+ * indeterminate tasks are not; therefore, their programming model is
+ * quite different).
+ *
+ * @param contract the pointer to the contract object
+ * @param[in] budget_min the minimum budget for the contract
+ * @param[in] period_max the maximum period for the contract
+ * @param[in] workload the kind of workload (can be FRSH_WT_BOUNDED,
+ * FRSH_WT_INDETERMINATE or FRSH_OVERHEAD)
+ * @param[in] contract_type can be FRSH_CT_REGULAR,
+ * FRSH_CT_BACKGROUND, FRSH_CT_DUMMY.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if any of the pointers is NULL
+ * 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 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);
+
+/**
+ * frsh_contract_get_basic_params()
+ *
+ * This operation obtains from the specified contract object its
+ * budget, period, and workload, and copies them to the places pointed
+ * to by the corresponding output parameters.
+ *
+ * @param[in] contract the pointer to the contract object
+ * @param[out] budget_min pointer to preallocated space
+ * @param[out] period_max pointer to preallocated space
+ * @param[out] workload pointer to preallocated space
+ * @param[out] contract_type pointer to preallocated space
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if one of the contract or
+ * pointers is NULL.
+ *
+ **/
+int frsh_contract_get_basic_params
+ (const frsh_contract_t *contract,
+ frsh_rel_time_t *budget_min,
+ frsh_rel_time_t *period_max,
+ frsh_workload_t *workload,
+ frsh_contract_type_t *contract_type);
+
+/**
+ * frsh_contract_set_resource_and_label()
+ *
+ * Specify resource_id and type, and the contract label. Otherwise
+ * default values will apply. If the contract label is too long it is truncated
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if the contract pointer is NULL.
+ **/
+int frsh_contract_set_resource_and_label
+ (frsh_contract_t *contract,
+ const frsh_resource_type_t resource_type,
+ const frsh_resource_id_t resource_id,
+ const char *contract_label);
+
+
+/**
+ * frsh_contract_get_resource_and_label()
+ *
+ * Obtain the resource_id and type, and the contract label.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if the contract or the contract_label
+ * pointer is NULL.
+ **/
+int frsh_contract_get_resource_and_label
+ (const frsh_contract_t *contract,
+ frsh_resource_type_t *resource_type,
+ frsh_resource_id_t *resource_id,
+ char *contract_label);
/**
- This operation obtains from the specified contract parameters
- object its budget, period, and workload, and copies them to the
- places pointed to by the corresponding input parameters.
-
- @param [in] contract the pointer to the contract object
- @param[out] budget_min pointer to the variable that will contain
- the minimum budget
- @param[out] period_max pointer to the variable that will contain the
- max_period
- @param[out] workload pointer to the variable that will contain the
- workload type
-
- @returns (PEPPE: this should return nothing!)
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if contract is NULL
- ]
-*/
-int
-frsh_get_contract_basic_parameters
- (const frsh_contract_parameters_t *contract,
- struct timespec *budget_min,
- struct timespec *period_max,
- frsh_workload_t *workload);
-
-
-/**
- The operation updates the specified contract parameters
- object, specifying the additional parameters requirements of
- a contract.
-
- @param contract The pointer to the contract object
-
- @param [in] d_equals_t It is a boolean value, set to true (1) if the
- we want to specify a deadline different from the period
- for the contract.
- @param [in] deadline If the previous parameter is set to true,
- this parameter should be set to NULL_DEADLINE. Otherwise,
- it contains the desired deadline value.
- (PEPPE: should be return with error otherwise?)
- @param [in] budget_overrun_sig_notify contains the number of posix signal
- that must be raised if the budget of the server is overrun.
- If the value of this parameter is NULL_SIGNAL, no signal will
- be raised.
- @param [in] budget_overrun_sig_value 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_sig_notify
- parameters is set to NULL_SIGNAL.
- @param [in] deadline_miss_sig_notify contains the number of posix
- signal that must be raised if the deadline of the server
- is missed. If the value of this parameter is NULL_SIGNAL,
- no signal is raised.
- @param [in] deadline_miss_sig_value 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_sig_notify
- parameters is set to NULL_SIGNAL
-
- @returns 0 if the operation is succesful
- @returns FRSH_BAD_ARGUMENT if some argument is out of range or not
- admissible.
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if contract is NULL or
- (d_equals_t is true and deadline is not FRSH_NULL_DEADLINE) or
- (budget_overrun_sig_notify is not a valid signal) or
- (deadline_miss_sig_notify is not a valid signal) or
- (d_equals_t is false but (deadline is FRSH_NULL_DEADLINE or its value
- is grater than the contract´s maximum period)))
- ]
-
- @see sigexplanation
-*/
-int
-frsh_set_contract_timing_requirements
- (frsh_contract_parameters_t *contract,
- bool d_equals_t,
- const struct timespec *deadline,
- int budget_overrun_sig_notify,
- union sigval budget_overrun_sig_value,
- int deadline_miss_sig_notify,
- union sigval deadline_miss_sig_value);
+ * frsh_contract_set_timing_reqs()
+ *
+ * The operation updates the specified contract object, specifying
+ * additional time-related requirements.
+ *
+ * @param contract The pointer to the contract object
+ *
+ * @param [in] d_equals_t It is a boolean value, set to true (1) if
+ * we want to specify a deadline different from
+ * the period for the contract.
+ * @param [in] deadline If the previous parameter is set to true,
+ * 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
+ * (d_equals_t is true and deadline is not FRSH_NULL_DEADLINE) \b or \n
+ * (budget_overrun_signal is not a valid signal) \b or \n
+ * (deadline_miss_signal is not a valid signal) \b or \n
+ * (d_equals_t is false but (deadline is FRSH_NULL_DEADLINE or its value
+ * is grater than the contract's maximum period))
+ *
+ **/
+int frsh_contract_set_timing_reqs
+ (frsh_contract_t *contract,
+ const bool d_equals_t,
+ 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,
+ const frsh_signal_info_t deadline_miss_siginfo);
/**
- The operation obtains the corresponding input parameters from the
- specified contract parameters object. If d_equals_t is true, the
- deadline will not be updated.
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if contract is NULL
- ]
-
-*/
-int
-frsh_get_contract_timing_requirements
- (const frsh_contract_parameters_t *contract,
+ * frsh_contract_get_timing_reqs()
+ *
+ * The operation obtains the corresponding input parameters from the
+ * specified contract object. If d_equals_t is true, the deadline will
+ * be set to FRSH_NULL_DEADLINE.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if contract is NULL
+ *
+ **/
+int frsh_contract_get_timing_reqs
+ (const frsh_contract_t *contract,
bool *d_equals_t,
- struct timespec *deadline,
- int *budget_overrun_sig_notify,
- union sigval *budget_overrun_sig_value,
- int *deadline_miss_sig_notify,
- union sigval *deadline_miss_sig_value);
+ frsh_rel_time_t *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);
+
/*@}*/
//////////////////////////////////////////////////////////////////
// SYNCHRONIZATION OBJECTS
//////////////////////////////////////////////////////////////////
-
-
/**
- \defgroup synch Synchronization objects
-*/
-/*@{*/
-/**
- An abstract synchronization object is defined by the application.
- This object can be used by an application to wait for an event to
- arrive by invoking the frsh_schedule_triggered_job() operation. It
- can also be used to signal the event either causing a waiting
- server to wake up, or the event to be queued if no server is
- waiting for it.
-*/
-typedef FRSH_SYNCH_OBJ_HANDLE_T_OPAQUE frsh_synch_obj_handle_t;
+ * @defgroup synch Synchronization objects
+ * @ingroup core
+ *
+ * Synchronisation objects provide an alternative to timers for
+ * bounded-workload vres to signal the end of their current job and
+ * return their remaining budget to FRSH.
+ *
+ * Instead of asking to be reactivated based on an absolute time, they
+ * queue themselves in a synchronisation object and will wait there
+ * until another vres (bounded-workload or indeterminate-workload)
+ * wakes them up with a signal call the earliest at the beginning of
+ * the next period.
+ *
+ * Indeterminate-workload vres cannot queue themselves here because
+ * they don't have any budget to return. However they can signal on
+ * the objects to activate a waiting workload vres.
+ *
+ * For classical signal/wait synchronisation paradigms the application
+ * must use whatever mechanism the underlying OS provides.
+ *
+ * In the future we may add a broadcast operation that would signal a
+ * group of synchronization objects. We have not included a broadcast
+ * service in this version because it can be easily created by the
+ * user by signalling individual synchronization objects inside a
+ * loop.
+ *
+ * Notice that for synchronization objects there is no naming service
+ * like in shared objects because tasks that use synchronization are
+ * not developed independently, as they are closely coupled.
+ *
+ * @{
+ **/
/**
- This operation creates and initializes a synchronization object
- variable managed by the scheduler, and returns a handle to it in
- the variable pointed to by synch_handle.
-
- @param[out] pointer to the variable that will contain the handle to the
- newly created synchronization object
-
- @returns 0 if the operation is succesful
- @returns FRSH_ERR_TOO_MANY_SYNCH_OBJS if the number of synchronization
- objects in the system has already exceeded the maximum
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if synch_handle is 0
- FRSH_ERR_TOO_MANY_SYNCH_OBJS : if the number of synchronization
- objects in the system has already exceeded the maximum
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- ]
-
-*/
-int
-frsh_create_synch_obj
- (frsh_synch_obj_handle_t *synch_handle);
+ * frsh_synchobj_create()
+ *
+ * This operation creates and initializes a synchronization object
+ * variable managed by the scheduler, and returns a handle to it in
+ * the variable pointed to by synch_handle.
+ *
+ * @param[out] synch_handle pointer to the variable that will contain
+ * the handle to the newly created synchronization object
+ *
+ * @return 0 if the operation is succesful
+ * FRSH_ERR_TOO_MANY_SYNCH_OBJS if the number of synchronization
+ * objects in the system has already exceeded the maximum
+ *
+ * FRSH_ERR_TOO_MANY_SYNCH_OBJS : if the number of synchronization
+ * objects in the system has already exceeded the maximum\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
+ *
+ **/
+int frsh_synchobj_create
+ (frsh_synchobj_handle_t *synch_handle);
/**
- This function sends a notification to the synchronization object
- specified as parameter. If there is at least one thread waiting on
- the synchronization object, it is awaken. If more than one thread
- is waiting, just one of them is awaken. However, which one is
- awaken is implementation dependent. If no thread is waiting on the
- synchronization object, the notification is queued.
-
- [JULIO: all the ocurrrences of the word "thread" should be changed
- by "server" in the paragraph above
- ]
- @param [in] synch_handle the handle of the synchronization object to
- notify.
-
- @returns 0 if the operation is completed succesfully
- @returns FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE is the handle is not valid
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if synch_handle is 0
- FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the handle is not valid
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_TOO_MANY_EVENTS_IN_SYNCH_OBJ : if the number of events stored
- in the synchronization object reaches the maximum defined in the
- configuration parameter header file
- ]
-
- @sa frsh_schedule_triggered_job, frsh_timed_schedule_triggered_job
-*/
-int
-frsh_signal_synch_obj
- (frsh_synch_obj_handle_t synch_handle);
+ * frsh_synchobj_destroy()
+ *
+ * This operation destroys the synchronization object (created by a
+ * previous call to frsh_synchobj_create) that is referenced by the
+ * synch_handle variable. After calling this operation, the
+ * synch_handle variable can not be used until it is initialized again
+ * by a call to frsh_synchobj_create.
+ *
+ * @param synch_handle the handle to the synchronization object
+ * to be destroyed
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if synch_handle is 0\n
+ * FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the handle is not valid\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
+ *
+ * @sa frsh_synchobj_create
+ **/
+int frsh_synchobj_destroy
+ (const frsh_synchobj_handle_t synchobj_handle);
/**
- This operation destroys the synchronization object (created by a
- previous call to frsh_create_synch_obj) that is referenced by the
- synch_handle variable. After calling this operation, the
- synch_handle variable can not be used until it is initialized again
- by a call to frsh_create_synch_obj.
-
- @param synch_handle the handle to the synchronization object
- to be destroyed
-
- @returns 0 if the operation is succesful
- @returns FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE is the handle is not valid
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if synch_handle is 0
- FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the handle is not valid
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- ]
-
- @sa frsh_create_synch_obj
-*/
-int
-frsh_destroy_synch_obj
- (frsh_synch_obj_handle_t synch_handle);
-
-// In the future we may add a broadcast operation that would signal a
-// group of synchronization objects. We have not included a broadcast
-// service in this version because it can be easily created by the
-// user by signalling individual synchronization objects inside a
-// loop.
-
-// Notice that for synchronization objects there is no naming service
-// like in shared objects because tasks that use synchronization are
-// not developed independently, as they are closely coupled.
+ * frsh_synchobj_wait()
+ *
+ * This operation is invoked by threads associated with bounded
+ * workload vres to indicate that a job has been completed (and
+ * that the scheduler may reassign the unused capacity of the current
+ * job to other vres).
+ *
+ * As a difference with frsh_timed_wait(), here the vres
+ * specifies to be awakened by the arrival of a signal operation
+ * instead of at a precise point of time.
+ *
+ * This function can also be called to schedule the first job of a
+ * recently created vres and make it start when a signal operation
+ * has been sent from another thread.
+ *
+ * The vres' budget will be made zero for the remainder of the vres'
+ * period, and FRSH will not replenish it until an event has been
+ * notified to the synchronisation object by another vres.
+ *
+ * It can happen that the synchronisation object has notification
+ * events queued from the past, in this case one of the events is
+ * dequeued immediately and the vres won't have to wait for another
+ * one.
+ *
+ * At the time of reception of a notification event (wether in the
+ * future or in the past), all pending budget replenishments (if any)
+ * are made effective. Once the vres has a positive budget and the
+ * scheduler schedules the calling thread again, the call returns and
+ * the vres continues executing.
+ *
+ * If the synchronisation object is destroyed while the vres was
+ * waiting on it, the vres will be awaken and the function will
+ * return with a code FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE
+ *
+ * Except for those parameters equal to NULL pointers, the system
+ * reports the current period and budget for the current job, it informs
+ * if the deadline of the previous job was missed or not, and whether the
+ * budget of the previous job was overrun or not.
+ *
+ * In a system with hierarchical scheduling, since this call makes the
+ * budget of the current period zero, the other threads in the same
+ * vres are not run. As mentioned above, only when the call finishes
+ * the budget may be replenished.
+ *
+ * @param synch_handle Synchronisation object upon which the vres
+ * will be waiting.
+ * @param next_budget[out] Upon return of this function, the variable
+ * pointed by this function will be equal to
+ * the current vres budget. If this parameter is
+ * set to NULL, no action is taken
+ * @param next_period[out] The vres period upon return (ignored if NULL).
+ * @param was_deadline_missed Upon return whether the deadline was
+ * missed in the previous period.
+ * @param was_budget_overran
+ *
+ *
+ * @return 0 if success \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_NOT_BOUND : if the calling thread does not have a valid
+ * vres bound to it \n
+ * FRSH_ERR_BAD_ARGUMENT : if synch_handle is 0 \n
+ * FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the synch_handle is not
+ * valid or was destroyed while the vres was waiting on it. \n
+ * FRSH_ERR_VRES_WORKLOAD_NOT_COMPATIBLE: if the kind of workload of the vres
+ * is not FRSH_BOUNDED
+ *
+ **/
+int frsh_synchobj_wait
+ (const frsh_synchobj_handle_t synch_handle,
+ frsh_rel_time_t *next_budget,
+ frsh_rel_time_t *next_period,
+ bool *was_deadline_missed,
+ bool *was_budget_overran);
-////////////////////////////////////////////////////
-// SCHEDULING BOUNDED WORKLOADS
-////////////////////////////////////////////////////
+/**
+ * frsh_synchobj_wait_with_timeout()
+ *
+ * This call is the same as frsh_synchobj_wait() but with an extra
+ * absolute timeout. The timed_out argument, indicates whether the
+ * function returned because of the expiration of the timeout or not.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the synch_handle is not
+ * valid \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_NOT_BOUND : if the calling thread does not have a valid
+ * vres bound to it \n
+ * FRSH_ERR_BAD_ARGUMENT : if the synch_handle given is not valid or the
+ * abs_timeout argument is NULL or its value is in the past\n
+ * FRSH_ERR_VRES_WORKLOAD_NOT_COMPATIBLE: if the kind of workload of the vres
+ * is not FRSH_BOUNDED
+ *
+ **/
+int frsh_synchobj_wait_with_timeout
+ (const frsh_synchobj_handle_t synch_handle,
+ const frsh_abs_time_t *abs_timeout,
+ bool *timed_out,
+ frsh_rel_time_t *next_budget,
+ frsh_rel_time_t *next_period,
+ bool *was_deadline_missed,
+ bool *was_budget_overran);
+
+/**
+ * frsh_synchobj_signal()
+ *
+ * This function sends a notification event to the synchronization object
+ * specified as parameter. If there is at least one vres waiting on
+ * the synchronization object, it is awaken. If more than one vres
+ * are waiting, just one of them is awaken. However, which one is
+ * awaken is implementation dependent. If no vres is waiting on the
+ * synchronization object, the notification event is queued.
+ *
+ * @param [in] synch_handle the handle of the synchronization object to
+ * notify.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if synch_handle is 0 \n
+ * FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the handle is not valid \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_TOO_MANY_EVENTS_IN_SYNCH_OBJ : if the number of events stored
+ * in the synchronization object reaches the maximum defined in the
+ * configuration parameter header file
+ *
+ * @sa frsh_synchobj_wait, frsh_synchobj_wait_with_timeout
+ **/
+int frsh_synchobj_signal
+ (const frsh_synchobj_handle_t synch_handle);
/**
- This operation is invoked by threads associated with bounded
- workload servers to indicate that a job has been completed (and
- that the scheduler may reassign the unused capacity of the current
- job to other servers). It is also invoked when the first job of
- such threads has to be scheduled. (PEPPE: I have a question, what
- happens to the budget? if I do not get it wrong, the replenishment
- time is set to abs_time and the bandwidth of the server up to time
- abs_time can be reassigned. Is it true? what is the exact
- relationship between this abs_time and the server period? What if
- the user specifies an abs_time less than the end of the current
- server period??)
-
- As an effect, the system will make the current server's budget zero
- for the remainder of the server's period, and will not replenish
- the budget until the specified absolute time. At that time, all
- pending budget replenishments (if any) are made effective. Once the
- server has a positive budget and the scheduler schedules the
- calling thread again, the call returns and at that time, except for
- those parameters equal to NULL pointers, the system reports the
- current period and budget for the current job, whether the deadline
- of the previous job was missed or not, and whether the budget of
- the previous job was overrun or not.
-
- In a system with hierarchical scheduling, since this call makes the
- budget zero, the other threads in the same server are not run. As
- mentioned abobe, only when the call finishes the budget may be
- replenished.
-
- @param [in] abs_time absolute time at which the budget will be
- replenished
-
- @param [out] next_budget upon return of this function, the variable
- pointed by this function will be equal to
- the current server budget. If this parameter is
- set to NULL, no action is taken.
-
- @param [out] next_period upon return of this function, the variable
- pointed by this function will be equal to
- the current server period. If this parameter is
- set to NULL, no action is taken.
-
- @param [out] was_deadline_missed upon return of this function, the
- variable pointed by this function will be
- equal to true if the previous server deadline
- was missed, to false otherwise. If this
- parameter is set to NULL, no action is
- taken.
-
- @param [out] was_budget_overrun upon return of this function, the
- variable pointed by this function will be
- equal to true if the previous server budget was
- overrun, to false otherwise. If this
- parameter is set to NULL, no action is
- taken.
-
- @returns 0 if the operation is succesful
- @returns FRSH_ERR_TIME_SPEC_IN_THE_PAST if the absolute time specification
- is in the past.
- [ERR@RETURNED:
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- main scheduler
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not scheduled
- under the FRSH
- FRSH_ERR_NOT_BOUND : if the calling thread does not have a valid
- server bound to it
- FRSH_ERR_BAD_ARGUMENT : if abs_time is NULL
- FRSH_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload of the server
- is not FRSH_BOUNDED
- ]
-
- @sa frsh_schedule_triggered_job, frsh_timed_schedule_triggered_job
-
-*/
-int
-frsh_schedule_timed_job
- (const struct timespec *abs_time,
- struct timespec *next_budget,
- struct timespec *next_period,
+ * frsh_timed_wait()
+ *
+ * This operation is invoked by threads associated with bounded
+ * workload vres to indicate that a job has been completed (and
+ * that the scheduler may reassign the unused capacity of the current
+ * job to other vres). It is also invoked when the first job of
+ * such threads has to be scheduled.
+ *
+ * As an effect, the system will make the current vres's budget zero
+ * for the remainder of the vres's period, and will not replenish
+ * the budget until the specified absolute time. At that time, all
+ * pending budget replenishments (if any) are made effective. Once the
+ * vres has a positive budget and the scheduler schedules the
+ * calling thread again, the call returns and at that time, except for
+ * those parameters equal to NULL pointers, the system reports the
+ * current period and budget for the current job, whether the deadline
+ * of the previous job was missed or not, and whether the budget of
+ * the previous job was overrun or not.
+ *
+ * In a system with hierarchical scheduling, since this call makes the
+ * budget zero, the other threads in the same vres are not run. As
+ * mentioned abobe, only when the call finishes the budget may be
+ * replenished.
+ *
+ * @param [in] abs_time absolute time at which the budget will be
+ * replenished
+ *
+ * @param [out] next_budget upon return of this function, the variable
+ * pointed by this function will be equal to
+ * the current vres budget. If this parameter is
+ * set to NULL, no action is taken.
+ *
+ * @param [out] next_period upon return of this function, the variable
+ * pointed by this function will be equal to
+ * the current vres period. If this parameter is
+ * set to NULL, no action is taken.
+ *
+ * @param [out] was_deadline_missed upon return of this function, the
+ * variable pointed by this function will be
+ * equal to true if the previous vres deadline
+ * was missed, to false otherwise. If this
+ * parameter is set to NULL, no action is
+ * taken.
+ *
+ * @param [out] was_budget_overrun upon return of this function, the
+ * variable pointed by this function will be
+ * equal to true if the previous vres budget was
+ * overrun, to false otherwise. If this
+ * parameter is set to NULL, no action is
+ * taken.
+ *
+ * @return 0 if the operation is successful \n
+ * FRSH_ERR_TIME_SPEC_IN_THE_PAST if the absolute time specification
+ * is in the past. \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_NOT_BOUND : if the calling thread does not have a valid
+ * vres bound to it \n
+ * FRSH_ERR_BAD_ARGUMENT : if abs_time is NULL \n
+ * FRSH_ERR_VRES_WORKLOAD_NOT_COMPATIBLE: if the kind of workload of the vres
+ * is not FRSH_BOUNDED
+ *
+ *
+ * @sa frsh_synchobj_wait, frsh_synchobj_wait_with_timeout
+ **/
+int frsh_timed_wait
+ (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);
+
/**
- This operation is invoked by threads associated with bounded
- workload servers to indicate that a job has been completed (and
- that the scheduler may reassign the unused capacity of the current
- job to other servers). It is also invoked when the first job of
- such threads has to be scheduled. If the specified synchronization
- object has events queued, one of them is dequeued; otherwise the
- server will wait upon the specified synchronization object, the
- server's budget will be made zero for the remainder of the server's
- period, and the implementation will not replenish the budget until
- the specified synchronization object is signalled. At that time,
- all pending budget replenishments (if any) are made effective. Once
- the server has a positive budget and the scheduler schedules the
- calling thread again, the call returns and at that time, except for
- those parameters equal to NULL pointers, the system reports the
- current period and budget for the current job, whether the deadline
- of the previous job was missed or not, and whether the budget of
- the previous job was overrun or not.
-
- In a system with hierarchical scheduling, since this call makes the
- budget zero, the other threads in the same server are not run. As
- mentioned above, only when the call finishes the budget may be
- replenished.
-
- [ERR@RETURNED:
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- main scheduler
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not scheduled
- under the FRSH
- FRSH_ERR_NOT_BOUND : if the calling thread does not have a valid
- server bound to it
- FRSH_ERR_BAD_ARGUMENT : if synch_handle is 0
- FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the synch_handle is not valid
- FRSH_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload of the server
- is not FRSH_BOUNDED
- ]
-
-
-*/
-int
-frsh_schedule_triggered_job
- (frsh_synch_obj_handle_t synch_handle,
- struct timespec *next_budget,
- struct timespec *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);
/**
- This call is the same as frsh_schedule_triggered_job, but with an
- absolute timeout. The timed_out argument, indicates whether the
- function returned because of a timeout or not
-
- [ERR@RETURNED:
- FRSH_ERR_INVALID_SYNCH_OBJ_HANDLE if the synch_handle is not valid
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- main scheduler
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not scheduled
- under the FRSH
- FRSH_ERR_NOT_BOUND : if the calling thread does not have a valid
- server bound to it
- FRSH_ERR_BAD_ARGUMENT : if the synch_handle given is not valid or the
- abs_timeout argument is NULL or its value is in the past
- FRSH_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload of the server
- is not FRSH_BOUNDED
- ]
-
-*/
-int
-frsh_timed_schedule_triggered_job
- (frsh_synch_obj_handle_t synch_handle,
- const struct timespec *abs_timeout,
- bool *timed_out,
- struct timespec *next_budget,
- struct timespec *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);
///////////////////////////////////////////////////////////////////
/**
- \defgroup negotiate Negotiate contract functions
-
- The following functions are used to create servers for a contract
- parameters specification and also to assign one or more threads to
- a server (Note: the current implementation only supports one thread
- per server; this limitation will be removed in the next phase of
- the project)
-*/
-/*@{*/
+ * @defgroup negotiate Negotiate contract functions
+ * @ingroup core
+ *
+ * The following functions are used to negotiate contracts and thus
+ * creating vres which are the execution image of a contract.
+ * Besides, these functions allow to assign and unassign threads to
+ * vres.
+ *
+ * In the case of more than one thread per vres please refer to the
+ * hierarchical module.
+ *
+ * @{
+ **/
-/**
- Server Id type, that identifies a server created to manage a given
- contract
-*/
-typedef int frsh_server_id_t; // => 0
-/**
- The type references a function that may become a thread's
- code
-*/
-typedef void * (*frsh_thread_code_t) (void *);
+/**
+ * frsh_contract_negotiate()
+ *
+ * The operation negotiates a contract and if accepted it will return
+ * a vres_id. It will also check that the given contract_label is unique
+ * within the node.
+ *
+ * If the on-line admission test is enabled, it determines whether the
+ * contract can be admitted or not based on the current contracts
+ * established in the system. Then it creates the vres and
+ * recalculates all necessary parameters for the contracts already
+ * present in the system.
+ *
+ * This is a potentially blocking operation, it returns when the
+ * system has either rejected the contract, or admitted it and made it
+ * effective. No thread is bound to the newly created vres, which
+ * will be idle until a thread is bound to it via frsh_thread_bind()
+ * or frsh_thread_create_and_bind().
+ *
+ * This operation can only be executed by threads that are already
+ * bound to an active vres and therefore are being scheduled by the
+ * frsh scheduler.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_CONTRACT_REJECTED: The contract is not accepted.\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 scheduler \n
+ * FRSH_ERR_BAD_ARGUMENT : if the contract or vres arguments are NULL \n
+ * FRSH_ERR_TOO_MANY_VRES : if there is no space for more vres
+ * (the maximum number of them is already reached) \n
+ * FRSH_ERR_CONTRACT_LABEL_ALREADY_EXISTS : contract_label is not unique.
+ *
+ **/
+int frsh_contract_negotiate
+ (const frsh_contract_t *contract,
+ frsh_vres_id_t *vres);
/**
- The operation negotiates a contract for a new server. If the
- on-line admission test is enabled it determines whether the
- contract can be admitted or not based on the current contracts
- established in the system. Then it creates the server and
- recalculates all necessary parameters for the contracts already
- present in the system. This is a potentially blocking operation; it
- returns when the system has either rejected the contract, or
- admitted it and made it effective. It returns zero and places the
- server identification number in the location pointed to by the
- server input parameter if accepted, or an error if rejected. No
- thread is bound to the newly created server, which will be idle
- until a thread is bound to it. This operation can only be executed
- by threads that are already bound to an active server and therefore
- are being scheduled by the frsh scheduler.
-
- [ERR@RETURNED:
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- main scheduler
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not scheduled
- under the FRSH
- FRSH_ERR_BAD_ARGUMENT : if the contract or server arguments are NULL
- FRSH_ERR_TOO_MANY_SERVERS : if there is no space for more servers
- (the maximum number of them is already reached)
- ]
-
-*/
-int
-frsh_negotiate_contract
- (const frsh_contract_parameters_t *contract,
- frsh_server_id_t *server);
+ * frsh_thread_create_and_bind()
+ *
+ * This operation creates a thread and binds it to an existing vres.
+ *
+ * This is the preferred way to add threads to the application because
+ * we make sure that the thread won't become unbound.
+ *
+ * The vres must not have any thread binded to it. If you want to
+ * bind more than one thread to the vres you must use the
+ * hierarchical module.
+ *
+ * The frsh_thread_attr_t parameter is overwritten as necessary to
+ * introduce the adequate scheduling policy and priority, according
+ * to the preemption level given in the contract and the
+ * frsh_priority_map() function defined by the user.
+ *
+ * @param[in] vres_id vres with which the thread will be bound.
+ * @param[out] thread frsh_thread_id returned by the system.
+ * @param attr pthread_attr taken and maybe corrected
+ * by the system. Ignored if NULL
+ * @param[in] thread_code Thread function (void func(void *) )
+ * that will constitute the main of the
+ * thread.
+ * @param[in] arg Argument for data to be passed at the
+ * thread. Set to NUL if you don't want
+ * to do anything like this.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if the contract or vres arguments are
+ * NULL \n
+ * FRSH_ERR_CONTRACT_REJECTED : if the contract is rejected. \n
+ * .
+ * It may also return all the errors that may be returned by the
+ * fosa_thread_create() function call
+ *
+ **/
+int frsh_thread_create_and_bind
+ (const frsh_vres_id_t vres,
+ frsh_thread_id_t *thread,
+ frsh_thread_attr_t *attr,
+ frsh_thread_code_t thread_code,
+ void *arg);
/**
- This operation negotiates a contract for a new server, creates a
- thread and binds it to the server. If the contract is accepted, the
- operation creates a thread with the arguments thread, attr,
- thread_code and arg as they are defined for the pthread_create()
- POSIX function call, and attaches it to the frsh scheduler. Then, it
- binds the created thread to the new server. It returns zero and
- puts the server identification number in the location pointed to by
- the server input parameter. The attr parameter is overwritten as
- necessary to introduce the adequate scheduling policy and priority,
- according to the preemption level given in the contract and the
- frsh_priority_map() function defined by the user. If the contract is
- rejected, the thread is not created and the corresponding error is
- returned.
-
- The server is created with the FRSH_NONE scheduling policy, which
- means no hierarchical scheduling, and only one thread per server,
- except for the case of background tasks (see below)
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the contract or server arguments are NULL
- FRSH_ERR_CONTRACT_REJECTED : if the contract is rejected.
- FRSH_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload
- in the contract is FRSH_OVERHEAD
-
- It may also return all the errors that may be returned by the
- pthread_create()POSIX function call
- ]
-
-*/
-int
-frsh_negotiate_contract_for_new_thread
- (const frsh_contract_parameters_t *contract,
- frsh_server_id_t *server,
- pthread_t *thread,
- pthread_attr_t *attr,
- frsh_thread_code_t thread_code,
- void *arg);
+ * frsh_thread_create_in_background()
+ *
+ * This function creates a "background contract" that does not need to
+ * be negotiated, creates a threads and binds to the new vres.
+ *
+ * This method is suggested as a way to initate components and
+ * plugins. The event that triggers the component activation should
+ * arrive to an application thread that could use this function to
+ * create a thread used in its initialisation.
+ *
+ * The attribute parameter is overwritten as necessary to introduce
+ * the adequate scheduling policy and priority.
+ *
+ * @param[in] thread_code Function to be executed by the new
+ * thread.
+ * @param[in] thread_arg General pointer that will be passed to
+ * the new thread as initialisation data.
+ * @param attr Pthread attribute with thread params
+ * @param[in] contract_label Contract label for the new vres.
+ * @param[out] thread_id Id of the new thread.
+ * @param[out] vres_id vres_id of the new vres.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : Any problems with the argument \n
+ * FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is
+ * not scheduled under FRSH \n
+ * FRSH_ERR_CONTRACT_LABEL_ALREADY_EXISTS : contract_label is not unique \n
+ * FRSH_ERR_TOO_MANY_VRES : if there is no space for more vres
+ * (the maximum number of them is already reached)
+ *
+ **/
+int frsh_thread_create_in_background
+ (frsh_thread_code_t thread_code,
+ const void *thread_arg,
+ const char *contract_label,
+ frsh_thread_attr_t *attr,
+ frsh_thread_id_t *thread_id,
+ frsh_vres_id_t *vres_id);
+
+
/**
- This operation negotiates a contract for a new server, and binds
- the calling thread to it. If the contract is accepted it returns
- zero and copies the server identification number in the location
- pointed to by the server input parameter. If it is rejected, an
- error is returned.
-
- The server is created with the FRSH_NONE scheduling policy, which
- means no hierarchical scheduling, and only one thread per server,
- except for the case of background tasks (see below)
-
- Implementation dependent issue: In order to allow the usage of
- application defined schedulers, the calling thread must not have
- the SCHED_APP scheduling policy and at the same time be attached to
- an application scheduler different than the frsh scheduler; in such
- case, an error is returned. After a successful call the calling
- thread will have the SCHED_APP scheduling policy and will be
- attached to the frsh scheduler.
-
- [ERR@RETURNED:
- FRSH_ERR_UNKNOWN_APPSCHEDULED_THREAD : if the thread is attached to
- an application defined scheduler different than the frsh scheduler
- FRSH_ERR_BAD_ARGUMENT : if the contract or server arguments are NULL
- FRSH_ERR_CONTRACT_REJECTED : if the contract is rejected.
- FRSH_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload
- in the contract is FRSH_OVERHEAD
- ]
-
-*/
-int
-frsh_negotiate_contract_for_myself
- (const frsh_contract_parameters_t *contract,
- frsh_server_id_t *server);
+ * 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.
+ **/
+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_bind_thread_to_server: This operation associates a thread with
- a server, which means that it starts consuming the server's budget
- and is executed according to the contract established for that
- server. If the thread is already bound to another server, it is
- effectively unbound from it and bound to the specified one.
-
- It fails if the server's policy is different than FRSH_NONE, or if
- there is already a thread bound to this server
-
- Implementation dependent issue: In order to allow the usage of
- application defined schedulers, the given thread must not have the
- scheduling policy SCHED_APP and at the same time be attached to an
- application scheduler different than the frsh scheduler.
-
- [ERR@RETURNED:
- FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- main scheduler
- FRSH_ERR_UNKNOWN_APPSCHEDULED_THREAD : if the thread is attached to
- an application defined scheduler different than the frsh scheduler
- FRSH_ERR_BAD_ARGUMENT : if the server value does not complain with the
- expected format or valid range or the given thread does not exist
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the referenced server is not valid
- FRSH_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload
- of the server is FRSH_OVERHEAD
- FRSH_ERR_ALREADY_BOUND : if the given server has a thread already bound
- ]
-
-*/
-int
-frsh_bind_thread_to_server
- (frsh_server_id_t server,
- pthread_t thread);
+ * frsh_thread_bind()
+ *
+ * This operation associates a thread with a vres, which means that
+ * it starts consuming the vres's budget and is executed according
+ * to the contract established for that vres. If the thread is
+ * already bound to another vres, it is effectively unbound from it
+ * and bound to the specified one.
+ *
+ * It fails if the vres's policy is different than FRSH_NONE, or if
+ * there is already a thread bound to this vres. In order to bind
+ * more than one vres to the same thread you must use the
+ * hierarchical module.
+ *
+ * Implementation dependent issue: In order to allow the usage of
+ * application defined schedulers, the given thread must not have the
+ * scheduling policy SCHED_APP and at the same time be attached to an
+ * application scheduler different than the frsh scheduler.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
+ * main scheduler \n
+ * FRSH_ERR_UNKNOWN_APPSCHEDULED_THREAD : if the thread is attached to
+ * an application defined scheduler different than the frsh
+ * scheduler \n
+ * FRSH_ERR_BAD_ARGUMENT : if the vres value does not complain with the
+ * expected format or valid range or the given thread does not
+ * exist \n
+ * FRSH_ERR_NOT_CONTRACTED_VRES : if the referenced vres is not
+ * valid \n
+ * FRSH_ERR_VRES_WORKLOAD_NOT_COMPATIBLE: if the kind of workload
+ * of the vres is FRSH_OVERHEAD \n
+ * FRSH_ERR_ALREADY_BOUND : if the given vres has a thread already
+ * bound
+ *
+ **/
+int frsh_thread_bind
+ (const frsh_vres_id_t vres,
+ const frsh_thread_id_t thread);
+
+/**
+ * frsh_thread_unbind()
+ *
+ * This operation unbinds a thread from a vres. Since threads with
+ * no vres associated are not allowed to execute, they remain in a
+ * dormant state until they are either eliminated or bound again.
+ *
+ * If the thread is inside a critical section the effects of this call
+ * are deferred until the critical section is ended
+ *
+ * Implementation dependent issue: in the implementation with an
+ * application scheduler, the thread is still attached to the frsh
+ * scheduler, but suspended.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
+ * main scheduler \n
+ * FRSH_ERR_BAD_ARGUMENT : if the given thread does not exist \n
+ * FRSH_ERR_NOT_SCHEDULED_THREAD : if the given thread is not scheduled
+ * under FRSH \n
+ * FRSH_ERR_UNKNOWN_APPSCHEDULED_THREAD : if the thread is attached to
+ * an application defined scheduler different than the frsh
+ * scheduler \n
+ * FRSH_ERR_NOT_BOUND : if the given thread does not have a valid
+ * vres bound to it
+ **/
+int frsh_thread_unbind(const frsh_thread_id_t thread);
/**
- This operation unbinds a thread from a server. Since threads with
- no server associated are not allow to execute, they remain in a
- dormant state until they are either eliminated or bound again.
-
- If the thread is inside a critical section the effects of this call
- are deferred until the critical section is ended
-
- Implementation dependent issue: in the implementation with an
- application scheduler, the thread is still attached to the frsh
- scheduler, but suspended.
-
- [ERR@RETURNED:
- FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- main scheduler
- FRSH_ERR_BAD_ARGUMENT : if the given thread does not exist
- FRSH_ERR_NOT_SCHEDULED_THREAD : if the given thread is not scheduled
- under the FRSH
- FRSH_ERR_UNKNOWN_APPSCHEDULED_THREAD : if the thread is attached to
- an application defined scheduler different than the frsh scheduler
- FRSH_ERR_NOT_BOUND : if the given thread does not have a valid
- server bound to it
- ]
-
-*/
-int
-frsh_unbind_thread_from_server (pthread_t thread);
+ * frsh_thread_get_vres_id()
+ *
+ * This operation stores the Id of the vres associated with the
+ * specified thread in the variable pointed to by vres. It returns
+ * an error if the thread does not exist, it is not under the control
+ * of the scheduling framework, or is not bound.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_NOT_SCHEDULED_THREAD : if the given thread is not scheduled
+ * under FRSH \n
+ * FRSH_ERR_NOT_BOUND : if the given thread does not have a valid
+ * vres bound to it \n
+ * FRSH_ERR_BAD_ARGUMENT : if the given thread does not exist or the
+ * vres argument is NULL
+ *
+ **/
+int frsh_thread_get_vres_id(const frsh_thread_id_t thread,
+ frsh_vres_id_t *vres_id);
/**
- This operation stores the Id of the server associated with the
- specified thread in the variable pointed to by server. It returns
- an error if the thread does not exist, it is not under the control
- of the scheduling framework, or is not bound.
-
- [ERR@RETURNED:
- FRSH_ERR_NOT_SCHEDULED_THREAD : if the given thread is not scheduled
- under the FRSH
- FRSH_ERR_NOT_BOUND : if the given thread does not have a valid
- server bound to it
- FRSH_ERR_BAD_ARGUMENT : if the given thread does not exist or the
- server argument is NULL
- ]
-
-*/
-int
-frsh_get_server
- (pthread_t thread,
- frsh_server_id_t *server);
+ * 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);
/**
- This operation stores the contract parameters currently associated
- with the specified server in the variable pointed to by
- contract. It returns an error if the server id is incorrect.
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the contract argument is NULL or the value
- of the server argument is not in range
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_get_contract
- (frsh_server_id_t server,
- frsh_contract_parameters_t *contract);
+ * frsh_vres_get_contract()
+ *
+ * This operation stores the contract parameters currently associated
+ * with the specified vres in the variable pointed to by
+ * contract. 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_contract
+ (const frsh_vres_id_t vres,
+ frsh_contract_t *contract);
/**
- The operation eliminates the specified server
- and recalculates all necessary parameters for the contracts
- remaining in the system. This is a potentially blocking operation;
- it returns when the system has made the changes effective.
+ * frsh_resource_get_vres_from_label()
+ *
+ * This operation retrieves the vres_id whose contract_label
+ * corresponds to the parameter in the resource_id and resource_type
+ * specified.
+ *
+ * The contract label must refer to a contract negotiated
+ * in the same processing node in which the call is being
+ * made. Otherwise an error is returned.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if the contract argument is NULL or the
+ * contract_label is NULL \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_CONTRACT_LABEL_UNKNOWN: if the contract_label is not known
+ **/
+int frsh_resource_get_vres_from_label
+ (const char *contract_label,
+ const frsh_resource_type_t resource_type,
+ const frsh_resource_id_t resource_id,
+ frsh_vres_id_t *vres);
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the value of server is not in range
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-*/
-int
-frsh_cancel_contract (frsh_server_id_t server);
+
+/**
+ * frsh_contract_cancel()
+ *
+ * The operation eliminates the specified vres
+ * and recalculates all necessary parameters for the contracts
+ * remaining in the system. This is a potentially blocking operation;
+ * it returns when the system has made the changes effective.
+ *
+ * Note that the thread is not eliminated. We leave the application
+ * the option to either freeze it for a later use or bind it to
+ * another vres.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if the value of vres 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_contract_cancel (const frsh_vres_id_t vres);
/**
- The operation renegotiates a contract for an existing server. If
- the on-line admission test is enabled it determines whether the
- contract can be admitted or not based on the current contracts
- established in the system. If it cannot be admitted, the old
- contract remains in effect and an error is returned. If it can be
- admitted, it recalculates all necessary parameters for the
- contracts already present in the system anr returns zero. This is a
- potentially blocking operation; it returns when the system has
- either rejected the new contract, or admitted it and made it
- effective.
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the new_contract argument is NULL or the
- value of the server argument is not in range
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- FRSH_ERR_REJECTED_CONTRACT : if the renegotiation fails
- ]
-
-*/
-int
-frsh_renegotiate_contract
- (const frsh_contract_parameters_t *new_contract,
- frsh_server_id_t server);
+ * frsh_contract_renegotiate_sync()
+ *
+ * The operation renegotiates a contract for an existing vres. If
+ * the on-line admission test is enabled it determines whether the
+ * contract can be admitted or not based on the current contracts
+ * established in the system. If it cannot be admitted, the old
+ * contract remains in effect and an error is returned. If it can be
+ * admitted, it recalculates all necessary parameters for the
+ * contracts already present in the system and returns zero. This is a
+ * potentially blocking operation; it returns when the system has
+ * either rejected the new contract, or admitted it and made it
+ * effective.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if the new_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 \n
+ * FRSH_ERR_REJECTED_CONTRACT : if the renegotiation fails
+ *
+ **/
+int frsh_contract_renegotiate_sync
+ (const frsh_contract_t *new_contract,
+ const frsh_vres_id_t vres);
/**
- The operation enqueues a renegotiate operation for an existing
- server, and returns immediately. The renegotiate operation is
- performed asynchronously, as soon as it is practical; meanwhile the
- system operation will continue normally. When the renegotiation is
- made, if the on-line admission test is enabled it determines
- whether the contract can be admitted or not based on the current
- contracts established in the system. If it cannot be admitted, the
- old contract remains in effect. If it can be admitted, it
- recalculates all necessary parameters for the contracts already
- present in the system. When the operation is completed,
- notification is made to the caller, if requested, via a signal. The
- status of the operation (in progress, admitted, rejected) can be
- checked with the get_renegotiation_status operation. The argument
- sig_notify can be NULL_SIGNAL (no notification), or any posix
- signal; and in this case sig_value is to be sent with the signal.
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the new_contract argument is NULL, the
- value of the server argument is not in range or sig_notify is
- neither NULL nor a valid POSIX signal
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_request_contract_renegotiation
- (const frsh_contract_parameters_t *new_contract,
- frsh_server_id_t server,
- int sig_notify,
- union sigval sig_value);
+ * frsh_contract_renegotiate_async()
+ *
+ * The operation enqueues a renegotiate operation for an existing
+ * vres, and returns immediately. The renegotiate operation is
+ * performed asynchronously, as soon as it is practical; meanwhile the
+ * system operation will continue normally. When the renegotiation is
+ * made, if the on-line admission test is enabled it determines
+ * whether the contract can be admitted or not based on the current
+ * contracts established in the system. If it cannot be admitted, the
+ * old contract remains in effect. If it can be admitted, it
+ * recalculates all necessary parameters for the contracts already
+ * present in the system.
+ *
+ * When the operation is completed, notification is made to the
+ * caller, if requested, via a signal. The status of the operation (in
+ * progress, admitted, rejected) can be checked with the
+ * frsh_vres_get_renegotiation_status() operation. The argument
+ * sig_notify can be FRSH_NULL_SIGNAL (no notification), or any FRSH
+ * signal value and in this case signal_info is to be sent with the signal.
+ *
+ * @param[in] new_contract New contract parameters for the new
+ * situation if approved.
+ * @param[in] vres vres_id on which to do the renegotiation.
+ * @param[in] signal_to_notify Signal number to use to notify vres of
+ * the negotiation result. If
+ * FRSH_NULL_SIGNAL, no signal will be raised.
+ * @param[in] signal_info: Associated info that will come with the
+ * signal. This parameter will be ignored
+ * if signal_to_notify == FRSH_NULL_SIGNAL.
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if the new_contract argument is NULL, the
+ * value of the vres argument is not in range or sig_notify is
+ * neither NULL nor a valid POSIX signal \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_contract_renegotiate_async
+ (const frsh_contract_t *new_contract,
+ const frsh_vres_id_t vres,
+ const frsh_signal_t signal_to_notify,
+ const frsh_signal_info_t signal_info);
/**
- The operation reports on the status of the last renegotiation
- operation enqueued for the specified server. It is callable even
- after notification of the completion of such operation, if
- requested. If the frsh_request_contract_renegotiation operation has
- not ever been called for the given server the status returned is
- FRSH_NOT_REQUESTED
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the renegotiation_status argument is
- NULL or the value of the server argument is not in range
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_get_renegotiation_status
- (frsh_server_id_t server,
+ * frsh_vres_get_renegotiation_status()
+ *
+ * The operation reports on the status of the last renegotiation
+ * operation enqueued for the specified vres. It is callable even
+ * after notification of the completion of such operation, if
+ * requested.
+ *
+ * If the vres is not and has not been involved in any of the
+ * frsh_contract_renegotiate_async() or frsh_group_change_mode_async()
+ * operations, the status returned is FRSH_RS_NOT_REQUESTED
+ *
+ * @return 0 if no error \n
+ * FRSH_ERR_BAD_ARGUMENT : if the renegotiation_status 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_renegotiation_status
+ (const frsh_vres_id_t vres,
frsh_renegotiation_status_t *renegotiation_status);
/*@}*/
+////////////////////////////////////////////////////////////////////////
+// CHANGE OF MODE: GROUPS OF CONTRACTS
+////////////////////////////////////////////////////////////////////////
+/**
+ * @defgroup groupofcontracts Group of contracts
+ * @ingroup core
+ *
+ * The following functions are used to negotiate atomically more than
+ * one contract. This allows to build complex applications by
+ * splitting them in individual contracts that are negotiated
+ * simultaneously and atomically.
+ *
+ * @{
+ **/
+
+/**
+ * frsh_group_change_mode_sync()
+ *
+ * This function performs a set of negotiation operations which can
+ * include: adding new contracts (neg), modifying existing vres (reneg)
+ * or cancelling existing vres (cancel).
+ *
+ * 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.
+ *
+ * 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
+ * contract situation with removed, changed and added contracts.
+ *
+ * A successful return code will mean that all contracts have been
+ * accepted and all required operations (creation, cancellation or
+ * update of vres) have been carried out to reach the new 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
+ * 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 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. \n
+ * FRSH_ERR_REJECTED_CONTRACT: The negotiation of one of the
+ * proposed contracts has failed.
+ **/
+int frsh_group_change_mode_sync
+ (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 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, 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_change_mode_async
+ (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);
+
+
+/*@}*/
+
////////////////////////////////////////////////////
// OBTAINING INFORMATION FROM THE SCHEDULER
////////////////////////////////////////////////////
+/**
+ * @defgroup getschedinfo Obtaining information from the scheduler
+ *
+ * @ingroup core
+ *
+ * The following functions are used to obtain available budget and
+ * resource usage in the system. They can be used to adapt the
+ * execution of threads according to the load of the system.
+ *
+ * @{
+ **/
+
/**
- Returns true if the system is
- configured with the on-line admission test enabled, or false
- otherwise.
-*/
-bool
-frsh_is_admission_test_enabled();
+ * frsh_config_is_admission_test_enabled()
+ *
+ * Returns true if the system is
+ * configured with the on-line admission test enabled, or false
+ * otherwise. This situation can only be changed at compile time.
+ **/
+bool frsh_config_is_admission_test_enabled();
/**
- This function stores the current execution time spent by the
- threads bound to the specified server in the variable pointed to by
- cpu_time.
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the value of the server argument is not in range or
- cpu_time is NULL
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_get_resource_usage
- (frsh_server_id_t server,
- struct timespec *cpu_time);
+ * frsh_vres_get_usage()
+ *
+ * This function stores the current execution time spent by the
+ * threads bound to the specified vres in the variable pointed to by
+ * cpu_time.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
+ * cpu_time is NULL \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_VRESR : if the vres of the calling thread
+ * has been cancelled or it is not valid
+ *
+ **/
+int frsh_vres_get_usage
+ (const frsh_vres_id_t vres,
+ frsh_rel_time_t *spent);
+
/**
- This function stores in the variable pointed to by budget the
- remaining execution-time budget associated with the specified
- server
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the value of the server argument is not in range or
- budget is NULL
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_get_remaining_budget
- (frsh_server_id_t server,
- struct timespec *budget);
+ * 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);
/**
- This function stores in the variables
- pointed to by budget and period, the execution-time budget and the
- period respectively associated with the specified server. If any of
- these pointers is NULL, the corresponding information is not stored.
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if the value of the server argument is not in range,
- or budget and period are both NULL
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_get_budget_and_period
- (frsh_server_id_t server,
- struct timespec *budget,
- struct timespec *period);
+ * frsh_vres_get_remaining_budget()
+ *
+ * This function stores in the variable pointed to by budget the
+ * remaining execution-time budget associated with the specified
+ * vres.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range or
+ * budget is NULL \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_remaining_budget
+ (const frsh_vres_id_t vres,
+ frsh_rel_time_t *budget);
+/**
+ * frsh_vres_get_budget_and_period()
+ *
+ * This function stores in the variables
+ * pointed to by budget and period, the execution-time budget and the
+ * period respectively associated with the specified vres. If any of
+ * these pointers is NULL, the corresponding information is not stored.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if the value of the vres argument is not in range,
+ * or budget and period are both NULL \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_budget_and_period
+ (const frsh_vres_id_t vres,
+ frsh_rel_time_t *budget,
+ frsh_rel_time_t *period);
+
+/*@}*/
/////////////////////////////////////////////////////////////////////
// SERVICE THREAD TUNING
/////////////////////////////////////////////////////////////////////
+/**
+ * @defgroup servthtuning Service thread tuning
+ *
+ * @ingroup core
+ *
+ * The following functions are used to obtain available budget and
+ * resource usage in the system. They can be used to adapt the
+ * execution of threads to the load of the system.
+ *
+ * @{
+ **/
/**
- This function allows the application to
- change the period and budget of the service thread that makes the
- negotiations. Increasing the utilization of this thread makes the
- negotiations faster, but introduces additional load in the system
- that may decrease the bandwidth available for the servers. For this
- call, the system will make a schedulability analysis to determine if
- the new situation is acceptable or not. This is reported back in the
- variable pointed to by accepted. If the new service thread data is
- accepted, the system will reassign budgets and periods to the
- servers according to the new bandwidth available, in the same way as
- it does for a regular contract negotiation.
-
- When its budget is exhausted, the service thread may run in the
- background
-
- The service thread starts with a default budget and period that are
- configurable
-
- Implementation dependency: in the fixed priority implementtaion of
- frsh, the default priority is lower than the priority of any server,
- but higher than the background. According to the
- implementation-dependent module the priority is adjustable by means
- of a function that changes its preemption level
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if any of the pointer arguments is NULL or
- the budget value is greater than the period value
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_set_service_thread_data
- (const struct timespec *budget,
- const struct timespec *period,
- bool *accepted);
+ * frsh_service_thread_set_data()
+ *
+ * This function allows the application to change the period and
+ * budget of the service thread that makes the
+ * negotiations. Increasing the utilization of this thread makes the
+ * negotiations faster, but introduces additional load in the system
+ * that may decrease the bandwidth available for the vres. For this
+ * call, the system will make a schedulability analysis to determine
+ * if the new situation is acceptable or not. This is reported back in
+ * the variable pointed to by accepted. If the new service thread data
+ * is accepted, the system will reassign budgets and periods to the
+ * vres according to the new bandwidth available, in the same way
+ * as it does for a regular contract negotiation.
+ *
+ * When its budget is exhausted, the service thread may run in the
+ * background
+ *
+ * The service thread starts with a default budget and period that are
+ * configurable
+ *
+ * Implementation dependency: in the fixed priority implementtaion of
+ * frsh, the default priority is lower than the priority of any vres,
+ * but higher than the background. According to the
+ * implementation-dependent module the priority is adjustable by means
+ * of a function that changes its preemption level
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if any of the pointer arguments is NULL or
+ * the budget value is greater than the period value \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_service_thread_set_data (const frsh_rel_time_t *budget,
+ const frsh_rel_time_t *period,
+ bool *accepted);
/**
- this function returns in the variables pointed by budget and
- period, respectively, the current budget and period of the service
- thread.
-
- [ERR@RETURNED:
- FRSH_ERR_BAD_ARGUMENT : if any of the pointer arguments is NULL
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
- scheduled under the FRSH
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
- has been cancelled or it is not valid
- ]
-
-*/
-int
-frsh_get_service_thread_data
- (struct timespec *budget,
- struct timespec *period);
-
+ * frsh_service_thread_get_data()
+ *
+ * this function returns in the variables pointed by budget and
+ * period, respectively, the current budget and period of the service
+ * thread.
+ *
+ * @return 0 if successful \n
+ * FRSH_ERR_BAD_ARGUMENT : if any of the pointer arguments is NULL \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_service_thread_get_data
+ (frsh_rel_time_t *budget,
+ frsh_rel_time_t *period);
+
+
+/*@}*/
+
////////////////////////////////////////////////////////////////////////
// BACKGROUND MANAGEMENT
//A round-robin background scheduling policy is available for those
//threads that do not have real-time requirements. Because some of
//these threads may require sharing information with other threads run
-//by regular servers, special background contracts may be created for
+//by regular vres. Special background contracts may be created for
//specifying the synchronization requirements.
-//The way of specifying a background contract is by setting budget_min
-//= period_max = 0. Negotiation may fail if the contract uses
+//The way of specifying a background contract is by setting
+//contract_type to FRSH_CT_BACKGROUND. Negotiation may fail if the contract uses
//shared_objects. If the contract has no shared_objects the returned
-//server id represents the background and may be used to bind more
-//than one thread. If the contract has shared objects a server is
+//vres id represents the background and may be used to bind more
+//than one thread. If the contract has shared objects a vres is
//created to keep track of them, but the associated threads are
//executed in the background, together with the other background
//threads
-////////////////////////////////////////////////////////////////////////
-// CHANGE OF MODE: GROUPS OF CONTRACTS
-////////////////////////////////////////////////////////////////////////
-
-//Data types
-
-//list of contracts to negotiate
-typedef struct {
- int size;
- frsh_contract_parameters_t* contracts[FRSH_MAX_N_SERVERS];
-} frsh_contracts_group_t;
-
-//list of servers to cancel
-typedef struct {
- int size;
- frsh_server_id_t servers[FRSH_MAX_N_SERVERS];
-} frsh_servers_group_t;
-
-
-/**
- This operation analizes the schedulability of
- the context that results from negitiating the contracts specified in
- the contracts_up list and cacelling the contracts referenced by the
- servers_down list. If the overall negotiation is successful, a new
- server will be created for each of the elements of the contracts_up
- group, the servers in servers_down will be cancelled, the list of
- new server ids will be returned in the variable pointed to by
- servers_up, and the variable pointed to by accepted will be made
- true. Otherwise, this variable will be made false, and no other
- effect will take place. The function returns the corresponding error
- code if any of the contracts is not correct or any of the server ids
- is not valid.
- Observe that in order to be able to receive the returned arguments,
- the calling thread's server should not be in the servers_down list.
-
- [ERR@RETURNED:
- FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
- FRSH_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FRSH
- main scheduler
- FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not scheduled
- under the FRSH
- FRSH_ERR_BAD_ARGUMENT : if any of the servers_up or accepted arguments
- is NULL, if the contracts_up and servers_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_negotiate_group
- (const frsh_contracts_group_t *contracts_up,
- const frsh_servers_group_t *servers_down,
- frsh_servers_group_t *servers_up,
- bool *accepted);
-
-
-//////////////////////////////////////////////////////////////////////
-// INITIALIZATION SERVICES
-//////////////////////////////////////////////////////////////////////
-
-
-/**
- We cannot call any frsh functions before frsh_init. After calling
- frsh_init, the main will be executing in the background. Then, it
- can do the negotiations, create the threads and, if needed,
- activate them via some user-specified synchronization mechanism. It
- may also create a contract for itself. The second time this
- function is called it fails.
-
- [ERR@RETURNED:
- FRSH_ERR_SYSTEM_ALREADY_INITIALIZED : if the function has already
- been called before
-
- It may also return any of the errors that may be returned by the
- underlying operating system primitives required to perform the
- FRSH system start up
- ]
-
-*/
-int frsh_init();
-
-/*@}*/
-
+FRSH_CPP_END_DECLS
#endif // _FRSH_CORE_H_