]> rtime.felk.cvut.cz Git - frescor/fosa.git/blobdiff - include/fosa_app_def_sched.h
Migrating FOSA trunk to d-ac2v2. Phase 1 moving FRSH-FOSA to FOSA
[frescor/fosa.git] / include / fosa_app_def_sched.h
index 6d77a085afcc3c99fe3c224c169e0e1da6ab09d3..e1c8aa2fdfdfb0cc0bb4cc1f73f450d51fcf398c 100644 (file)
@@ -1,5 +1,5 @@
-// -----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
 //
 //    Universidad de Cantabria,              SPAIN
 //    University of York,                    UK
 //    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
+//    See http://www.frescor.org
+//
+//        The 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.
+//  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  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.
+// This file is part of FOSA (Frsh Operating System Abstraction)
 //
-//  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.
+// FOSA 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.  FOSA 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 FOSA; see file
+// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+// Cambridge, MA 02139, 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 FOSA header files in a file,
+// instantiating FOSA generics or templates, or linking other files
+// with FOSA 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.
 // -----------------------------------------------------------------------
 //fosa_app_def_sched.h
 //==============================================
@@ -62,6 +67,8 @@
 #ifndef        FOSA_APP_DEF_SCHED_H_
 #define        FOSA_APP_DEF_SCHED_H_
 
+#include "fosa_types.h"
+
 /**
  * @defgroup appdefsched Application Defined Scheduling
  * @ingroup fosa
  * arg. A pointer to this new created area will be passed to the
  * primitive operation init() in its arg parameter.
  *
+ * This function must be called before any other function in this
+ * header file.
+ *
+ * In addition it must be called at a priority level no greater than
+ * the priority at which the scheduler operations execute.  This
+ * priority is defined as the maximum SCHED_FIFO priority in the
+ * system minus the configuration parameter FOSA_ADS_SCHEDULER_PRIO_DIFF.
+ *
  * 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
+ *
+ *     FOSA_EINVAL: The value of scheduler_ops was invalid \n
+ *     FOSA_EAGAIN: The system lacks enough resources to create the
+ *                  scheduler \n
  *
  * Alternatively, in case of error the implementation is allowed to
  * notify it to the system console and then terminate the FRSH
@@ -138,14 +155,15 @@ int fosa_ads_scheduler_create
  * the system under a fixed priority scheduler
  *
  * Returns 0 if successful; otherwise it returns an error code:
- *     EINVAL: The value of attr is invalid
+ *
+ *     FOSA_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_set_appscheduled
-        (frsh_thread_attr_t *attr,
+        (fosa_thread_attr_t *attr,
          bool appscheduled);
 
 /**
@@ -160,14 +178,15 @@ int fosa_thread_attr_set_appscheduled
  * the system under a fixed priority scheduler.
  * 
  * Returns 0 if successful; otherwise it returns an error code:
- *    EINVAL: The value of attr is invalid
+ *
+ *    FOSA_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_get_appscheduled
-        (const frsh_thread_attr_t *attr,
+        (const fosa_thread_attr_t *attr,
          bool *appscheduled);
 
 /**
@@ -184,7 +203,8 @@ int fosa_thread_attr_get_appscheduled
  * 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 
+ *
+ *    FOSA_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
@@ -192,7 +212,7 @@ int fosa_thread_attr_get_appscheduled
  * implementation and dependant applications
  **/
 int fosa_thread_attr_set_appsched_params
-        (frsh_thread_attr_t *attr,
+        (fosa_thread_attr_t *attr,
          const void *param,
          size_t paramsize);
 
@@ -212,14 +232,15 @@ int fosa_thread_attr_set_appsched_params
  * paramsize.
  *
  * Returns 0 if successful; otherwise it returns an error code:
- *     EINVAL: The value of attr is invalid
+ *
+ *     FOSA_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_get_appsched_params
-        (const frsh_thread_attr_t *attr,
+        (const fosa_thread_attr_t *attr,
          void *param,
          size_t *paramsize);
 
@@ -235,9 +256,10 @@ int fosa_thread_attr_get_appsched_params
  * 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
+ *     FOSA_EINVAL: The value of thread is invalid
+ *
+ *     FOSA_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
@@ -247,7 +269,7 @@ int fosa_thread_attr_get_appsched_params
  * implementation and dependant applications
  **/
 int fosa_ads_set_appscheduled
-        (frsh_thread_id_t thread,
+        (fosa_thread_id_t thread,
          bool appscheduled);
 
 /**
@@ -262,14 +284,15 @@ int fosa_ads_set_appscheduled
  * 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
+ *
+ *     FOSA_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_get_appscheduled
-        (frsh_thread_id_t thread,
+        (fosa_thread_id_t thread,
          bool *appscheduled);
 
 
@@ -288,7 +311,8 @@ int fosa_ads_get_appscheduled
  * that attribute
  *
  * Returns 0 if successful; otherwise it returns an error code:
- *    EINVAL: The value of thread is invalid, or paramsize is less than 
+ *
+ *    FOSA_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
@@ -296,7 +320,7 @@ int fosa_ads_get_appscheduled
  * implementation and dependant applications
  **/
 int fosa_ads_set_appsched_params
-        (frsh_thread_id_t thread,
+        (fosa_thread_id_t thread,
          const void *param,
          size_t paramsize);
 
@@ -316,7 +340,8 @@ int fosa_ads_set_appsched_params
  * 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 
+ *
+ *     FOSA_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
@@ -324,7 +349,7 @@ int fosa_ads_set_appsched_params
  * implementation and dependant applications.
  **/
 int fosa_ads_get_appsched_params
-        (frsh_thread_id_t thread,
+        (fosa_thread_id_t thread,
          void *param,
          size_t *paramsize);
 
@@ -353,7 +378,7 @@ int fosa_ads_get_appsched_params
  * 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_set_appscheduled() function shall complete the
- * function with an error code of EREJECT. If no reject-thread action
+ * function with an error code of FOSA_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_set_appscheduled()
@@ -363,11 +388,12 @@ int fosa_ads_get_appsched_params
  * 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
+ *
+ *     FOSA_ENOMEM: There is insufficient memory to add this action \n
+ *     FOSA_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
+ *               called from the new_thread primitive operation \n
+ *     FOSA_EINVAL: The value specified by sched_actions is invalid \n
  *
  * Alternatively, in case of error the implementation is allowed to
  * notify it to the system console and then terminate the FRSH
@@ -375,7 +401,7 @@ int fosa_ads_get_appsched_params
  **/
 int fosa_adsactions_add_reject(
         fosa_ads_actions_t *sched_actions,
-        frsh_thread_id_t thread);
+        fosa_thread_id_t thread);
 
 /**
  * fosa_adsactions_add_activate()
@@ -400,10 +426,11 @@ int fosa_adsactions_add_reject(
  * 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
+ *
+ *     FOSA_ENOMEM: There is insufficient memory to add this action \n
+ *     FOSA_EPOLICY: The thread specified by thread has its appscheduled
+ *              attribute set to false \n
+ *     FOSA_EINVAL: The value specified by sched_actions is invalid \n
  *
  * Alternatively, in case of error the implementation is allowed to
  * notify it to the system console and then terminate the FRSH
@@ -411,7 +438,7 @@ int fosa_adsactions_add_reject(
  **/
 int fosa_adsactions_add_activate(
         fosa_ads_actions_t *sched_actions,
-        frsh_thread_id_t thread,
+        fosa_thread_id_t thread,
         fosa_ads_urgency_t urgency);
 
 /**
@@ -428,10 +455,11 @@ int fosa_adsactions_add_activate(
  * 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
+ *
+ *     FOSA_ENOMEM: There is insufficient memory to add this action \n
+ *     FOSA_EPOLICY: The thread specified by thread has its appscheduled
+ *              attribute set to false \n
+ *     FOSA_EINVAL: The value specified by sched_actions is invalid \n
  *
  *  Alternatively, in case of error the implementation is allowed to
  *  notify it to the system console and then terminate the FRSH
@@ -439,7 +467,7 @@ int fosa_adsactions_add_activate(
  **/
 int fosa_adsactions_add_suspend(
         fosa_ads_actions_t *sched_actions,
-        frsh_thread_id_t thread);
+        fosa_thread_id_t thread);
 
 /**
  * fosa_adsactions_add_timeout()
@@ -454,10 +482,9 @@ int fosa_adsactions_add_suspend(
  * 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
+ *
+ *     FOSA_ENOMEM: There is insufficient memory to add this action \n
+ *     FOSA_EINVAL: The value specified by sched_actions is invalid \n
  *
  * Alternatively, in case of error the implementation is allowed to
  * notify it to the system console and then terminate the FRSH
@@ -487,10 +514,11 @@ int fosa_adsactions_add_timeout(
  * 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
+ *
+ *     FOSA_ENOMEM: There is insufficient memory to add this action \n
+ *     FOSA_EPOLICY: The thread specified by thread has its appscheduled
+ *              attribute set to false \n
+ *     FOSA_EINVAL: The value specified by sched_actions is invalid \n
  *
  *  Alternatively, in case of error the implementation is allowed to
  *  notify it to the system console and then terminate the FRSH
@@ -498,7 +526,7 @@ int fosa_adsactions_add_timeout(
  **/
 int fosa_adsactions_add_thread_notification(
         fosa_ads_actions_t *sched_actions,
-        frsh_thread_id_t thread,
+        fosa_thread_id_t thread,
         fosa_clock_id_t clock_id,
         const struct timespec *at_time);
 
@@ -522,16 +550,52 @@ int fosa_adsactions_add_thread_notification(
  * succeed, it has to be called from a primitive operation of a
  * scheduler.
  *
+ * The size of the array is specified by argument size.
+ *
  * 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
+ *
+ *    FOSA_EPOLICY: The function has not been called from a scheduler 
+ *              primitive operation \n
+ *    FOSA_EINVAL: The value specified by set is invalid \n
  *
  * 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[]);
+int fosa_ads_set_handled_signal_set(fosa_signal_t set[], int size);
+
+
+/**
+ * fosa_signal_queue_scheduler()
+ *
+ * Queue a signal destinated to the scheduler
+ *
+ * This is a special case of fosa_signal_queue() in which the
+ * destinator is the scheduler itself.  It is needed by the service
+ * thread to notify the results to the scheduler.
+ *
+ * The problem with this case is that, depending on the implementation,
+ * this call would be translated to a true signal or to a scheduler
+ * notification message.
+ *
+ * Besides for the scheduler we don't have always a destinator
+ * thread_id needed in fosa_signal_queue for OSE.
+ *
+ * So the fosa implementation will solve this issue internally.
+ * 
+ * Returns 0 if successful; otherwise it returns an error code:
+ *     FOSA_EINVAL: the signal specified by signal is not
+ *              between FOSA_SIGNAL_MIN and FOSA_SIGNAL_MAX
+ *
+ *     FOSA_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_scheduler(fosa_signal_t signal, fosa_signal_info_t info);
 
 
 /**
@@ -566,12 +630,13 @@ int fosa_ads_set_handled_signal_set(frsh_signal_t set[]);
  * 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
+ *
+ *     FOSA_EPOLICY: The function been called from inside a scheduler 
+ *              primitive operation \n
+ *     FOSA_EINVAL: The value of msg_size is less than zero or larger than 
+ *             FOSA_ADS_SCHEDINFO_MAX \n
+ *     FOSA_EMASKED: The operation cannot be executed because the primitive
+ *              operation explicit_call_with_data() is set to NULL \n
  *
  *  Alternatively, in case of error the implementation is allowed to
  *  notify it to the system console and then terminate the FRSH