]> rtime.felk.cvut.cz Git - frescor/fosa.git/blobdiff - include/fosa_threads_and_signals.h
Adding FOSA_CPP_BEING|END_DECLS to allow interfacing with C++
[frescor/fosa.git] / include / fosa_threads_and_signals.h
index bc56e03fad117453c1932a6cb3b72a866b3226a5..b2d685f24c5f2f2cc179a241882fec677e56236c 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_thread_and_signals.h
 //==============================================
 
 #include "fosa_types.h"
 
+
+FOSA_CPP_BEGIN_DECLS
+
+
 /**
  * @defgroup threadandsignals Thread and Signals
  * @ingroup fosa
  *
- * This module defines the functions that manipulate frsh_threads and
- * frsh_signals inside FRSH implementation.
+ * This module defines the functions that manipulate fosa_threads and
+ * fosa_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, we assume that the OS provides a direct mapping
- * for frsh_signal_t and frsh_signal_info_t in the native interface.
+ * for fosa_signal_t and fosa_signal_info_t in the native interface.
  *
  * @{
  **/
  * 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);
+bool fosa_thread_equal(fosa_thread_id_t t1, fosa_thread_id_t t2);
 
 
 /**
@@ -101,7 +110,71 @@ bool fosa_thread_equal(frsh_thread_id_t t1, frsh_thread_id_t t2);
  *
  * Return the thread id of the calling thread
  **/
-frsh_thread_id_t fosa_thread_self();
+fosa_thread_id_t fosa_thread_self();
+
+
+/*************************
+ * Thread attributes
+ *************************/ 
+
+/**
+ * fosa_thread_attr_init()
+ *
+ * Initialize a thread attributes object
+ *
+ * This function initializes the object pointed to by attr to all 
+ * the default values defined by FRSH
+ *
+ * @return 0 if successful; otherwise it returns \n
+ *   FOSA_ENOMEM: insufficient memory exists to initialize the thread 
+ *           attributes object
+ **/
+int fosa_thread_attr_init(fosa_thread_attr_t *attr);
+
+
+/**
+ * fosa_thread_attr_destroy()
+ *
+ * Destroy a thread attributes object
+ *
+ * This function is used to destroy the thread attributes object,
+ * pointed to by attr, and deallocate any system resources allocated for it
+ * 
+ * Returns 0
+ */
+int fosa_thread_attr_destroy(fosa_thread_attr_t *attr);
+
+
+/**
+ * fosa_thread_attr_set_stacksize()
+ *
+ * Set the thread minimum stack size in a thread attributes object
+ *
+ * This function sets the minimum stack size of the thread attributes
+ * object attr to the value given by stacksize, in bytes. This
+ * function has no runtime effect on the stack size, except when the
+ * attributes object is used to create a thread, when it will be
+ * created with the specified minimum stack size
+ * 
+ * @return 0 if successful, or the following error code:
+ *    FOSA_EINVAL: the specified stacksize  value is not supported in
+ *            this implementation
+ */
+int fosa_thread_attr_set_stacksize(fosa_thread_attr_t *attr, 
+                                   size_t stacksize);
+
+/**
+ * fosa_thread_attr_get_stacksize()
+ *
+ * Get the thread minimum stack size from a thread attributes object
+ *
+ * This function sets the variable pointed to by stacksize to the
+ * minimum stack size stored in the thread attributes object attr.
+ * 
+ * @return 0
+ */
+int fosa_thread_attr_get_stacksize(const fosa_thread_attr_t *attr, 
+                                   size_t *stacksize);
 
 
 /*************************
@@ -134,8 +207,8 @@ frsh_thread_id_t fosa_thread_self();
  *
  **/
  int fosa_thread_create
-    (frsh_thread_id_t *tid, const frsh_thread_attr_t *attr, 
-     frsh_thread_code_t code, void * arg);
+    (fosa_thread_id_t *tid, const fosa_thread_attr_t *attr, 
+     fosa_thread_code_t code, void * arg);
 
 
 /**
@@ -161,7 +234,9 @@ frsh_thread_id_t fosa_thread_self();
  * Create a new key for thread specific data.
  *
  * Prior to setting data in a key, we need ask the system to create
- * one for us.
+ * one for us.  The thread specific data of all the threads is set to
+ * the value NULL until changed to a different value via
+ * fosa_thread_set_specific_data().
  *
  * @return 0 if successful \n
  *   FOSA_EINVAL If we already have reached the FOSA_MAX_KEYS limit.
@@ -175,7 +250,7 @@ int fosa_key_create(int *key);
  *
  * Destroy a key
  *
- * This destroys the key and isables its use in the system
+ * This destroys the key and disables its use in the system
  *
  * @return 0 if successful \n
  *   FOSA_EINVAL The key is not initialised or is not in FOSA key range.
@@ -199,7 +274,7 @@ int fosa_key_destroy(int key);
  * implementation and dependant applications
  **/
  int fosa_thread_set_specific_data
-       (int key, frsh_thread_id_t tid, const void * value);
+       (int key, fosa_thread_id_t tid, const void * value);
 
 /**
  * fosa_thread_get_specific_data()
@@ -216,7 +291,7 @@ int fosa_key_destroy(int key);
  * 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, 
+int fosa_thread_get_specific_data(int key, fosa_thread_id_t tid, 
                                   void ** value);
 
 
@@ -264,7 +339,7 @@ int fosa_get_priority_min();
  * 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);
+int fosa_thread_attr_set_prio(fosa_thread_attr_t *attr, int prio);
 
 /**
  * fosa_thread_attr_get_prio()
@@ -277,7 +352,7 @@ int fosa_thread_attr_set_prio(frsh_thread_attr_t *attr, int prio);
  * Returns 0
  **/
  int fosa_thread_attr_get_prio
-          (const frsh_thread_attr_t *attr, int *prio);
+          (const fosa_thread_attr_t *attr, int *prio);
 
 /**
  * fosa_thread_set_prio()
@@ -295,7 +370,7 @@ int fosa_thread_attr_set_prio(frsh_thread_attr_t *attr, int prio);
  * 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);
+int fosa_thread_set_prio(fosa_thread_id_t tid, int prio);
 
 /**
  * fosa_thread_get_prio()
@@ -307,7 +382,7 @@ int fosa_thread_set_prio(frsh_thread_id_t tid, int prio);
  * 
  * Returns 0
  **/
-int fosa_thread_get_prio (frsh_thread_id_t tid, int *prio);
+int fosa_thread_get_prio (fosa_thread_id_t tid, int *prio);
 
 
 
@@ -319,7 +394,7 @@ int fosa_thread_get_prio (frsh_thread_id_t tid, int *prio);
  * 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,
+ * the type fosa_signal_t) in the range FOSA_SIGNAL_MIN,
  * FOSA_SIGNAL_MAX.  This range is required to have at least <tbd>
  * values.
  *******************************************************************/
@@ -342,7 +417,7 @@ int fosa_thread_get_prio (frsh_thread_id_t tid, int *prio);
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_set_accepted_signals(frsh_signal_t set[], int size);
+int fosa_set_accepted_signals(fosa_signal_t set[], int size);
 
 /**
  * fosa_signal_queue()
@@ -373,8 +448,8 @@ int fosa_set_accepted_signals(frsh_signal_t set[], int size);
  * implementation and dependant applications
  **/
 int fosa_signal_queue
-       (frsh_signal_t signal, frsh_signal_info_t info,
-        frsh_thread_id_t receiver);
+       (fosa_signal_t signal, fosa_signal_info_t info,
+        fosa_thread_id_t receiver);
 
 
 
@@ -404,8 +479,8 @@ int fosa_signal_queue
  * 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_t set[], int size, fosa_signal_t *signal_received, 
+       fosa_signal_info_t *info);
 
 /**
  * fosa_signal_timedwait()
@@ -427,10 +502,11 @@ int fosa_signal_queue
  * 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);
+      (fosa_signal_t set[], int size, fosa_signal_t *signal_received, 
+       fosa_signal_info_t *info, const struct timespec *timeout);
 
 /*}*/
 
+FOSA_CPP_END_DECLS
 
 #endif             /* !FOSA_THREAD_AND_SIGNALS_H_ */