]> rtime.felk.cvut.cz Git - frescor/fosa.git/commitdiff
Uploading first version of FOSA code !!
authortelleriam <telleriam@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Mon, 19 Feb 2007 00:22:17 +0000 (00:22 +0000)
committertelleriam <telleriam@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Mon, 19 Feb 2007 00:22:17 +0000 (00:22 +0000)
git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@305 35b4ef3e-fd22-0410-ab77-dab3279adceb

include/fosa.h [new file with mode: 0644]
include/fosa_app_def_sched.h [new file with mode: 0644]
include/fosa_clocks_and_timers.h [new file with mode: 0644]
include/fosa_configuration_parameters.h [new file with mode: 0644]
include/fosa_errors.h [new file with mode: 0644]
include/fosa_mutexes_and_condvars.h [new file with mode: 0644]
include/fosa_opaque_types.h [new file with mode: 0644]
include/fosa_threads_and_signals.h [new file with mode: 0644]
include/fosa_types.h [new file with mode: 0644]

diff --git a/include/fosa.h b/include/fosa.h
new file mode 100644 (file)
index 0000000..6a7540f
--- /dev/null
@@ -0,0 +1,77 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+
+#ifndef        _FOSA_H_
+#define        _FOSA_H_
+
+#include "frsh.h"
+
+#include "fosa_configuration_parameters.h"
+#include "fosa_types.h"
+#include "fosa_errors.h"
+
+#include "fosa_threads_and_signals.h"
+#include "fosa_clocks_and_timers.h"
+#include "fosa_mutexes_and_condvars.h"
+#include "fosa_app_def_sched.h"
+
+
+#endif // _FOSA_H_
diff --git a/include/fosa_app_def_sched.h b/include/fosa_app_def_sched.h
new file mode 100644 (file)
index 0000000..6be4a1e
--- /dev/null
@@ -0,0 +1,585 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_app_def_sched.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+
+#ifndef        FOSA_APP_DEF_SCHED_H_
+#define        FOSA_APP_DEF_SCHED_H_
+
+/**
+ * @defgroup appdefsched Application Defined Scheduling
+ *
+ * This module defines the function and types for an abstraction of
+ * the Application Defined Scheduling.
+ *
+ * @{
+ **/
+
+
+
+/********************************
+ * Application-defined scheduling
+ ********************************/
+
+/**
+ * We make the following ASSUMPTIONS:
+ *
+ * - The ADS always executes in the user memory space, so we don't
+ *   need to manage the memory space translation. 
+ *
+ * - Only one application scheduler exists, so we don't need an
+ *   scheduler_id.
+ **/
+
+/**
+ * fosa_ads_scheduler_create()
+ *
+ * Create the application defined scheduler
+ *
+ * The application defined scheduler is created with the primitive
+ * operations specified in the object pointed to by scheduler_ops.
+ * 
+ * The clock used to read the time immediately before the invocation
+ * of each primitive operation, to be reported to the scheduler via
+ * the current_time parameter of each primitive operation is the
+ * FOSA_CLOCK_REALTIME clock.
+ *
+ * The scheduler_data_size parameter is used to request that a memory
+ * area of this size must be created and reserved for the scheduler to
+ * store its state. A pointer to this area is passed to the scheduler
+ * operations in the sched_data parameter. 
+ *
+ * Parameter init_arg points to an area that contains configuration
+ * information for the scheduler. The function creates a memory area
+ * of init_arg_size bytes and copies into it the area pointed by
+ * arg. A pointer to this new created area will be passed to the
+ * primitive operation init() in its arg parameter.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: The value of scheduler_ops was invalid
+ *     EAGAIN: The system lacks enough resources to create the scheduler
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_ads_scheduler_create
+     (const fosa_ads_scheduler_ops_t * scheduler_ops, 
+      size_t scheduler_data_size,
+      void * init_args, 
+      size_t init_args_size);
+
+/**
+ * fosa_thread_attr_setappscheduled()
+ *
+ * Set the appscheduled attribute of a thread attributes object
+ *
+ * This function is used to set the appscheduled attribute in the
+ * object pointed to by attr. This attribute controls the kind of
+ * scheduling used for threads created with it. If true, the thread is
+ * scheduled by the application scheduler. If not, it is scheduled by
+ * the system under a fixed priority scheduler
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: The value of attr is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_attr_setappscheduled
+        (frsh_thread_attr_t *attr,
+         bool appscheduled);
+
+/**
+ * fosa_thread_attr_getappscheduled()
+ *
+ * Get the appscheduled attribute of a thread attributes object
+ *
+ * This function is used to get the appscheduled attribute in the
+ * object pointed to by attr. This attribute controls the kind of
+ * scheduling used for threads created with it. If true, the thread is
+ * scheduled by the application scheduler. If not, it is scheduled by
+ * the system under a fixed priority scheduler.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: The value of attr is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_attr_getappscheduled
+        (const frsh_thread_attr_t *attr,
+         bool *appscheduled);
+
+/**
+ * fosa_thread_attr_setappschedparam()
+ *
+ * Set the appsched_param attribute of a thread attributes object
+ *
+ * This function is used to set the appsched_param attribute in the
+ * object pointed to by attr.  For those threads with appscheduled set
+ * to true, this attribute represents the application-specific
+ * scheduling parameters. If successful, the function shall set the
+ * size of the appsched_param attribute to the value specified by
+ * paramsize, and shall copy the scheduling parameters occupying
+ * paramsize bytes and pointed to by param into that attribute
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: The value of attr is invalid, or paramsize is less than 
+ *            zero or larger than FOSA_ADS_SCHEDPARAM_MAX
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_attr_setappschedparam
+        (frsh_thread_attr_t *attr,
+         const void *param,
+         size_t paramsize);
+
+/**
+ * fosa_thread_attr_getappschedparam()
+ *
+ * Get the appsched_param attribute of a thread attributes object
+ *
+ * This function is used to get the appsched_param attribute from the
+ * object pointed to by attr.  For those threads with appscheduled set
+ * to true, this attribute represents the application-specific
+ * scheduling parameters. If successful, the function shall set the
+ * value pointed to by paramsize to the size of the appsched_param
+ * attribute, and shall copy the scheduling parameters occupying
+ * paramsize bytes into the variable pointed to by param. This
+ * variable should be capable of storing a number of bytes equal to
+ * paramsize.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: The value of attr is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_attr_getappschedparam
+        (const frsh_thread_attr_t *attr,
+         void *param,
+         size_t *paramsize);
+
+/**
+ * fosa_ads_setappscheduled()
+ *
+ * Dynamically set the appscheduled attribute of a thread
+ * 
+ * This function is used to dynamically set the appscheduled attribute
+ * of the thread identified by thread. This attribute controls the
+ * kind of scheduling used for threads created with it. If true, the
+ * thread is scheduled by the application scheduler. If not, it is
+ * scheduled by the system under a fixed priority scheduler.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: The value of thread is invalid
+ *
+ *     EREJECT: the attachment of the thread to the frsh schehduler
+ *     was rejected by the frsh scheduler possibly because of
+ *     incorrect attributes, or because the requested minimum
+ *     capacity cannot be guaranteed
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_ads_setappscheduled
+        (frsh_thread_id_t thread,
+         bool appscheduled);
+
+/**
+ * fosa_ads_getappscheduled()
+ *
+ * Dynamically get the appscheduled attribute of a thread
+ * 
+ * This function is used to dynamically get the appscheduled attribute
+ * of the thread identified by thread. This attribute controls the
+ * kind of scheduling used for threads created with it. If true, the
+ * thread is scheduled by the application scheduler. If not, it is
+ * scheduled by the system under a fixed priority scheduler
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: The value of thread is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_ads_getappscheduled
+        (frsh_thread_id_t thread,
+         bool *appscheduled);
+
+
+/**
+ * fosa_ads_setappschedparam()
+ *
+ * Dynamically set the appsched_param attribute of a thread
+ *
+ * This function is used to dynamically set the appsched_param
+ * attribute of the thread identified by thread.  For those threads
+ * with appscheduled set to true, this attribute represents the
+ * application-specific scheduling parameters. If successful, the
+ * function shall set the size of the appsched_param attribute to the
+ * value specified by paramsize, and shall copy the scheduling
+ * parameters occupying paramsize bytes and pointed to by param into
+ * that attribute
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: The value of thread is invalid, or paramsize is less than 
+ *            zero or larger than FOSA_ADS_SCHEDPARAM_MAX
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_ads_setappschedparam
+        (frsh_thread_id_t thread,
+         const void *param,
+         size_t paramsize);
+
+/**
+ * fosa_ads_getappschedparam()
+ *
+ * Dynamically get the appsched_param attribute of a thread
+ *
+ * This function is used to dynamically get the appsched_param
+ * attribute of the thread identified by thread.  For those threads
+ * with appscheduled set to true, this attribute represents the
+ * application-specific scheduling parameters. If successful, the
+ * function shall set the variable pointed to by paramsize to the size
+ * of the appsched_param attribute, and shall copy the scheduling
+ * parameters occupying paramsize bytes into the variable pointed to
+ * by param. This variable should be capable of storing a number of
+ * bytes equal to paramsize.
+ *
+ *  Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: The value of thread is invalid, or paramsize is less than 
+ *             zero or larger than FOSA_ADS_SCHEDPARAM_MAX
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications.
+ **/
+int fosa_ads_getappschedparam
+        (frsh_thread_id_t thread,
+         void *param,
+         size_t *paramsize);
+
+
+/*********************************
+ * ADS actions
+ *
+ * A scheduling actions object is used to specify a series of actions
+ * to be performed by the system at the end of a scheduler primitive
+ * operation. The order of the actions added to the object shall be
+ * preserved.
+ *
+ *********************************/
+
+/**
+ * fosa_adsactions_addreject()
+ *
+ * Add a reject-thread action
+ *
+ * This function adds a thread-reject action to the object referenced
+ * by sched_actions, that will serve to notify that the thread
+ * identified by thread has not been accepted by the scheduler to be
+ * scheduled by it, possibly because the thread contained invalid
+ * application scheduling attributes, or because there are not enough
+ * resources for the new thread.  At the end of the new_thread()
+ * scheduler primitive operation, the parent of the rejected thread
+ * waiting on a fosa_thread_create() or the rejected thread itself
+ * waiting on a fosa_ads_setappscheduled() function shall complete the
+ * function with an error code of EREJECT. If no reject-thread action
+ * is added during the new_thread() scheduler primitive operation, the
+ * thread is accepted to be scheduled by the scheduler and the
+ * associated fosa_thread_create() or the fosa_ads_setappscheduled()
+ * function shall be completed without error. For the function to
+ * succeed, it has to be called from the new_thread() primitive
+ * operation and for the thread that is requesting attachment to the
+ * scheduler.
+ *
+ *  Returns 0 if successful; otherwise it returns an error code:
+ *     ENOMEM: There is insufficient memory to add this action
+ *     EPOLICY: The thread specified by thread is not the one requesting
+ *               attachment to the scheduler, or the function is not being
+ *               called from the new_thread primitive operation
+ *     EINVAL: The value specified by sched_actions is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_adsactions_add_reject(
+        fosa_ads_actions_t *sched_actions,
+        frsh_thread_id_t thread);
+
+/**
+ * fosa_adsactions_add_activate()
+ *
+ * Add a thread-activate action 
+ *
+ * This function adds a thread-activate action to the object
+ * referenced by sched_actions. In case the thread had been previously
+ * suspended via posix_appsched_actions_addsuspend(), it will be
+ * activated at the end of the primitive operation.
+ *
+ * In those implementations that do not support urgency scheduling,
+ * the urgencu value is ignored. These implementations cannot support
+ * the frsh hierarchical scheduling module.
+ *
+ * In those implementations supporting urgency-scheduling, the action
+ * will cause the change of the urgency of the thread to the value
+ * specified in the urgency argument. Besides, if the thread was
+ * already active at the time the thread-activate action is executed,
+ * the change or urgency will imply a reordering of the thread in its
+ * priority queue, so that for threads of the same priority, those
+ * with more urgency will be scheduled before those of less urgency.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     ENOMEM: There is insufficient memory to add this action
+ *     EPOLICY: The thread specified by thread has its appscheduled
+ *              attribute set to false, 
+ *     EINVAL: The value specified by sched_actions is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_adsactions_add_activate(
+        fosa_ads_actions_t *sched_actions,
+        frsh_thread_id_t thread,
+        fosa_ads_urgency_t urgency);
+
+/**
+ * fosa_adsactions_add_suspend()
+ *
+ * Add a thread-suspend action
+ *
+ * This function adds a thread-suspend action to the object referenced
+ * by sched_actions, that will cause the thread identified by thread
+ * to be suspended waiting for a thread-activate action at the end of
+ * the scheduler operation. If the thread was already waiting for a
+ * thread-activate action the thread-suspend action has no effect. It
+ * is an error trying to suspend a thread that is blocked by the
+ * operating system.
+ * 
+ *  Returns 0 if successful; otherwise it returns an error code:
+ *     ENOMEM: There is insufficient memory to add this action
+ *     EPOLICY: The thread specified by thread has its appscheduled
+ *              attribute set to false, 
+ *     EINVAL: The value specified by sched_actions is invalid
+ *
+ *  Alternatively, in case of error the implementation is allowed to
+ *  notify it to the system console and then terminate the FRSH
+ *  implementation and dependant applications
+ **/
+int fosa_adsactions_add_suspend(
+        fosa_ads_actions_t *sched_actions,
+        frsh_thread_id_t thread);
+
+/**
+ * fosa_adsactions_add_timeout()
+ *
+ * Add a timeout action
+ *
+ * This function adds a timeout action to the object referenced by
+ * sched_actions, that will cause the timeout() scheduler operation to
+ * be invoked if no other scheduler operation is invoked before
+ * timeout expires. The timeout shall expire when the clock specified by
+ * clock_id reaches the absolute time specified by the at_time
+ * argument.
+ *
+ *  Returns 0 if successful; otherwise it returns an error code:
+ *     ENOMEM: There is insufficient memory to add this action
+ *     EPOLICY: The thread specified by thread has its appscheduled
+ *              attribute set to false, 
+ *     EINVAL: The value specified by sched_actions is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_adsactions_add_timeout(
+        fosa_ads_actions_t *sched_actions,
+        fosa_clock_id_t clock_id,
+        const struct timespec *at_time);
+
+/**
+ * fosa_adsactions_add_thread_notification()
+ *
+ * Add a timed-thread-notification action
+ *
+ * This function adds a thread-notification action associated with the
+ * thread specified in the thread argument that will cause the
+ * notification_for_thread() scheduler operation to be invoked at the
+ * time specified by at_time. This operation shall be invoked when the
+ * clock specified by clock_id reaches the absolute time specified by
+ * the at_time argument. In particular, a cpu-time clock may be used
+ * for parameter clock_id.Only one thread-notification can be active
+ * for each thread and clock. Calling the function shall remove the
+ * former thread-notification, if any, that had been programmed for
+ * the same thread and clock. A value of NULL for parameter at_time is
+ * used to cancel a previous thread-notification, if any, for the
+ * thread specified by thread and the clock specified by clock_id.
+ * 
+ *  Returns 0 if successful; otherwise it returns an error code:
+ *     ENOMEM: There is insufficient memory to add this action
+ *     EPOLICY: The thread specified by thread has its appscheduled
+ *              attribute set to false, 
+ *     EINVAL: The value specified by sched_actions is invalid
+ *
+ *  Alternatively, in case of error the implementation is allowed to
+ *  notify it to the system console and then terminate the FRSH
+ *  implementation and dependant applications
+ **/
+int fosa_adsactions_add_thread_notification(
+        fosa_ads_actions_t *sched_actions,
+        frsh_thread_id_t thread,
+        fosa_clock_id_t clock_id,
+        const struct timespec *at_time);
+
+
+/**
+ * fosa_ads_set_handled_signal_set()
+ *
+ * Specifiy the set of signals that will be handled by the application
+ * scheduler
+ *
+ * This function is used to dynamically set the set of signals that
+ * are handled by the application scheduler.  When a signal included
+ * in this set is generated, the signal() primitive operation of the
+ * application scheduler shall be executed. When a signal in tis set
+ * is generated, it shall always imply the execution of the signal()
+ * primitive operation, regardless of whether that signal could be
+ * accepted by some other thread. Once the signal() primitive
+ * operation is executed the signal is consumed, so no signal handlers
+ * shall be executed and no threads using a sigwait operation shall
+ * return for that particular signal instance.  For this function to
+ * succeed, it has to be called from a primitive operation of a
+ * scheduler.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EPOLICY: The function has not been called from a scheduler 
+ *              primitive operation
+ *    EINVAL: The value specified by set is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_ads_set_handled_signal_set(frsh_signal_t set[]);
+
+
+/**
+ * fosa_ads_invoke_withdata()
+ *
+ * Explicitly invoke the scheduler, with data  
+ *
+ * This function can be used by any thread in the process to invoke
+ * the ads scheduler or to share data with it.
+ *
+ * If successful, the function shall cause the execution of the
+ * primitive operation explicit_call_with_data() of the ads scheduler
+ * with its thread parameter equal to the thread ID of the calling
+ * thread, and its msg_size parameter equal to msg_size. In addition,
+ * if msg_size is larger than zero, the function shall make available
+ * to the scheduler a memory area whose contents are identical to the
+ * memory area pointed to by msg in the msg parameter of the
+ * explicit_call_with_data() primitive operation (note that copying
+ * the information is not needed). 
+ *
+ * The function shall not return until the system has finished
+ * execution of the explicit_call_with_data() primitive operation. If
+ * the reply argument is non NULL, the memory area pointed to by the
+ * reply parameter of explicit_call_with_data() primitive operation is
+ * copied into the memory area pointed to by reply, and its size is
+ * copied into the variable pointed to by reply_size. The size of the
+ * reply information is limited to the value FOSA_ADS_SCHEDINFO_MAX. 
+ * 
+ * The function shall fail if the size specified by msg_size is larger
+ * than FOSA_ADS_SCHEDINFO_MAX.  The function shall fail if primitive
+ * operation explicit_call_with_data() is set to NULL for the ads
+ * scheduler.
+ *
+ *  Returns 0 if successful; otherwise it returns an error code:
+ *     EPOLICY: The function been called from inside a scheduler 
+ *              primitive operation
+ *     EINVAL: The value of msg_size is less than zero or larger than 
+ *             FOSA_ADS_SCHEDINFO_MAX
+ *     EMASKED: The operation cannot be executed because the primitive
+ *              operation explicit_call_with_data() is set to NULL
+ *
+ *  Alternatively, in case of error the implementation is allowed to
+ *  notify it to the system console and then terminate the FRSH
+ *  implementation and dependant applications
+ **/
+int fosa_ads_invoke_withdata
+   (const void *msg, size_t msg_size, void *reply, size_t *reply_size);
+
+/*}*/
+
+
+#endif             /* !FOSA_APP_DEF_SCHED_H_ */
diff --git a/include/fosa_clocks_and_timers.h b/include/fosa_clocks_and_timers.h
new file mode 100644 (file)
index 0000000..7a0ed88
--- /dev/null
@@ -0,0 +1,229 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_clocks_and_timers.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+
+#ifndef        FOSA_CLOCKS_AND_TIMERS_H_
+#define        FOSA_CLOCKS_AND_TIMERS_H_
+
+/**
+ * @defgroup clocksandtimers Clocks and Timers
+ *
+ * This module defines the types and functions to abstract clocks and
+ * timers for the FRSH implementation.
+ *
+ * @{
+ **/
+
+
+
+/*************************
+ * Timing: Clocks
+ *************************/
+
+/**
+ * fosa_get_time()
+ *
+ * Get the time from a clock
+ *
+ * This function sets the variable pointed to by current_time to the 
+ * current value of the clock specified by clockid, which may be the 
+ * FOSA_CLOCK_REALTIME constant or a value obtained with 
+ * fosa_get_cputime_clock()
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of clockid is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_clock_get_time(fosa_clock_id_t clockid, struct timespec current_time);
+
+
+/**
+ * fosa_get_cputime_clock()
+ *
+ * Get the identifier of a cpu-time clock
+ *
+ * This function stores in the variable pointed to by clockid the 
+ * identifier of a cpu-time clock for the thread specified by tid.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of tid is invalid
+ * 
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_get_cputime_clock(frsh_thread_id_t tid, fosa_clock_id_t *clockid);
+
+
+/*************************
+ * Timing: Timers
+ *************************/
+
+/**
+ * fosa_create_timer()
+ *
+ * Create a one-shot timer
+ *
+ * This function creates a timer based on the clock specified by clock,
+ * and associates to this timer a notification mechanism consisting of
+ * a signal and associated information. Initially, the timer is in the
+ * disarmed state, i.e., not counting time. It can be armed to start
+ * counting time with fosa_timer_arm().
+ *
+ * The function stores the identifier of the newly created timer in the 
+ * variable pointed to by timerid.
+ *
+ * When the timer expires, the signal number specified by signal will be
+ * sent together with the information specified by info, to the thread
+ * that armed the timer (@see fosa_timer_arm()). 
+ *
+ * In those implementations that do not support queueing a
+ * signal with information to a thread (such as POSIX), the signal may
+ * be sent to any thread that is waiting for this signal via
+ * fosa_signal_wait(). Portability can be ensured by having the receiver
+ * thread be the one who is waiting for the signal. 
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of clockid or signal is invalid
+ * 
+ *     EAGAIN: the system lacks enough resources to create the timer
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+ int fosa_timer_create
+      (fosa_clock_id_t clockid, frsh_signal_t signal, frsh_signal_info_t info,
+       fosa_timer_id_t *timerid);
+
+/**
+ * Delete a timer
+ * 
+ * The function deletes the timer specified by timerid, which becomes 
+ * unusable. If the timer was armed, it is automatically disarmed before
+ * deletion.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of timerid is not valid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_timer_delete(fosa_timer_id_t timerid);
+
+/**
+ * fosa_timer_arm()
+ *
+ * Arm a timer
+ *
+ * The timer specified by timer is armed and starts counting time.
+ *
+ * If abstime is true, the value pointed to by value is the absolute
+ * time at which the timer will expire. If value specifies a time instant 
+ * in the past, the timer expires immediately.
+ *
+ * If abstime is false, the value pointed to by value is the relative interval
+ * that must elapse for the timer to expire. 
+ *
+ * In both cases, absolute or relative, the time is measured with the clock 
+ * associated with the timer when it was created.
+ *
+ * If the timer was already armed, the previous time or interval is discarded
+ * and the timer is rearmed with the new value.
+ *
+ * When the timer expires, it is disarmed.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of timerid or value is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_timer_arm
+      (fosa_timer_id_t timerid, bool abstime,
+       const struct timespec *value);
+
+/**
+ * fosa_timer_disarm()
+ *
+ * Disarm a timer
+ * 
+ * The timer specified by timer is disarmed, and will not expire unless 
+ * it is rearmed. If the timer was already disramed, the function has 
+ * no effect.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of timerid or value is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_timer_disarm(fosa_timer_id_t timerid);
+
+/*@}*/
+
+
+#endif             /* !FOSA_CLOCKS_AND_TIMERS_H_ */
diff --git a/include/fosa_configuration_parameters.h b/include/fosa_configuration_parameters.h
new file mode 100644 (file)
index 0000000..b080482
--- /dev/null
@@ -0,0 +1,88 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_configuration_parameters.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+
+#ifndef        _FOSA_CONFIG_PARAM_H_
+#define        _FOSA_CONFIG_PARAM_H_
+
+
+
+// the realtime clock used internally by the FRSH implementation
+// as the time basis for all timed services
+#define  FOSA_CLOCK_REALTIME   CLOCK_MONOTONIC
+
+// The maximum number of keys, or data items that may be associated
+// with each thread, in the thread-specific data
+#define  FOSA_MAX_KEYS         4
+
+
+/*********
+ *  ADS
+ *********/
+
+// the maximum size in bytes of the ADS scheduling parameters 
+#define FOSA_ADS_SCHEDPARAM_MAX   32
+
+// the maximum size in bytes of the data exchanged between a thread
+// and an ADS scheduler
+#define FOSA_ADS_SCHEDINFO_MAX   32
+
+
+#endif // _FOSA_CONFIG_PARAM_H_
diff --git a/include/fosa_errors.h b/include/fosa_errors.h
new file mode 100644 (file)
index 0000000..a0ec801
--- /dev/null
@@ -0,0 +1,96 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_error.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+#ifndef        _FOSA_ERROR_H_
+#define        _FOSA_ERROR_H_
+
+/**
+ * @defgroup fosaerror FOSA Errors
+ *
+ * We define return error values.
+ *
+ * @{
+ **/
+
+/* FOSA Error codes */
+
+#if defined(RT_LINUX) || defined(MARTE_OS)
+
+#include <error.h>
+
+/** Not enough memory available **/
+#define FOSA_ENOMEM   ENOMEM
+
+/** Invalid parameter **/
+#define FOSA_EINVAL   EINVAL
+
+/** Still pending information **/
+#define FOSA_EAGAIN   EAGAIN
+
+/* FOSA ADS errors */
+
+#define FOSA_EREJECT   EREJECT
+#define FOSA_EMASKED   EMASKED
+
+#endif
+
+/*}*/
+
+#endif             /* _FOSA_ERROR_H_ */
diff --git a/include/fosa_mutexes_and_condvars.h b/include/fosa_mutexes_and_condvars.h
new file mode 100644 (file)
index 0000000..3a72980
--- /dev/null
@@ -0,0 +1,344 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_mutexes_and_condvars.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+#ifndef        FOSA_MUTEX_AND_CONDVARS_H_
+#define        FOSA_MUTEX_AND_CONDVARS_H_
+
+/**
+ * @defgroup mutexesandcondvars Mutexes and Condvars
+ *
+ * This module defines the types and functions to abstract mutexes and
+ * conditional variables for the FRSH implementation.
+ *
+ * @{
+ **/
+
+
+/*******************************************************
+ * Mutexes with priority ceiling
+ ******************************************************/
+
+/**
+ * fosa_mutex_init()
+ *
+ * Initialize a frsh mutex
+ *
+ * The mutex pointed to by mutex is initialized as a mutex using 
+ * the priority ceiling protocol. A priority ceiling of prioceiling
+ * is assigned to this mutex.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of prioceiling is invalid
+ *    EAGAIN: the system lacked the necessary resources to create the mutex
+ *    ENOMEM: Insufficient memory exists to initialize the mutex
+ *    EBUSY:  The system has detected an attempt to reinitialize the mutex
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_mutex_init(frsh_mutex_t *mutex, int prioceiling);
+
+/**
+ * fosa_mutex_destroy()
+ *
+ * Destroy a frsh mutex
+ * 
+ * The mutex pointed to by mutex is destroyed
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of mutex is invalid
+ *    EBUSY:  The mutex is in use (is locked)  
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_mutex_destroy(frsh_mutex_t *mutex);
+
+/**
+ * fosa_mutex_set_prioceiling()
+ *
+ * Dynamically set the priority ceiling of a mutex
+ * 
+ * This function locks the mutex (blocking the calling thread if
+ * necessary) and after it is locked it changes its priority ceiling
+ * to the value specified by new_ceiling, and then it unlocks the
+ * mutex. The previous value of the ceiling is returned in
+ * old_ceiling.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of mutex or prioceiling is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_mutex_set_prioceiling
+   (frsh_mutex_t *mutex, int new_ceiling, int *old_ceiling);
+
+/**
+ * fosa_mutex_get_prioceiling()
+ *
+ * Dynamically get the priority ceiling of a mutex 
+ *
+ * This function copies into the variable pointed to by ceiling the
+ * current priority ceiling of the mutex referenced by mutex
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of mutex is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_mutex_get_prioceiling(const frsh_mutex_t *mutex, int *ceiling);
+
+/**
+ * fosa_mutex_lock()
+ *
+ * Lock a mutex
+ * 
+ * This function locks the mutex specified by mutex. If it is already
+ * locked, the calling thread blocks until the mutex becomes
+ * available. The operation returns with the mutex in the locked
+ * state, with the calling thread as its owner.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of mutex is invalid, or the priority of the
+ *            calling thread is higher than the priority ceiling of the mutex
+ *    EDEADLK: the current thread already owns this mutex
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_mutex_lock(frsh_mutex_t *mutex);
+
+/**
+ * fosa_mutex_trylock()
+ *
+ * Try locking a mutex
+ *
+ * This function is identical to fosa_mutex_lock() except that if the
+ * mutex is already locked the call returns immediately with an error
+ * indication.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of mutex is invalid, or the priority of the
+ *            calling thread is higher than the priority ceiling of the mutex
+ *    EBUSY: the mutex was already locked
+ *
+ * Alternatively, except for EBUSY, in case of error the
+ * implementation is allowed to notify it to the system console and
+ * then terminate the FRSH implementation and dependant applications
+ **/
+int fosa_mutex_trylock(frsh_mutex_t *mutex);
+
+/**
+ * fosa_mutex_unlock()
+ *
+ * Unlock a mutex
+ * 
+ * This function must be called by the owner of the mutex referenced
+ * by mutex, to unlock it. If there are threads blocked on the mutex
+ * the mutex becomes available and the highest priority thread is
+ * awakened to acquire the mutex.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of mutex is invalid
+ *     EPERM: the calling thread is not the owner of the mutex
+ *
+ * Alternatively, except for EBUSY, in case of error the
+ * implementation is allowed to notify it to the system console and
+ * then terminate the FRSH implementation and dependant applications 
+ **/
+int fosa_mutex_unlock(frsh_mutex_t *mutex);
+
+
+/**********************
+ * Condition variables
+ *********************/
+
+/**
+ * fosa_cond_init()
+ *
+ * Initiatize a condition variable
+ * 
+ * The condition variable referenced by cond is initialized with
+ * the attributes required by the FOSA implementation.
+ *
+ *  Returns 0 if successful; otherwise it returns an error code:
+ *     EAGAIN: the system lacked the necessary resources to create the
+ *             condition variable
+ *     ENOMEM: Insufficient memory exists to initialize the condition variable
+ *     EBUSY:  The system has detected an attempt to reinitialize the 
+ *             condition variable
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_cond_init(fosa_cond_t *cond);
+
+/**
+ * fosa_cond_destroy()
+ *
+ * Destroy a condition variable
+ *
+ * The condition variable pointed to by cond is destroyed
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of cond is invalid
+ *     EBUSY:  The condition variable is in use (a thread is waiting on it)  
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_cond_destroy(fosa_cond_t *cond);
+
+/**
+ * fosa_cond_signal()
+ *
+ * Signal a condition variable
+ *
+ * This call unblocks at least one of the threads that are waiting on
+ * the condition variable referenced by cond. If there are no threads
+ * waiting, the function has no effect
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of cond is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_cond_signal(fosa_cond_t *cond);
+
+/**
+ * fosa_cond_broadcast()
+ *
+ * Broadcast a condition variable
+ *
+ * This call unblocks all of the threads that are waiting on the
+ * condition variable referenced by cond. If there are no threads
+ * waiting, the function has no effect.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of cond is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_cond_broadcast(fosa_cond_t *cond);
+
+/**
+ * fosa_cond_wait()
+ *
+ * Wait at a condition variable
+ *
+ * This call is used to block on the condition variable referenced by
+ * cond. It shall be called with the mutex referenced by mutex
+ * locked. The function releases the mutex and blocks the calling
+ * thread until the condition is signalled by some other thread and
+ * the calling thread is awakened. Then it locks the mutex and
+ * returns with the mutex locked by the calling thread.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    EINVAL: the value of cond or mutex is invalid, or different
+ *            mutexes were used for concurrent wait operations on cond, or
+ *            the mutex was not owned by the calling thread
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_cond_wait(fosa_cond_t *cond, frsh_mutex_t *mutex);
+
+/**
+ * fosa_cond_timedwait()
+ *
+ * Wait at a condition variable, with a timeout
+ * 
+ * This function is equal to fosa_cond_wait(), except that the maximum
+ * wait time is limited to the absolute time referenced by abstime, as
+ * measured by the FOSA_CLOCK_REALTIME clock.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the value of cond or mutex or abstime is invalid, or different
+ *             mutexes were used for concurrent wait operations on cond, or
+ *             the mutex was not owned by the calling thread
+ *     ETIMEDOUT: the timeout expired
+ *
+ * Alternatively, except for ETIMEDOUT, in case of error the
+ * implementation is allowed to notify it to the system console and
+ * then terminate the FRSH implementation and dependant applications
+ **/
+int fosa_cond_timedwait(fosa_cond_t *cond, frsh_mutex_t *mutex, 
+      const struct timespec abstime);
+
+/*@}*/ 
+
+
+
+#endif             /* !FOSA_MUTEX_AND_CONDVARS_H_ */
diff --git a/include/fosa_opaque_types.h b/include/fosa_opaque_types.h
new file mode 100644 (file)
index 0000000..4c8098d
--- /dev/null
@@ -0,0 +1,92 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_opaque_types.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+// Implementation dependent definitions
+
+#ifndef _FOSA_OPAQUE_TYPES_H_
+#define _FOSA_OPAQUE_TYPES_H_
+
+
+#if defined(RT_LINUX) || defined(MARTE_OS)
+
+#include <pthread.h>
+#include <signal.h>
+#include <time.h>
+
+
+
+#define    FOSA_CLOCK_ID_T_OPAQUE    clockid_t
+
+#define    FOSA_TIMER_ID_T_OPAQUE    timer_t
+
+#define    FOSA_COND_T_OPAQUE        pthread_cond_t
+
+/*********
+ *  ADS
+ *********/
+
+#define FOSA_ADS_ACTIONS_T_OPAQUE  int
+/*should be posix_appsched_actions_t*/
+
+#endif
+
+
+
+#endif // _FOSA_OPAQUE_TYPES_H_
diff --git a/include/fosa_threads_and_signals.h b/include/fosa_threads_and_signals.h
new file mode 100644 (file)
index 0000000..c8b60ee
--- /dev/null
@@ -0,0 +1,403 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_thread_and_signals.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+
+#ifndef        FOSA_THREAD_AND_SIGNALS_H_
+#define        FOSA_THREAD_AND_SIGNALS_H_
+
+/**
+ * @defgroup threadandsignals Thread and Signals
+ *
+ * This module defines the functions that manipulate frsh_threads and
+ * frsh_signals inside FRSH implementation.
+ *
+ * Applications can refer to FRSH threads but they cannot create them
+ * directly, instead they must use frsh_thread_create*() which in turn
+ * use fosa_thread_create().
+ *
+ * For signals, application threads cannot signal them but only wait
+ * on them.
+ *
+ * @{
+ **/
+
+
+
+/*************************
+ * Thread identification
+ *************************/ 
+
+/**
+ * fosa_thread_equal()
+ *
+ * Compare two thread identifiers to determine if they refer to the 
+ * same thread
+ **/
+bool fosa_thread_equal(frsh_thread_id_t t1, frsh_thread_id_t t2);
+
+
+/**
+ * fosa_thread_self()
+ *
+ * Return the thread id of the calling thread
+ **/
+frsh_thread_id_t fosa_thread_self();
+
+
+/*************************
+ * Thread creation and termination
+ *************************/ 
+
+/**
+ * fosa_thread_create()
+ *
+ * This function creates a new thread using the attributes specified
+ * in attr. If attr is NULL, default attributes are used. The new
+ * thread starts running immediately, executing the function specified
+ * by code, with an argument equal to arg. Upon successful return, the
+ * variable pointed to by tid will contain the identifier of the newly
+ * created thread. The set of signals that may be synchronously
+ * accepted is inherited from the parent thread.
+ *
+ * Returns 0 if successful; otherwise it returs a code error:
+ *
+ *     EAGAIN: the system lacks the necessary resources to create a
+ *             new thread or the maximum number of threads has been
+ *             reached
+ *
+ *     EINVAL: the value specified by attr is invalid (for instance,
+ *              it has not been correctly initialized)
+ *
+ *     EREJECT: the cretion of the thread was rejected by the frsh scheduler
+ *               possibly because of incorrect attributes, or because the 
+ *               requested minimum capacity cannot be guaranteed
+ *
+ **/
+ int fosa_thread_create
+    (frsh_thread_id_t *tid, const frsh_thread_attr_t *attr, 
+     frsh_thread_code_t code, void * arg);
+
+
+/**
+ * Note: no thread termination primitive is provided. The termination
+ * of a thread will be notifoed by the system to the FRSH scheduler
+ * through the scheduler API
+ **/
+
+
+/**************************************************
+ * Thread-specific data
+ *  (extended with access from a different thread)
+ *
+ * Several data items (pointers) may be associated with each thread
+ * Each item is identified through a key, an integer value between 0
+ * and FOSA_MAX_KEYS-1. The caller is responsible of allocating and
+ * deallocating the memory area pointed to by the pointer
+ **************************************************/ 
+
+/**
+ * fosa_thread_set_specific_data()
+ *
+ * Set thread-specific data
+ *
+ * For the thread identified by tid, the thread-specifid data field
+ * identified by key will be set to the value specified by value
+ *
+ * Returns 0 if successful; otherwise, an error code is returned
+ *     EINVAL: the value of key is not between 0 and FOSA_MAX_KEYS-1
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+ int fosa_thread_set_specific_data
+       (int key, frsh_thread_id_t tid, const void * value);
+
+/**
+ * fosa_thread_get_specific_data()
+ *
+ * Get thread-specific data
+ *
+ * For the thread identified by tid, the thread-specifid data field
+ * identified by key will be copied to the variable pointed to by value
+ *
+ * Returns 0 if successful; otherwise, an error code is returned
+ *     EINVAL: the value of key is not between 0 and FOSA_MAX_KEYS-1
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_get_specific_data(int key, frsh_thread_id_t tid, 
+                                  void ** value);
+
+
+/******************************************************************
+ * Thread scheduling
+ * 
+ * This implementation of FRSH assumes an underlying fixed priority
+ * scheduler with priorities in a range, with a minimum and a
+ * maximumm, a number of priority levels with at least 31
+ * priorities. A larger number implies a larger priority. In systems
+ * in which the underlying scheduler uses the opposite convention, a
+ * mapping is automatically provided by the OS adaptation layer.
+ *******************************************************************/
+
+/**
+ * fosa_get_priority_max()
+ *
+ * Return the maximum priority value used in this implementation
+ **/
+int fosa_get_priority_max();
+
+/**
+ * fosa_get_priority_min()
+ *
+ * Return the minimum priority value used in this implementation
+ **/
+int fosa_get_priority_min();
+
+/**
+ * fosa_thread_attr_set_prio()
+ *
+ * Change the priority of a thread attributes object
+ *
+ * The priority of the thread attriutes object specified by attr is
+ * set to the value specified by prio. This function has no runtime
+ * effect on the priority, except when the attributes object is used
+ * to create a thread, when it will be created with the specified
+ * priority
+ * 
+ * Returns 0 if successful, or the following error code:
+ *    EINVAL: the specified priority value is not between the 
+ *            minimum and the maximum priorities defined in this
+ *            FRSH implementation
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_attr_set_prio(frsh_thread_attr_t *attr, int prio);
+
+/**
+ * frsh_thread_attr_get_prio()
+ *
+ * Get the priority from a thread attributes object
+ *
+ * This function sets the variable pointed to by prio to the
+ * priority stored in the thread attributes object attr.
+ * 
+ * Returns 0
+ **/
+ int frsh_thread_attr_get_prio
+          (const frsh_thread_attr_t *attr, size_t *prio);
+
+/**
+ * fosa_thread_set_prio()
+ *
+ * Dynamically change the priority of a thread
+ *
+ * The priority of the thread identified by tid is
+ * set to the value specified by prio. 
+ * 
+ * Returns 0 if successful, or the following error code:
+ *    EINVAL: the specified priority value is not between the 
+ *            minimum and the maximum priorities defined in this
+ *            FRSH implementation
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_thread_set_prio(frsh_thread_id_t tid, int prio);
+
+/**
+ * fosa_thread_get_prio()
+ *
+ * Dynamically get the priority of a thread
+ *
+ * This function sets the variable pointed to by prio to the
+ * priority of the thread identified by tid
+ * 
+ * Returns 0
+ **/
+int fosa_thread_get_prio (frsh_thread_id_t tid, int *prio);
+
+
+
+/*******************************************************************
+ * Signals
+ *
+ * Signals represent events that may be notified by the system, or
+ * sent explicitly by the application, and for which a thread may
+ * synchronously wait. Signals carry an associated piece of
+ * information (an integer or a pointer) and are queued until they are
+ * accepted.  Signals are identified by an integer signal number (of
+ * the type frsh_signal_t) in the range FOSA_SIGNAL_MIN,
+ * FOSA_SIGNAL_MAX.  This range is required to have at least <tbd>
+ * values.
+ *******************************************************************/
+
+/**
+ * fosa_set_accepted_signals()
+ *
+ * Establish the set of signals that may be synchronously accepted 
+ * by the calling thread
+ *
+ * The function uses the array of signal numbers specified by set,
+ * which must be of size equal to size
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the array contains one or more values which are not
+ *             between FOSA_SIGNAL_MIN and FOSA_SIGNAL_MAX, or size
+ *             is less than 0
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int frsh_set_accepted_signals(frsh_signal_t set[], int size);
+
+/**
+ * fosa_signal_queue()
+ *
+ * Queue a signal
+ *
+ * This function is used to explicitly send a signal with a specified
+ * value
+ * 
+ * The signal number specified by signal is sent together with the
+ * information specified by info, to the thread identified by
+ * receiver. In those implementations that do not support queueing a
+ * signal with information to a thread (such as POSIX), the signal may
+ * be sent to any thread that is waiting for this signal via
+ * fosa_signal_wait(). Portability can be ensured by having the receiver
+ * thread be the one who is waiting for the signal. 
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the signal specified by signal is not
+ *              between FOSA_SIGNAL_MIN and FOSA_SIGNAL_MAX
+ *
+ *     EAGAIN: no resources are available to queue the signal; the
+ *             maximum number of queued signals has been reached, or a
+ *             systemwide resource limit has been exceeded
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+ int fosa_signal_queue
+       (frsh_signal_t signal, frsh_signal_info_t info,
+        frsh_thread_id_t receiver);
+
+
+/**
+ * fosa_signal_wait()
+ *
+ * Wait for a signal
+ * 
+ * The function waits for the arrival of one of the signals in the
+ * array of signal numbers specified by set, which must be of size
+ * equal to size. If there is a signal already queued, the function
+ * returns immediately. If there is no signal of the specified set
+ * queued, the calling thread is suspended until a signal from that
+ * set arrives. Upon return, if signal_received is not NULL the number
+ * of the signal received is stored in the variable pointed to by
+ * signal_received; and if info is not NULL the associated information
+ * is stored in the variable pointed to by info.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the array contains one or more values which are not
+ *             between FOSA_SIGNAL_MIN and FOSA_SIGNAL_MAX, or size
+ *             is less than 0
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+ int fosa_signal_wait
+      (frsh_signal_t set[], int size, frsh_signal_t *signal_received, 
+       frsh_signal_info_t *info);
+
+/**
+ * fosa_signal_timedwait()
+ *
+ * Timed wait for a signal
+ * 
+ * This function behaves the same as fosa_signal_wait(), except that
+ * the suspension time is limited to the time interval specified in
+ * the timespec structure referenced by timeout.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     EINVAL: the array contains one or more values which are not
+ *             between FOSA_SIGNAL_MIN and FOSA_SIGNAL_MAX, or size
+ *             is less than 0, or timeout is invalid
+ *     EAGAIN: The timeout expired
+ *
+ * Alternatively, in case of the EINVAL error the implementation is
+ * allowed to notify it to the system console and then terminate the
+ * FRSH implementation and dependant applications
+ **/
+ int fosa_signal_timedwait
+      (frsh_signal_t set[], int size, frsh_signal_t *signal_received, 
+       frsh_signal_info_t *info, const struct timespec *timeout);
+
+/*}*/
+
+
+#endif             /* !FOSA_THREAD_AND_SIGNALS_H_ */
diff --git a/include/fosa_types.h b/include/fosa_types.h
new file mode 100644 (file)
index 0000000..3b8a31e
--- /dev/null
@@ -0,0 +1,329 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//    
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//  This file is part of the FRSH implementation
+//
+//  FRSH is free software; you can  redistribute it and/or  modify
+//  it under the terms of  the GNU General Public License as published by
+//  the Free Software Foundation;  either  version 2, or (at  your option)
+//  any later version.
+//
+//  FRSH  is distributed  in  the hope  that  it  will  be useful,  but
+//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+//  General Public License for more details.
+//
+//  You should have  received a  copy of  the  GNU  General Public License
+//  distributed  with  FRSH;  see file COPYING.   If not,  write to the
+//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+//  02111-1307, USA.
+//
+//  As a special exception, if you include this header file into source
+//  files to be compiled, this header file does not by itself cause
+//  the resulting executable to be covered by the GNU General Public
+//  License.  This exception does not however invalidate any other
+//  reasons why the executable file might be covered by the GNU General
+//  Public License.
+// -----------------------------------------------------------------------
+//fosa_types.h
+//==============================================
+//  ********  ******    ********  **********
+//  **///// /**    **  **//////  /**     /**
+//  **      /**    ** /**        /**     /**
+//  ******* /**    ** /********* /**********
+//  **////  /**    ** ////////** /**//////**
+//  **      /**    **        /** /**     /**
+//  **      /**    **  ********  /**     /**
+//  //       /******/  ////////   //      // 
+//
+// FOSA(Frescor Operating System Adaptation layer)
+//================================================
+
+
+#ifndef        _FOSA_TYPES_H_
+#define        _FOSA_TYPES_H_
+
+#include "fosa_opaque_types.h"
+
+/**
+ * @addtogroup clocksandtimers
+ *
+ * @{
+ **/  
+// identifier of a clock
+// either a real-time clock or a cpu-time clock
+typedef    FOSA_CLOCK_ID_T_OPAQUE    fosa_clock_id_t;
+
+// identifier of a one-shot timer
+typedef    FOSA_TIMER_ID_T_OPAQUE    fosa_timer_id_t;
+
+/*@}*/
+
+/**
+ * @addtrogroup mutexesandcondvars
+ *
+ * @{
+ **/
+// a condition variable
+typedef    FOSA_COND_T_OPAQUE        fosa_cond_t;
+/*@}*/
+
+/**
+ * @addtogroup appdefsched
+ *
+ * @{
+ **/
+
+/*********
+ *  ADS
+ *********/
+
+/**
+ * ADS actions
+ *
+ * This type is used to represent a list of scheduling actions that the
+ * scheduler will later request to be executed by the system. The pos-
+ * sible actions are of the following kinds: 
+ *  - reject a thread that has requested attachment to this scheduler
+ *  - activate an application-scheduled thread with the desired value
+ *    of urgency
+ *  - suspend an application-scheduled thread
+ *  - program a timeout
+ *  - program a timed notification associated to a particular 
+ *    application-scheduled thread.
+ *
+ * No comparison or assignment operators are defined for this type
+ **/
+typedef FOSA_ADS_ACTIONS_T_OPAQUE  fosa_ads_actions_t;
+
+
+/**
+ * Causes of error in the appsched_error primitive operation
+ **/
+typedef enum {FOSA_ADS_THREAD_NOT_ATTACHED, FOSA_ADS_INVALID_ACTION}
+    fosa_ads_error_cause_t;
+
+
+/**
+ * The urgency used to orde the threads of the same priority in the
+ * underlying scheduler. Support for urgency scheduling is required
+ * for supporting the hierarchhical scheduling module
+ **/
+typedef int fosa_ads_urgency_t;
+
+
+/**
+ * Scheduler primitive operations
+ *
+ * This structure is used to create application schedulers. It
+ * contains pointers to the primitive operations that are invoked by
+ * the system when a scheduling event occurs:
+ *
+ * - The init() primitive operation is invoked by the system just after
+ *   the scheduler has been created using fosa_ads_scheduler_create().
+ *
+ * - The new_thread() primitive operation is invoked by the system when
+ *   a thread has requested attachment to this scheduler; this can be a
+ *   newly created thread (via fosa_thread_create()), or an existing thread
+ *   that was not running under ads scheduler (via
+ *   fosa_ads_setappscheduled()).  The thread can be rejected by the
+ *   scheduler adding a reject-thread action to the actions parameter
+ *   using fosa_ads_actions_addreject(). If no reject-thread
+ *   action is added, the thread is accepted. Newly created threads
+ *   shall be activated by the system after the execution of the
+ *   new_thread() primitive operation. The urgency of an accepted thread
+ *   (either newly created or existing) shall be set to a value of zero,
+ *   unless an activate-thread action with a different value of urgency
+ *   is added via fosa_ads_actions_addactivate(). If a request to
+ *   attach a thread to this scheduler was made via
+ *   fosa_ads_setappscheduled(), at the finalization of the new_thread()
+ *   primitive operation if the newly attached thread is blocked by the
+ *   system (not by the scheduler itself via a \92¡Èsuspend\92¡É scheduling
+ *   action), a thread-block event shall be generated for the scheduler
+ *   immediately and, consequently, the thread_block() primitive
+ *   operation shall be invoked by the system.
+ *
+ * - The thread_terminate() primitive operation is invoked by the system
+ *   when a thread attached to this scheduler is terminating (via an
+ *   explicit or implicit thread termination, or cancellation, or when
+ *   it is no longer sceduled by the ads scheduler (via
+ *   fosa_ads_setappscheduled()). Before the thread_terminate()
+ *   primitive operation is invoked by the system, all the
+ *   thread-notification events programmed for that thread are
+ *   cancelled. In the case of a thread that is terminating the
+ *   thread_terminate() primitive operation is executed before the
+ *   execution of the cleanup handlers and of the thread-specific data
+ *   destructor functions. In that way, the thread parameter corresponds
+ *   to a valid thread Id and the thread-specific data is valid and can
+ *   be accessed from the thread_terminate() primitive operation. Also
+ *   for terminating threads, after the thread_terminate() primitive
+ *   operation finishes, the system shall lower the urgency of the
+ *   thread identified by thread to a value of zero, and shall deattach
+ *   it from the ads scheduler.  Then, the thread shall execute the
+ *   cleanup handlers and the thread-specific data destructor functions
+ *   outside the management of its former scheduler. Notice that in a
+ *   multiprocessor system this may imply the suspension of the thread
+ *   identified by parameter thread during the execution of the
+ *   thread_terminate() primitive operation.
+ *
+ * - The thread_ready() primitive operation is invoked by the system
+ *   when a thread attached to this scheduler that was blocked has
+ *   become unblocked by the system.
+ *
+ * - The thread_block() primitive operation is invoked by the system
+ *   when a thread attached to this scheduler has blocked.
+ *
+ * - The change_sched_param_thread() primitive operation is invoked by
+ *   the system when the scheduling parameters of a thread attached to
+ *   this scheduler have been changed, but the thread continues to run
+ *   under this scheduler. The change includes either the regular sched-
+ *   uling parameters (fosa_thread_set_prio() or the application-defined
+ *   scheduling parameters, via fosa_ads_setappschedparam().
+ *
+ * - The explicit_call_with_data() primitive operation is invoked by the
+ *   system when a thread (identified by the thread parameter) has
+ *   explicitly invoked the scheduler with a message containing
+ *   scheduling information, and possibly requesting a reply message,
+ *   via fosa_ads_invoke_withdata().
+ *
+ * - The notification_for_thread() primitive operation is invoked by the
+ *   system when the time for a thread-notification previously programed
+ *   by the scheduler via fosa_ads_actions_addthreadnotification()
+ *   is reached. Parameter clock identifies the clock for which the
+ *   thread-notification was programmed.
+ *
+ * - The timeout() primitive operation is invoked by the system when a
+ *   timeout requested by the scheduler (via
+ *   fosa_ads_actions_addtimeout()) has expired.
+ *
+ * - The signal() primitive operation is invoked by the system when a
+ *   signal belonging to the set of signals for which the scheduler is
+ *   waiting (via fosa_ads_sethandledsignalset()) has been
+ *   generated. The signal number and its associated information (if
+ *   any) are passed in the arguments signal and siginfo. The signal is
+ *   consumed with the invocation of this primitive operation, which
+ *   implies that it will not cause the execution of any signal handler,
+ *   nor it may be accepted by any thread waiting for this signal
+ *   number.
+ *
+ * - The appsched_error() primitive operation is invoked by the system
+ *   when an error in the scheduling actions list specified in a
+ *   previous primitive operation is detected. The cause of the error is
+ *   notified in the parameter cause. The defined causes of error are
+ *   described fosa_ads_error_cause_tappdefsched
+ *
+ * Every primitive operation receives the argument sched_data. It is a
+ * pointer to a memory area containing information shared by all the
+ * scheduler operations. It can be used to store the data structures
+ * required by the scheduler (for example, a ready queue and a delay
+ * queue). Scheduler operations should not use any other global data out
+ * of this memory area.  
+ *
+ * The actions argument is used by the scheduler to request the operating
+ * system to execute a set of scheduling actions at the end of the
+ * primitive operation. It is passed empty by the system, and the
+ * scheduler may add multiple scheduling actions.
+ *
+ * The current_time argument contains the system time
+ * measured immediately before the invocation of the primitive operation
+ * using the FOSA_CLOCK_REALTIME clock
+ *
+ * In addition to these common parameters, most of the primitive
+ * operations receive a thread argument. This argument allows the
+ * primitive operations to know which is the thread that has produced or
+ * is related to the event. 
+ **/
+typedef struct {
+   void (*init) (void * sched_data, void * arg);
+   void (*new_thread) (void * sched_data,
+            frsh_thread_id_t thread,
+            fosa_ads_actions_t * actions,
+            struct timespec *current_time);
+   void (*thread_terminate) (void * sched_data,
+            frsh_thread_id_t thread,
+            fosa_ads_actions_t * actions,
+            struct timespec *current_time);
+   void (*thread_ready) (void * sched_data,
+            frsh_thread_id_t thread,
+            fosa_ads_actions_t * actions,
+            struct timespec *current_time);
+   void (*thread_block) (void * sched_data,
+            frsh_thread_id_t thread,
+            fosa_ads_actions_t * actions,
+            struct timespec *current_time);
+  //void (*thread_yield) (void * sched_data,
+  //          frsh_thread_id_t thread,
+  //          fosa_ads_actions_t * actions,
+  //          struct timespec *current_time);
+   void (*change_sched_param_thread) (void * sched_data,
+            frsh_thread_id_t thread,
+            fosa_ads_actions_t * actions,
+            struct timespec *current_time);
+  //void msg_from_scheduler(void * sched_data,
+  //          fosa_ads_scheduler_id_t scheduler_id,
+  //          const void * msg, size_t msg_size,
+  //          fosa_ads_actions_t * actions,
+  //          struct timespec *current_time);
+  //void (*explicit_call) (void * sched_data,
+  //          frsh_thread_id_t thread,
+  //         int user_event_code,
+  //         fosa_ads_actions_t * actions,
+  //         struct timespec *current_time);
+  void (*explicit_call_with_data) (void * sched_data,
+           frsh_thread_id_t thread,
+           const void * msg, size_t msg_size,
+           void **reply, size_t *reply_size,
+           fosa_ads_actions_t * actions,
+           struct timespec *current_time);
+  void (*notification_for_thread) (void * sched_data,
+           frsh_thread_id_t thread,
+           fosa_clock_id_t clock,
+           fosa_ads_actions_t * actions,
+           struct timespec *current_time);
+  void (*timeout) (void * sched_data,
+           fosa_ads_actions_t * actions,
+           struct timespec *current_time);
+  void (*signal) (void * sched_data,
+          frsh_signal_t signal,
+           frsh_signal_info_t siginfo,
+           fosa_ads_actions_t * actions,
+           struct timespec *current_time);
+  //void (*priority_inherit) (void * sched_data,
+  //         frsh_thread_id_t thread,
+  //         int sched_priority,
+  //         fosa_ads_actions_t * actions,
+  //         struct timespec *current_time);
+  //void (*priority_uninherit) (void * sched_data,
+  //         frsh_thread_id_t thread,
+  //         int sched_priority,
+  //         fosa_ads_actions_t * actions,
+  //         struct timespec *current_time);
+  void (*appshed_error) (void * sched_data,
+          frsh_thread_id_t thread,
+          fosa_ads_error_cause_t cause,
+           fosa_ads_actions_t * actions);
+} fosa_ads_scheduler_ops_t;
+
+
+/*@}*/
+
+#endif // _FOSA_TYPES_H_