]> 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 8c37a9065f648e1edd1148bb5bcd86ed19a3636f..b2d685f24c5f2f2cc179a241882fec677e56236c 100644 (file)
 
 #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);
 
 
 /**
@@ -106,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);
 
 
 /*************************
@@ -139,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);
 
 
 /**
@@ -166,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.
@@ -180,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.
@@ -204,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()
@@ -221,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);
 
 
@@ -269,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()
@@ -282,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()
@@ -300,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()
@@ -312,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);
 
 
 
@@ -324,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.
  *******************************************************************/
@@ -347,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()
@@ -378,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);
 
 
 
@@ -409,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()
@@ -432,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_ */