#ifndef FOSA_THREAD_AND_SIGNALS_H_
#define FOSA_THREAD_AND_SIGNALS_H_
+#include "fosa_types.h"
+
/**
* @defgroup threadandsignals Thread and Signals
* @ingroup fosa
*
* Returns 0 if successful; otherwise it returs a code error:
*
- * EAGAIN: the system lacks the necessary resources to create a
+ * FOSA_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,
+ * FOSA_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
+ * FOSA_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
*
/**
* Note: no thread termination primitive is provided. The termination
- * of a thread will be notifoed by the system to the FRSH scheduler
+ * of a thread will be notified by the system to the FRSH scheduler
* through the scheduler API
**/
* deallocating the memory area pointed to by the pointer
**************************************************/
+/**
+ * fosa_key_create()
+ *
+ * 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.
+ *
+ * @return 0 if successful \n
+ * FOSA_EINVAL If we already have reached the FOSA_MAX_KEYS limit.
+ * FOSA_ENOMEM If there are no enough memory resources to
+ * create the key.
+ **/
+int fosa_key_create(int *key);
+
+/**
+ * fosa_key_destroy()
+ *
+ * Destroy a key
+ *
+ * This destroys the key and isables its use in the system
+ *
+ * @return 0 if successful \n
+ * FOSA_EINVAL The key is not initialised or is not in FOSA key range.
+ **/
+int fosa_key_destroy(int key);
+
+
/**
* fosa_thread_set_specific_data()
*
* 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
+ * FOSA_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
* 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
+ * FOSA_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
* priority
*
* Returns 0 if successful, or the following error code:
- * EINVAL: the specified priority value is not between the
+ * FOSA_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
* Returns 0
**/
int fosa_thread_attr_get_prio
- (const frsh_thread_attr_t *attr, size_t *prio);
+ (const frsh_thread_attr_t *attr, int *prio);
/**
* fosa_thread_set_prio()
* 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
+ * FOSA_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
* 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
+ * FOSA_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
*
* 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
+ * FOSA_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
+ * 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
*
* notify it to the system console and then terminate the FRSH
* implementation and dependant applications
**/
- int fosa_signal_queue
+int fosa_signal_queue
(frsh_signal_t signal, frsh_signal_info_t info,
frsh_thread_id_t receiver);
+
+
/**
* fosa_signal_wait()
*
* 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
+ * FOSA_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
*
* 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
+ * FOSA_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
+ * FOSA_EAGAIN: The timeout expired
*
- * Alternatively, in case of the EINVAL error the implementation is
+ * Alternatively, in case of the FOSA_EINVAL error the implementation is
* allowed to notify it to the system console and then terminate the
* FRSH implementation and dependant applications
**/