]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blobdiff - frsh_shared_objects.h
Deadline miss notification signals API changed
[frescor/frsh-include.git] / frsh_shared_objects.h
index 78c96e5eb1da224b7b4128684b4f80ab71b4f6bf..cca6c15a9b567a07eba5424b9c27e0396568e055 100644 (file)
@@ -1,5 +1,5 @@
 // -----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//  Copyright (C) 2006 - 2009 FRESCOR consortium partners:
 //
 //    Universidad de Cantabria,              SPAIN
 //    University of York,                    UK
@@ -12,7 +12,7 @@
 //    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
@@ -22,7 +22,7 @@
 //
 //
 //  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
 //   FSF API web pages: http://marte.unican.es/fsf/docs
 //                      http://shark.sssup.it/contrib/first/docs/
 //
-//  This file is part of FRSH API
-//
-//  FRSH API is free software; you can  redistribute it and/or  modify
-//  it under the terms of  the GNU General Public License as published by
-//  the Free Software Foundation;  either  version 2, or (at  your option)
-//  any later version.
+//   This file is part of FRSH (FRescor ScHeduler)
 //
-//  FRSH API  is distributed  in  the hope  that  it  will  be useful,  but
-//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
-//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
-//  General Public License for more details.
+//  FRSH is free software; you can redistribute it and/or modify it
+//  under terms of the GNU General Public License as published by the
+//  Free Software Foundation; either version 2, or (at your option) any
+//  later version.  FRSH is distributed in the hope that it will be
+//  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+//  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//  General Public License for more details. You should have received a
+//  copy of the GNU General Public License along with FRSH; see file
+//  COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+//  Cambridge, MA 02139, USA.
 //
-//  You should have  received a  copy of  the  GNU  General Public License
-//  distributed  with  FRSH API;  see file COPYING.   If not,  write to the
-//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
-//  02111-1307, USA.
-//
-//  As a special exception, if you include this header file into source
-//  files to be compiled, this header file does not by itself cause
-//  the resulting executable to be covered by the GNU General Public
-//  License.  This exception does not however invalidate any other
-//  reasons why the executable file might be covered by the GNU General
-//  Public License.
+//  As a special exception, including FRSH header files in a file,
+//  instantiating FRSH generics or templates, or linking other files
+//  with FRSH objects to produce an executable application, does not
+//  by itself cause the resulting executable application to be covered
+//  by the GNU General Public License. This exception does not
+//  however invalidate any other reasons why the executable file might be
+//  covered by the GNU Public License.
 // -----------------------------------------------------------------------
 //frsh_shared_objects.h
 
 #ifndef _FRSH_SHARED_OBJECTS_H_
 #define _FRSH_SHARED_OBJECTS_H_
 
-#include "frsh_fosa.h"
 #include "frsh_shared_objects_types.h"
 #include "frsh_core_types.h"
 
+FRSH_CPP_BEGIN_DECLS
 
 #define FRSH_SHAREDOBJS_MODULE_SUPPORTED       1
 
  * kind of object (protected or unprotected) specified by obj_kind
  *
  * @param[in] obj_label  Label defined by the application.  Char * for
- *                       a string of SHAREDOBJ_LABEL_MAXLENGTH
+ *                       a string of FRSH_MAX_SIZE_SHARED_OBJ_LABEL
  *                       characters (+ null terminating \0).
  *
  * @param[in] obj_kind  Whether it is protected or unprotected.
@@ -228,8 +225,8 @@ int frsh_sharedobj_init
  * obj_handle. Otherwise, an error code is returned.
  *
  * @param[in] obj_label  Defined by the application at object creation
- *                    time. Char * for a string of SHAREDOBJ_LABEL_MAXLENGTH
- *                       characters (+ null terminating \0).
+ *                time. Char * for a string of FRSH_MAX_SIZE_SHARED_OBJ_LABEL
+ *                characters (+ null terminating \0).
  *
  * @param[out] obj_handle Placeholder for the object handle.
  *
@@ -359,7 +356,7 @@ int frsh_sharedobj_remove
  * @param[in] wcet Execution time of the critical section.  This
  *                 budget is consumed in parallel with the vres budget.
  *
- * @param[out] cset Critical section memory placeholder.
+ * @param[out] csect Critical section memory placeholder.
  *
  * @return 0 if no error \n
  *   FRSH_ERR_BAD_ARGUMENT : if obj_handle is NULL \b or \n
@@ -375,7 +372,7 @@ int frsh_sharedobj_remove
  **/
 int frsh_csect_init
     (frsh_sharedobj_handle_t obj_handle,
-     struct timespec wcet,
+     frsh_rel_time_t wcet,
      frsh_csect_t *csect);
 
 
@@ -386,7 +383,7 @@ int frsh_csect_init
  * shared object stored in the critical section referenced by csect
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset or obj_handle are NULL or cset
+ *   FRSH_ERR_BAD_ARGUMENT : if csect or obj_handle are NULL or csect
  *      is not correct \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
  *      scheduled under the FRSH \n
@@ -397,7 +394,7 @@ int frsh_csect_init
  * 
  **/
 int frsh_csect_get_sharedobj_handle
-    (const frsh_csect_t *cset,
+    (const frsh_csect_t *csect,
      frsh_sharedobj_handle_t * obj_handle);
 
 /**
@@ -407,7 +404,7 @@ int frsh_csect_get_sharedobj_handle
  * of the operation stored in the critical section referenced by csect.
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset or wcet are NULL or cset
+ *   FRSH_ERR_BAD_ARGUMENT : if csect or wcet are NULL or csect
  *      is not correct \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
  *      scheduled under FRSH \n
@@ -418,8 +415,8 @@ int frsh_csect_get_sharedobj_handle
  * 
  **/
 int frsh_csect_get_wcet
-    (const frsh_csect_t *cset,
-     struct timespec *wcet);
+    (const frsh_csect_t *csect,
+     frsh_rel_time_t *wcet);
 
 
 /**
@@ -431,7 +428,7 @@ int frsh_csect_get_wcet
  * The function returns an error if the shared_object is unprotected.
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset or op are NULL or if csect points
+ *   FRSH_ERR_BAD_ARGUMENT : if csect or op are NULL or if csect points
  *      to a wrong critical section or if the shared_object is of type
  *      unprotected. 
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
@@ -443,7 +440,7 @@ int frsh_csect_get_wcet
  * 
  **/
 int frsh_csect_register_read_op
-    (frsh_csect_t *cset,
+    (frsh_csect_t *csect,
      frsh_csect_op_t op);
 
 /**
@@ -457,9 +454,9 @@ int frsh_csect_register_read_op
  * The function returns an error if the shared_object is unprotected.
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if op, cset or areas are NULL or cset points 
- *      to a wrong critical section or if the shared_object of csect
- *      is of type unprotected.
+ *   FRSH_ERR_BAD_ARGUMENT : if op, csect or areas are NULL or csect points 
+ *      to a wrong critical section, or areas has a wrong size, or if the 
+ *      shared_object of csect is of type unprotected.
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
  *      scheduled under the FRSH \n
  *   FRSH_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not
@@ -469,7 +466,7 @@ int frsh_csect_register_read_op
  * 
  **/
 int frsh_csect_register_write_op
-    (frsh_csect_t *cset,
+    (frsh_csect_t *csect,
      frsh_csect_op_t op,
      const frsh_memory_areas_t *areas);
 
@@ -478,9 +475,9 @@ int frsh_csect_register_write_op
  * frsh_csect_get_op_kind()
  *
  * Returns the type of operation (read/write/unchecked) of the critical section.
-
+ *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset or op_kind are NULL or cset
+ *   FRSH_ERR_BAD_ARGUMENT : if csect or op_kind are NULL or csect
  *      is not correct \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
  *      scheduled under FRSH \n
@@ -491,7 +488,7 @@ int frsh_csect_register_write_op
  * 
  **/
 int frsh_csect_get_op_kind
-    (const frsh_csect_t *cset,
+    (const frsh_csect_t *csect,
      frsh_csect_op_kind_t *op_kind);
 
 
@@ -499,12 +496,12 @@ int frsh_csect_get_op_kind
  * frsh_csect_get_read_op()
  *
  * Get into the variable pointed to by op the operation pointer stored
- * in the critical section referenced by cset.
+ * in the critical section referenced by csect.
  *
  * If the csect is of type write or unchecked it returns an error.
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset is NULL or points to a wrong 
+ *   FRSH_ERR_BAD_ARGUMENT : if csect is NULL or points to a wrong 
  *      critical section, or to a critical section that is not of the
  *      FRSH_CSOK_READ kind \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
@@ -516,7 +513,7 @@ int frsh_csect_get_op_kind
  * 
  **/
 int frsh_csect_get_read_op
-    (const frsh_csect_t *cset,
+    (const frsh_csect_t *csect,
      frsh_csect_op_t *op);
 
 
@@ -524,12 +521,12 @@ int frsh_csect_get_read_op
 /**
  * frsh_csect_get_write_op()
  *
- * Get the oparation pointer and the memory areas stored in the csect.
+ * Get the operation pointer and the memory areas stored in the csect.
  *
  * If the csect is of type read or unchecked.
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset is NULL or points to a wrong 
+ *   FRSH_ERR_BAD_ARGUMENT : if csect is NULL or points to a wrong 
  *      critical section, or to a critical section that is not of the
  *      FRSH_CSOK_WRITE kind \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
@@ -541,7 +538,7 @@ int frsh_csect_get_read_op
  * 
  **/
 int frsh_csect_get_write_op
-    (const frsh_csect_t *cset,
+    (const frsh_csect_t *csect,
      frsh_csect_op_t *op,
      frsh_memory_areas_t *areas);
 
@@ -556,7 +553,7 @@ int frsh_csect_get_write_op
  * If the section is of type FRSH_CSOK_UNCHECKED, the function returns
  * an error.
  *
- * For read operations, the mutex is locked, the cset budget is set equal
+ * For read operations, the mutex is locked, the csect budget is set equal
  * to the wcet, the registered read operation is invoked, and then the
  * mutex is unlocked; if the csect budget expires, the operation is
  * interrupted, the mutex is unlocked, and the function returns with
@@ -575,7 +572,7 @@ int frsh_csect_get_write_op
  * returns an error.
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset is NULL or points to a wrong 
+ *   FRSH_ERR_BAD_ARGUMENT : if csect is NULL or points to a wrong 
  *      critical section, or to a critical section that is unprotected \n
  *   FRSH_ERR_BUDGET_EXPIRED : the csect budget expired and the protected 
  *      operation was interrupted \n
@@ -588,7 +585,7 @@ int frsh_csect_get_write_op
  * 
  **/
 int frsh_csect_invoke
-    (const frsh_csect_t *cset,
+    (const frsh_csect_t *csect,
      const void * input_arg, 
      void * output_arg);
 
@@ -598,14 +595,14 @@ int frsh_csect_invoke
  * Get in the variable pointed to by blocking the maximum blocking
  * time of the operation of the referenced protected critical section.
  *
- * For read operations, the maximum blocking time is the wcet.
+ * For read or unchecked operations, the maximum blocking time is the wcet.
  *
  * For write operations, the maximum blocking time suffered by higher
  * priority tasks is the wcet of the operation plus the backup time
  * plus the recovery time.
  *
  * @return 0 if no error \n
- *   FRSH_ERR_BAD_ARGUMENT : if cset or blocking are NULL or if csect
+ *   FRSH_ERR_BAD_ARGUMENT : if csect or blocking are NULL or if csect
  *      points to a wrong critical section, or to a critical section
  *      that is unprotected \n
  *   FRSH_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
@@ -617,8 +614,36 @@ int frsh_csect_invoke
  * 
  **/
 int frsh_csect_get_blocking_time
-    (const frsh_csect_t *cset,
-     struct timespec *blocking);
+    (const frsh_csect_t *csect,
+     frsh_rel_time_t *blocking);
+
+
+/**
+ * frsh_csect_destroy()
+ * 
+ * Destroy a critical section, deallocating all the resources that may
+ * have been allocated to it.
+ **/
+int frsh_csect_destroy
+   (frsh_csect_t *csect);
+
+/**
+ * frsh_csect_register_thread()
+ * 
+ * Register the calling thread for invoking time-protected critical
+ * sections via frsh_csect_invoke.
+ **/
+int frsh_csect_register_thread();
+
+/**
+ * frsh_csect_deregister_thread()
+ * 
+ * Deregister the calling thread from being able to invoke
+ * time-protected critical sections. This operation releases system
+ * resources that may have been allocated for the thread.
+ **/
+int frsh_csect_deregister_thread();
+
 
 
 /*@}*/ /* For so_critical group */
@@ -647,7 +672,7 @@ int frsh_csect_get_blocking_time
  * @return 0 if no error \n
  *    FRSH_ERR_BAD_ARGUMENT :  if any of the pointers is NULL or 
  *    the size of the critical_sections structure is less than zero
- *    or grater than FRSH_MAX_N_CRITICAL_SECTIONS
+ *    or greater than FRSH_MAX_N_CRITICAL_SECTIONS
  * 
  **/
 int frsh_contract_set_csects
@@ -675,4 +700,6 @@ int frsh_contract_get_csects
 
 /*@}*/ /* For shared_objects group */
 
+FRSH_CPP_END_DECLS
+
 #endif // _FRSH_SHARED_OBJECTS_H_