]> rtime.felk.cvut.cz Git - frescor/fosa.git/commitdiff
Migrating FOSA trunk to d-ac2v2. Phase 1 moving FRSH-FOSA to FOSA
authortelleriam <telleriam@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Tue, 22 Jan 2008 12:59:11 +0000 (12:59 +0000)
committertelleriam <telleriam@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Tue, 22 Jan 2008 12:59:11 +0000 (12:59 +0000)
git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@1004 35b4ef3e-fd22-0410-ab77-dab3279adceb

29 files changed:
include/fosa.h
include/fosa_app_def_sched.h
include/fosa_clocks_and_timers.h
include/fosa_configuration_parameters.h
include/fosa_long_jump.h
include/fosa_mutexes_and_condvars.h
include/fosa_opaque_types.h
include/fosa_threads_and_signals.h
include/fosa_time.h [new file with mode: 0644]
include/fosa_types.h
include/timespec_operations.h [new file with mode: 0644]
rules.mk
src_marte/fosa_app_def_sched.c
src_marte/fosa_clocks_and_timers.c
src_marte/fosa_long_jump.c
src_marte/fosa_mutexes_and_condvars.c
src_marte/fosa_threads_and_signals.c
src_marte/fosa_time.c [moved from src_marte/frsh_fosa.c with 59% similarity]
src_marte/tests/test_clock_and_timers/test_clock_and_timers.c
src_marte/tests/test_cpu_clocks/test_cpu_clocks.c
src_marte/tests/test_cpu_clocks/test_cpu_clocks_sigwait_from_different_thread.c
src_marte/tests/test_fosa_ads/test_fosa_ads.c
src_marte/tests/test_fosa_general/Makefile [new file with mode: 0644]
src_marte/tests/test_fosa_general/test_fosa.c
src_marte/tests/test_non_local_jump/Makefile
src_marte/tests/test_non_local_jump/frsh_error.c [deleted file]
src_marte/tests/test_non_local_jump/simple_test_non_local_jump.c
src_marte/tests/test_non_local_jump/test_fosa_long_jump.c
src_marte/tests/test_non_local_jump/testbench_long_jump.c

index 09e75f26c32769375ab54293bfa53d8ea9dcb22e..2a6ad33792eed163055ad6b06db9ca96764f8c78 100644 (file)
@@ -67,8 +67,6 @@
 #ifndef        _FOSA_H_
 #define        _FOSA_H_
 
-#include "frsh_fosa.h"
-
 #include "fosa_configuration_parameters.h"
 #include "fosa_types.h"
 
@@ -77,6 +75,7 @@
 #include "fosa_mutexes_and_condvars.h"
 #include "fosa_app_def_sched.h"
 #include "fosa_long_jump.h"
+#include "fosa_time.h"
 
 
 /**
index 738a87563101af0f65ba85af48f350af22830483..e1c8aa2fdfdfb0cc0bb4cc1f73f450d51fcf398c 100644 (file)
@@ -163,7 +163,7 @@ int fosa_ads_scheduler_create
  * implementation and dependant applications
  **/
 int fosa_thread_attr_set_appscheduled
-        (frsh_thread_attr_t *attr,
+        (fosa_thread_attr_t *attr,
          bool appscheduled);
 
 /**
@@ -186,7 +186,7 @@ int fosa_thread_attr_set_appscheduled
  * implementation and dependant applications
  **/
 int fosa_thread_attr_get_appscheduled
-        (const frsh_thread_attr_t *attr,
+        (const fosa_thread_attr_t *attr,
          bool *appscheduled);
 
 /**
@@ -212,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);
 
@@ -240,7 +240,7 @@ int fosa_thread_attr_set_appsched_params
  * 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);
 
@@ -269,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);
 
 /**
@@ -292,7 +292,7 @@ int fosa_ads_set_appscheduled
  * implementation and dependant applications
  **/
 int fosa_ads_get_appscheduled
-        (frsh_thread_id_t thread,
+        (fosa_thread_id_t thread,
          bool *appscheduled);
 
 
@@ -320,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);
 
@@ -349,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);
 
@@ -401,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()
@@ -438,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);
 
 /**
@@ -467,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()
@@ -526,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);
 
@@ -562,7 +562,7 @@ int fosa_adsactions_add_thread_notification(
  * 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 size);
+int fosa_ads_set_handled_signal_set(fosa_signal_t set[], int size);
 
 
 /**
@@ -579,7 +579,7 @@ int fosa_ads_set_handled_signal_set(frsh_signal_t set[], int size);
  * notification message.
  *
  * Besides for the scheduler we don't have always a destinator
- * thread_id needed in frsh_signal_queue for OSE.
+ * thread_id needed in fosa_signal_queue for OSE.
  *
  * So the fosa implementation will solve this issue internally.
  * 
@@ -595,7 +595,7 @@ int fosa_ads_set_handled_signal_set(frsh_signal_t set[], int size);
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_signal_queue_scheduler(frsh_signal_t signal, frsh_signal_info_t info);
+int fosa_signal_queue_scheduler(fosa_signal_t signal, fosa_signal_info_t info);
 
 
 /**
index eab2614f5575ae1d3ee5e944b8a0442c1c4b5d6e..53f4d5560b4178acd533009ade18dd230a91a325 100644 (file)
@@ -121,7 +121,7 @@ int fosa_clock_get_time(fosa_clock_id_t clockid, struct timespec *current_time);
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_thread_get_cputime_clock(frsh_thread_id_t tid, fosa_clock_id_t *clockid);
+int fosa_thread_get_cputime_clock(fosa_thread_id_t tid, fosa_clock_id_t *clockid);
 
 
 /*************************
@@ -162,7 +162,7 @@ int fosa_thread_get_cputime_clock(frsh_thread_id_t tid, fosa_clock_id_t *clockid
  * implementation and dependant applications
  **/
  int fosa_timer_create
-      (fosa_clock_id_t clockid, frsh_signal_t signal, frsh_signal_info_t info,
+      (fosa_clock_id_t clockid, fosa_signal_t signal, fosa_signal_info_t info,
        fosa_timer_id_t *timerid);
 
 /**
@@ -184,8 +184,8 @@ int fosa_thread_get_cputime_clock(frsh_thread_id_t tid, fosa_clock_id_t *clockid
  * implementation and dependant applications
  **/
  int fosa_timer_create_with_receiver
-      (fosa_clock_id_t clockid, frsh_signal_t signal, frsh_signal_info_t info,
-       fosa_timer_id_t *timerid, frsh_thread_id_t receiver);
+      (fosa_clock_id_t clockid, fosa_signal_t signal, fosa_signal_info_t info,
+       fosa_timer_id_t *timerid, fosa_thread_id_t receiver);
 
 /**
  * fosa_timer_delete()
index 3b22ddfeb683e3f963febbda6bba6d918217122c..e5e308c3828ba83969abb6fddaee6d4dbfd380a3 100644 (file)
@@ -81,7 +81,7 @@
 /**
  * Real-time signal number reserved for the long jump handler
  **/
-#define FOSA_LONG_JUMP_SIGNAL             FRSH_SIGNAL_MIN+1
+#define FOSA_LONG_JUMP_SIGNAL             FOSA_SIGNAL_MIN+1
 
 
 
index d9c853152917a5e21a4bcc2773e0e1fa3a9ce45c..b68b8a18668298aea8e3d6fab36d481acc4d2080 100644 (file)
@@ -198,7 +198,7 @@ int fosa_long_jump_was_performed
  *  implementation and dependant applications
  */
 int fosa_long_jump_install_handler
-(frsh_signal_t *signal, frsh_thread_id_t *handler);
+(fosa_signal_t *signal, fosa_thread_id_t *handler);
 
 
 
index cfa1e561cee25714c374fc2a7df84b844d4b874b..6b198e7be82a875f0fd334249a207cc42d427d2f 100644 (file)
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_init(frsh_mutex_t *mutex, int prioceiling);
+int fosa_mutex_init(fosa_mutex_t *mutex, int prioceiling);
 
 /**
  * fosa_mutex_destroy()
@@ -123,7 +123,7 @@ int fosa_mutex_init(frsh_mutex_t *mutex, int prioceiling);
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_destroy(frsh_mutex_t *mutex);
+int fosa_mutex_destroy(fosa_mutex_t *mutex);
 
 /**
  * fosa_mutex_set_prioceiling()
@@ -145,7 +145,7 @@ int fosa_mutex_destroy(frsh_mutex_t *mutex);
  * implementation and dependant applications
  **/
 int fosa_mutex_set_prioceiling
-   (frsh_mutex_t *mutex, int new_ceiling, int *old_ceiling);
+   (fosa_mutex_t *mutex, int new_ceiling, int *old_ceiling);
 
 /**
  * fosa_mutex_get_prioceiling()
@@ -163,7 +163,7 @@ int fosa_mutex_set_prioceiling
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_get_prioceiling(const frsh_mutex_t *mutex, int *ceiling);
+int fosa_mutex_get_prioceiling(const fosa_mutex_t *mutex, int *ceiling);
 
 /**
  * fosa_mutex_lock()
@@ -187,7 +187,7 @@ int fosa_mutex_get_prioceiling(const frsh_mutex_t *mutex, int *ceiling);
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_lock(frsh_mutex_t *mutex);
+int fosa_mutex_lock(fosa_mutex_t *mutex);
 
 /**
  * fosa_mutex_trylock()
@@ -208,7 +208,7 @@ int fosa_mutex_lock(frsh_mutex_t *mutex);
  * implementation is allowed to notify it to the system console and
  * then terminate the FRSH implementation and dependant applications
  **/
-int fosa_mutex_trylock(frsh_mutex_t *mutex);
+int fosa_mutex_trylock(fosa_mutex_t *mutex);
 
 /**
  * fosa_mutex_unlock()
@@ -228,7 +228,7 @@ int fosa_mutex_trylock(frsh_mutex_t *mutex);
  * implementation is allowed to notify it to the system console and
  * then terminate the FRSH implementation and dependant applications
  **/
-int fosa_mutex_unlock(frsh_mutex_t *mutex);
+int fosa_mutex_unlock(fosa_mutex_t *mutex);
 
 
 /**********************
@@ -330,7 +330,7 @@ int fosa_cond_broadcast(fosa_cond_t *cond);
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_cond_wait(fosa_cond_t *cond, frsh_mutex_t *mutex);
+int fosa_cond_wait(fosa_cond_t *cond, fosa_mutex_t *mutex);
 
 /**
  * fosa_cond_timedwait()
@@ -351,7 +351,7 @@ int fosa_cond_wait(fosa_cond_t *cond, frsh_mutex_t *mutex);
  * implementation is allowed to notify it to the system console and
  * then terminate the FRSH implementation and dependant applications
  **/
-int fosa_cond_timedwait(fosa_cond_t *cond, frsh_mutex_t *mutex,
+int fosa_cond_timedwait(fosa_cond_t *cond, fosa_mutex_t *mutex,
       const struct timespec *abstime);
 
 /*@}*/
index b587c91287cdc83bddbe4cf70db225a1be43c3d0..043ebe4c4ef8e76eca4334a439ab57b21726a4b7 100644 (file)
 
 #include <stdbool.h>
 
-/////////////////////// RT_LINUX, MARTE_OS & AQuoSA ///////////////////////////
+///////////////////////  MARTE_OS /////////////////////////////
 
-#if defined(RT_LINUX) || defined(MARTE_OS) || defined(AQuoSA)
+#ifdef MARTE_OS
 
-#ifdef AQuoSA
-#define __USE_UNIX98
-#endif // AQuoSA
 #include <pthread.h>
 #include <signal.h>
 #include <time.h>
 #include <sched.h>
+#include <errno.h>
 
-#ifdef RT_LINUX
-#include <rtl_timer.h>
-#endif // RT_LINUX
+/* Time */
+/********/
+// typedef struct timespec fosa_rel_time_t;
+// typedef struct timespec fosa_abs_time_t;
 
-#define    FOSA_CLOCK_ID_T_OPAQUE    clockid_t
-#define    FOSA_SYSTEM_CLOCK_OPAQUE  CLOCK_MONOTONIC
+/* Thread and signals */
+/**********************/
+typedef pthread_t FOSA_THREAD_ID_T_OPAQUE;
+typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
 
-#define    FOSA_TIMER_ID_T_OPAQUE    timer_t
+typedef int FOSA_SIGNAL_T_OPAQUE;
+/* Signal info is defined as a union in thread_and_signals */
 
-#define    FOSA_COND_T_OPAQUE        pthread_cond_t
+#define FOSA_SIGNAL_MIN       SIGRTMIN
+#define FOSA_SIGNAL_MAX       SIGRTMIN+0
 
-/*********
- *  ADS
- *********/
+#define FOSA_NULL_SIGNAL 0
 
-#ifdef MARTE_OS
+/* Clocks and timers */
+/**********************/
+typedef clockid_t FOSA_CLOCK_ID_T_OPAQUE;
+typedef timer_t FOSA_TIMER_ID_T_OPAQUE;
+
+#define FOSA_SYSTEM_CLOCK_OPAQUE  CLOCK_MONOTONIC
+
+/* Mutex and conditional variables */
+/***********************************/
+typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
+typedef pthread_cond_t FOSA_COND_T_OPAQUE;
+
+
+/* Application defined Scheduling */
+/**********************************/
 typedef struct {
     posix_appsched_actions_t actions;
-    struct timespec * timeout_ptr;
+    struct timespec *timeout_ptr;
     struct timespec timeout;
     bool rejected;
     bool suspended;
     bool activated;
 } fosa_ads_actions_internal_t;
 
-
 #define FOSA_ADS_ACTIONS_T_OPAQUE fosa_ads_actions_internal_t
 
-///////////////////
-// Long jumps
-///////////////////
-
+/* Local jump */
+/**************/
 #include "marte_non_local_jmp.h"
 
 #define FOSA_LONG_JUMP_CONTEXT_T_OPAQUE  struct { \
   marte_nonlocaljmp_context_t marte_context;      \
-  frsh_thread_id_t tid;                            \
+  fosa_thread_id_t tid;                            \
 }
 
-#else // MARTE_OS
 
+/* FOSA errors */
+/***************/
+/** Not enough memory available **/
+#define FOSA_ENOMEM   ENOMEM
+
+/** Invalid parameter **/
+#define FOSA_EINVAL   EINVAL
+
+/** Still pending information **/
+#define FOSA_EAGAIN   EAGAIN
+
+/** FOSA ADS errors **/
+#ifdef MARTE_OS
+#define EREJECT   201 /* (for linux_lib_arch) Appsched has rejected object */
+#endif
+
+#define FOSA_EREJECT   EREJECT
+#define FOSA_EMASKED   -2
+#define FOSA_EPOLICY   -3
+
+#define FOSA_ETIMEDOUT ETIMEDOUT
+
+#endif
+
+///////////////////////  End of MARTE_OS  /////////////////////////////
+
+
+/////////////////////// RT_LINUX ///////////////////////////
+
+#ifdef RT_LINUX
+
+/* Very similar to MARTE_OS but I leave separate for clarity */
+
+#include <pthread.h>
+#include <signal.h>
+#include <time.h>
+#include <sched.h>
+#include <errno.h>
+#include <rtl_timer.h>
+
+/* Time */
+/********/
+// typedef struct timespec fosa_rel_time_t;
+// typedef struct timespec fosa_abs_time_t;
+
+
+/* Threads and signals */
+/***********************/
+#define    FOSA_THREAD_ID_T_OPAQUE pthread_t
+
+typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
+typedef int FOSA_SIGNAL_T_OPAQUE;
+/* Signal info is defined as a union in fosa_types.h */
+
+// The minimum and maximum signal numbers that may be used by the FRSH
+// implementation
+#define FOSA_SIGNAL_MIN       SIGRTMIN
+#define FOSA_SIGNAL_MAX       SIGRTMIN+0
+#define FOSA_NULL_SIGNAL 0
+
+/* Clocks and timers */
+/*********************/
+#define    FOSA_CLOCK_ID_T_OPAQUE    clockid_t
+#define    FOSA_TIMER_ID_T_OPAQUE    timer_t
+#define    FOSA_SYSTEM_CLOCK_OPAQUE  CLOCK_MONOTONIC
+
+/* Mutex and cond vars */
+/***********************/
+typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
+#define    FOSA_COND_T_OPAQUE        pthread_cond_t
+
+
+/* FOSA Errors */
+/***************/
+/** Not enough memory available **/
+#define FOSA_ENOMEM   ENOMEM
+/** Invalid parameter **/
+#define FOSA_EINVAL   EINVAL
+/** Still pending information **/
+#define FOSA_EAGAIN   EAGAIN
+
+/** FOSA ADS errors **/
+#define FOSA_EREJECT   EREJECT
+#define FOSA_EMASKED   -2
+#define FOSA_EPOLICY   -3
+
+#define FOSA_ETIMEDOUT ETIMEDOUT
+
+#endif
+
+///////////////////////  End of RT_LINUX  /////////////////////////////
+
+
+////////////////////////// OSE    //////////////////////////////////////
+
+#ifdef OSE
+
+/* Time */
+/********/
+// typedef struct timespec fosa_rel_time_t;
+// typedef struct timespec fosa_abs_time_t;
+
+
+/* Put OSE dependent includes and defines here */
+
+#endif /* OSE */
+
+
+
+/////////////////////// AQuoSA ///////////////////////////
+
+#ifdef AQuoSA
+
+#define __USE_UNIX98
+
+#include <pthread.h>
+#include <signal.h>
+#include <errno.h>
+#include <time.h>
+
+/* Time */
+/********/
+// typedef struct timespec fosa_rel_time_t;
+// typedef struct timespec fosa_abs_time_t;
+
+
+/* Threads and signals */
+/***********************/
+typedef struct {
+       pthread_t pthread_id;
+       pid_t linux_pid;
+       pid_t linux_tid;
+} FOSA_THREAD_ID_T_OPAQUE;
+
+
+typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
+typedef int FOSA_SIGNAL_T_OPAQUE;
+
+
+// The minimum and maximum signal numbers that may be used by the FRSH
+// implementation
+#define FOSA_SIGNAL_MIN       SIGRTMIN
+#define FOSA_SIGNAL_MAX       SIGRTMIN+0
+
+#define FOSA_NULL_SIGNAL 0
+
+
+/* Clocks and signals */
+/**********************/
+#define    FOSA_CLOCK_ID_T_OPAQUE    clockid_t
+#define    FOSA_SYSTEM_CLOCK_OPAQUE  CLOCK_MONOTONIC
+#define    FOSA_TIMER_ID_T_OPAQUE    timer_t
+
+
+
+/* Mutex and cond vars */
+/***********************/
+typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
+#define    FOSA_COND_T_OPAQUE        pthread_cond_t
+
+
+/* Application Defined Scheduling */
+/**********************************/
 /* hack to get AQuoSA sources compile without having none
  * of the application level scheduler header files and symbols */
-#ifdef AQuoSA
 #define posix_appsched_actions_t int
 #define FOSA_LONG_JUMP_CONTEXT_T_OPAQUE int
-#endif // AQuoSA
 
 #define FOSA_ADS_ACTIONS_T_OPAQUE posix_appsched_actions_t
-#endif // MARTE_OS
 
 
+/* FOSA Errors */
+
+/** Not enough memory available **/
+#define FOSA_ENOMEM   ENOMEM
+
+/** Invalid parameter **/
+#define FOSA_EINVAL   EINVAL
+
+/** Still pending information **/
+#define FOSA_EAGAIN   EAGAIN
+
+#define FOSA_EREJECT   EREJECT
+#define FOSA_EMASKED   -2
+#define FOSA_EPOLICY   -3
+
+#define FOSA_ETIMEDOUT ETIMEDOUT
+
+
+#endif 
+////////////////// END of AQuoSA //////////////////////
+
+
+////////////////////////// VIRTUAL TIME    //////////////////////////////////////
+#ifdef VIRTUAL_TIME
+
+/* Time */
+/********/
+// typedef struct timespec fosa_rel_time_t;
+// typedef struct timespec fosa_abs_time_t;
+
+#include <fosa_vt.h>
+
+#define FOSA_THREAD_ID_T_OPAQUE   vt_posix_process_t
+#define FOSA_THREAD_ATTR_T_OPAQUE fosa_thread_attr_t
+#define FOSA_SIGNAL_T_OPAQUE      int
+
+#define FOSA_MUTEX_T_OPAQUE fosa_mutex_t
+
+// The minimum and maximum signal numbers that may be used by the FRSH
+// implementation
+#define FOSA_SIGNAL_MIN       8
+#define FOSA_SIGNAL_MAX       31
 
-#endif //  defined(RT_LINUX) || defined(MARTE_OS) || defined(AQuoSA)
+// the min. and max. priority a fosa thread can have
+#define FOSA_PRIORITY_MAX VT_PRIORITY_MIN - 1
+#define FOSA_PRIORITY_MIN VT_PRIORITY_MAX
 
+#define FOSA_NULL_SIGNAL       0
 
-////////////////// END OF RT_LINUX, MARTE_OS and AQuoSA //////////////////////
+/* FOSA Errors and return values*/
+
+/** Invalid parameter **/
+#define FOSA_EINVAL   -1
+
+/** Not enough memory available **/
+#define FOSA_ENOMEM   -2
+
+/** Still pending information **/
+#define FOSA_EAGAIN   -3
+
+/** Mutex not available **/
+#define FOSA_EBUSY        -4
+
+/** Cond var timedout **/
+#define FOSA_ETIMEDOUT -5
+
+/** FOSA ADS errors **/
+#define FOSA_EREJECT   -6
+#define FOSA_EMASKED   -7
+
+
+/** Sched policy not correct */
+#define FOSA_EPOLICY   -8
+
+/** the value given by thread_id is not valid for ADS */
+#define FOSA_ESRCH             -9
+
+/** retval if no action performed **/
+#define FOSA_NO_ACTION 0
+
+#endif /* VIRTUAL_TIME */
+//////////////////////////End of VIRTUAL TIME ///////////////////////////////////
 
 
 ////////////////////////// DUMMY_OS    //////////////////////////////////////
@@ -149,21 +397,41 @@ typedef struct {
 /* independent at the FRSH code.                                 */
 /*****************************************************************/
 
-#define    FOSA_CLOCK_ID_T_OPAQUE    int
-#define    FOSA_SYSTEM_CLOCK_OPAQUE  42
+/* Time */
+/********/
+// typedef struct timespec fosa_rel_time_t;
+// typedef struct timespec fosa_abs_time_t;
 
-#define    FOSA_TIMER_ID_T_OPAQUE    int
+/* Thread and signals */
+/**********************/
+typedef int FOSA_THREAD_ID_T_OPAQUE;
+typedef int FOSA_THREAD_ATTR_T_OPAQUE;
 
-#define    FOSA_COND_T_OPAQUE        int
+typedef int FOSA_SIGNAL_T_OPAQUE;
+typedef int FOSA_SIGNAL_INFO_T_OPAQUE;
 
+/* Signal info is defined as a union in thread_and_signals */
 
-/*********
- *  ADS
- *********/
+#define FOSA_SIGNAL_MIN     42
+#define FOSA_SIGNAL_MAX     44
 
-#define FOSA_ADS_ACTIONS_T_OPAQUE  int
+#define FOSA_NULL_SIGNAL 0
 
+/* Clocks and timers */
+/**********************/
+typedef int FOSA_CLOCK_ID_T_OPAQUE;
+typedef int FOSA_TIMER_ID_T_OPAQUE;
 
+#define FOSA_SYSTEM_CLOCK_OPAQUE  25
+
+/* Mutex and conditional variables */
+/***********************************/
+typedef int FOSA_MUTEX_T_OPAQUE;
+typedef int FOSA_COND_T_OPAQUE;
+
+/* Application defined Scheduling */
+/**********************************/
+#define FOSA_ADS_ACTIONS_T_OPAQUE  int
 
 
 #endif /* DUMMY */
index cc79e61ff45e315a598b97450db1139204eb1c63..a6d22856a3d81729fb329f98e36f7fff4fb590e0 100644 (file)
  * @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.
  *
  * @{
  **/
@@ -98,7 +98,7 @@
  * 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 +106,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 +203,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);
 
 
 /**
@@ -206,7 +270,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()
@@ -223,7 +287,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);
 
 
@@ -271,7 +335,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()
@@ -284,7 +348,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()
@@ -302,7 +366,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()
@@ -314,7 +378,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);
 
 
 
@@ -326,7 +390,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.
  *******************************************************************/
@@ -349,7 +413,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()
@@ -380,8 +444,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);
 
 
 
@@ -411,8 +475,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()
@@ -434,8 +498,8 @@ 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);
 
 /*}*/
 
diff --git a/include/fosa_time.h b/include/fosa_time.h
new file mode 100644 (file)
index 0000000..f3ff8c1
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+** fosa_time.h
+** 
+** Made by Miguel marciano
+** Login   <miguel@namir.ctr.unican.es>
+** 
+** Started on  Mon Jan 21 20:01:04 2008 Miguel marciano
+** Last update Mon Jan 21 20:01:04 2008 Miguel marciano
+*/
+#ifndef        FOSA_TIME_H_
+#define        FOSA_TIME_H_
+
+/**
+ * fosa_eat()
+ *
+ * Eat some time using system clock facilities
+ **/
+void inline fosa_eat(const struct timespec *cpu_time);
+
+
+#endif             /* !FOSA_TIME_H_ */
index 67dfdc54e029a65fd650d966670baa68eef39fdf..d46651a10055ef4f60ebbe49a506409f2b354f66 100644 (file)
 #define        _FOSA_TYPES_H_
 
 #include "fosa_opaque_types.h"
-#include "frsh_fosa.h"
+/**
+ * @addtogroup threadandsignals
+ *
+ * @{
+ **/  
+
+/* Coming from FRSH-FOSA */
+
+/** identifier of a FOSA thread **/
+typedef FOSA_THREAD_ID_T_OPAQUE fosa_thread_id_t;
+
+
+/** thread attributes object **/
+typedef FOSA_THREAD_ATTR_T_OPAQUE fosa_thread_attr_t;
+
+typedef FOSA_SIGNAL_T_OPAQUE fosa_signal_t;
+
+/** 
+ *  The type references a function that may become a thread's
+ *  code
+ **/
+typedef void * (*fosa_thread_code_t) (void *);
+
+
+/** information associated to a signal **/
+#if defined(VIRTUAL_TIME)
+
+#include <vt_ose.h>
+typedef vt_posix_signal_info_t fosa_signal_info_t;
+
+#else
+
+typedef union {int sival_int; void * sival_ptr; } fosa_signal_info_t;
+/* typedef FOSA_SIGNAL_INFO_T_OPAQUE fosa_signal_info_t; */
+
+#endif
+
+/* @} */
+
+
 /**
  * @addtogroup clocksandtimers
  *
@@ -91,6 +130,9 @@ typedef    FOSA_TIMER_ID_T_OPAQUE    fosa_timer_id_t;
  * @{
  **/
 // a condition variable
+/** Mutex object.  Attributes are handled by FOSA **/
+typedef    FOSA_MUTEX_T_OPAQUE       fosa_mutex_t;
+
 typedef    FOSA_COND_T_OPAQUE        fosa_cond_t;
 /*@}*/
 
@@ -277,27 +319,27 @@ typedef int fosa_ads_urgency_t;
 typedef struct {
    void (*init) (void * sched_data, void * arg);
    void (*new_thread) (void * sched_data,
-            frsh_thread_id_t thread,
+            fosa_thread_id_t thread,
             fosa_ads_actions_t * actions,
             struct timespec *current_time);
    void (*thread_terminate) (void * sched_data,
-            frsh_thread_id_t thread,
+            fosa_thread_id_t thread,
             fosa_ads_actions_t * actions,
             struct timespec *current_time);
    void (*thread_ready) (void * sched_data,
-            frsh_thread_id_t thread,
+            fosa_thread_id_t thread,
             fosa_ads_actions_t * actions,
             struct timespec *current_time);
    void (*thread_block) (void * sched_data,
-            frsh_thread_id_t thread,
+            fosa_thread_id_t thread,
             fosa_ads_actions_t * actions,
             struct timespec *current_time);
   //void (*thread_yield) (void * sched_data,
-  //          frsh_thread_id_t thread,
+  //          fosa_thread_id_t thread,
   //          fosa_ads_actions_t * actions,
   //          struct timespec *current_time);
    void (*change_sched_param_thread) (void * sched_data,
-            frsh_thread_id_t thread,
+            fosa_thread_id_t thread,
             fosa_ads_actions_t * actions,
             struct timespec *current_time);
   //void msg_from_scheduler(void * sched_data,
@@ -306,18 +348,18 @@ typedef struct {
   //          fosa_ads_actions_t * actions,
   //          struct timespec *current_time);
   //void (*explicit_call) (void * sched_data,
-  //          frsh_thread_id_t thread,
+  //          fosa_thread_id_t thread,
   //         int user_event_code,
   //         fosa_ads_actions_t * actions,
   //         struct timespec *current_time);
   void (*explicit_call_with_data) (void * sched_data,
-           frsh_thread_id_t thread,
+           fosa_thread_id_t thread,
            const void * msg, size_t msg_size,
            void *reply, size_t *reply_size,
            fosa_ads_actions_t * actions,
            struct timespec *current_time);
   void (*notification_for_thread) (void * sched_data,
-           frsh_thread_id_t thread,
+           fosa_thread_id_t thread,
            fosa_clock_id_t clock,
            fosa_ads_actions_t * actions,
            struct timespec *current_time);
@@ -325,22 +367,22 @@ typedef struct {
            fosa_ads_actions_t * actions,
            struct timespec *current_time);
   void (*signal) (void * sched_data,
-          frsh_signal_t signal,
-           frsh_signal_info_t siginfo,
+          fosa_signal_t signal,
+           fosa_signal_info_t siginfo,
            fosa_ads_actions_t * actions,
            struct timespec *current_time);
   //void (*priority_inherit) (void * sched_data,
-  //         frsh_thread_id_t thread,
+  //         fosa_thread_id_t thread,
   //         int sched_priority,
   //         fosa_ads_actions_t * actions,
   //         struct timespec *current_time);
   //void (*priority_uninherit) (void * sched_data,
-  //         frsh_thread_id_t thread,
+  //         fosa_thread_id_t thread,
   //         int sched_priority,
   //         fosa_ads_actions_t * actions,
   //         struct timespec *current_time);
   void (*appsched_error) (void * sched_data,
-          frsh_thread_id_t thread,
+          fosa_thread_id_t thread,
           fosa_ads_error_cause_t cause,
            fosa_ads_actions_t * actions);
 } fosa_ads_scheduler_ops_t;
diff --git a/include/timespec_operations.h b/include/timespec_operations.h
new file mode 100644 (file)
index 0000000..2a4cf27
--- /dev/null
@@ -0,0 +1,269 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politécnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    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
+//        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.
+//
+//
+//  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
+//
+//   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.
+//
+//  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.
+//
+//  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.
+// -----------------------------------------------------------------------
+/*-----------------------------------------------------------------------
+ *                                                         V1.0  Dec 2001
+ *
+ *                    't i m e s p e c _ o p e r a t i o n s'
+ *
+ *                                      H
+ *
+ * File 'timespec_operations.h'                                   by MAR.
+ *                           (july 2002)  transformed into macros by Jul.
+ * Some basic operations with the type 'timespec'.
+ *
+ * ----------------------------------------------------------------------
+ *  Copyright (C) 2001   Universidad de Cantabria, SPAIN
+ *
+ *  Authors: Mario Aldea Rivas          aldeam@ctr.unican.es
+ *           Michael Gonzalez Harbour      mgh@ctr.unican.es
+ *
+ * MaRTE OS  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.
+ *
+ * MaRTE OS  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
+ * distributed with MaRTE  OS;  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  link this  unit  with other  files to
+ * produce an   executable,   this unit  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 Public License.
+ *
+ *---------------------------------------------------------------------------*/
+// 16-Jul-2007 SANGORRIN corrections to msec_addto_timespec and msec2timespec
+// 23-Jul-2007 SANGORRIN moved t2d and d2t from frsh_time_operations
+// (TODO: test for __ALL__ the functions)
+// -----------------------------------------------------------------------
+
+#ifndef        _MARTE_MISC_TIMESPEC_OPERATIONS_H_
+#define _MARTE_MISC_TIMESPEC_OPERATIONS_H_
+
+/**
+ * @file timespec_operations.h
+ **/
+
+#include <time.h> // for timespec
+#include <string.h> // for memset
+
+#define smaller_timespec(t1, t2) \
+ ( \
+  (t1)->tv_sec < (t2)->tv_sec || ((t1)->tv_sec == (t2)->tv_sec &&   \
+  (t1)->tv_nsec < (t2)->tv_nsec) \
+ )
+
+#define smaller_or_equal_timespec(t1, t2) \
+ ( \
+  (t1)->tv_sec < (t2)->tv_sec || ((t1)->tv_sec == (t2)->tv_sec &&    \
+  (t1)->tv_nsec <= (t2)->tv_nsec) \
+ )
+
+#define incr_timespec(t1, t2) \
+do { \
+  (t1)->tv_sec += (t2)->tv_sec; \
+  (t1)->tv_nsec += (t2)->tv_nsec; \
+  if ((t1)->tv_nsec >= 1000000000) { \
+    (t1)->tv_sec ++; \
+    (t1)->tv_nsec -= 1000000000; \
+  } \
+} while (0)
+
+#define decr_timespec(t1, t2) \
+do { \
+  if ((t1)->tv_nsec < (t2)->tv_nsec) { \
+    (t1)->tv_sec -= (t2)->tv_sec + 1; \
+    (t1)->tv_nsec = (t1)->tv_nsec + 1000000000 - (t2)->tv_nsec; \
+  } else { \
+    (t1)->tv_sec -= (t2)->tv_sec; \
+    (t1)->tv_nsec -= (t2)->tv_nsec; \
+  } \
+} while (0)
+
+#define  add_timespec( sum , t1 , t2 ) \
+do { \
+  (sum)->tv_sec  = (t1)->tv_sec  + (t2)->tv_sec; \
+  (sum)->tv_nsec = (t1)->tv_nsec + (t2)->tv_nsec; \
+  if ((sum)->tv_nsec >= 1000000000) { \
+    (sum)->tv_sec ++; \
+    (sum)->tv_nsec -= 1000000000; \
+  } \
+} while (0)
+
+#define float_to_timespec( f1 , t1 ) \
+( \
+  (t1)->tv_sec = (int)(f1), \
+  (t1)->tv_nsec = (int)(((f1)-(float)((t1)->tv_sec))*1000000000.0), \
+  (t1) \
+)
+
+#define float_to_timespec_value(f1, t1) \
+( \
+  (t1).tv_sec = (int)(f1), \
+  (t1).tv_nsec = (int)(((f1)-(float)((t1).tv_sec))*1000000000.0), \
+  (t1) \
+)
+
+//---------------//
+// msec2timespec //
+//---------------//
+
+static inline struct timespec msec2timespec(long msec)
+{
+    struct timespec result = {-1, -1};
+
+    if (msec >= 1000) {
+        result.tv_sec = msec/1000;
+        result.tv_nsec = (msec % 1000) * 1000000;
+    } else {
+        result.tv_sec = 0;
+        result.tv_nsec = msec * 1000000;
+    }
+
+    return result;
+}
+
+static inline long timespec2msec(const struct timespec *timespec)
+{
+    
+    return (timespec->tv_sec % 2147482) * 1000 + timespec->tv_nsec/1000000;
+}
+
+
+#define HOURS_IN_MSECS 3600000
+#define MINUTES_IN_MSECS 60000
+
+#define HOURS_IN_TS     1000000
+#define MINUTES_IN_TS    100000
+
+static inline long timespec2msects(const struct timespec *timespec)
+{
+    long msec_total = -1;
+    long minutes = -1;
+    long hours = -1;
+
+    long remainder_msecs = -1;
+    long timestamp = -1;
+
+    msec_total = (timespec->tv_sec % 2147482) * 1000 + timespec->tv_nsec/1000000;
+
+    hours = msec_total / HOURS_IN_MSECS;
+    minutes = (msec_total % HOURS_IN_MSECS) / MINUTES_IN_MSECS;
+    remainder_msecs = ( (msec_total % HOURS_IN_MSECS) % MINUTES_IN_MSECS);
+    
+    timestamp = hours*HOURS_IN_TS + minutes*MINUTES_IN_TS + remainder_msecs;
+
+    return timestamp;
+}
+    
+
+//------------------------//
+// timespec_lessthan_msec //
+//------------------------//
+
+static inline int timespec_lessthan_msec(struct timespec *timespec, long msec)
+{
+    struct timespec msec_timespec = {0, 0};
+
+    msec_timespec = msec2timespec(msec);
+    return smaller_timespec(timespec, &msec_timespec);
+}
+
+//---------------------//
+// msec_addto_timespec //
+//---------------------//
+
+static inline void msec_addto_timespec(long msec, struct timespec *timespec)
+{
+    struct timespec msec_timespec = {0, 0};
+
+    msec_timespec = msec2timespec(msec);
+    incr_timespec(timespec, &msec_timespec);
+}
+
+//--------------------------//
+// t2d (timespec to double) //
+//--------------------------//
+
+static inline double t2d(struct timespec time)
+{
+    return time.tv_nsec*0.000000001 + (double)time.tv_sec;
+}
+
+//--------------------------//
+// d2t (double to timespec) //
+//--------------------------//
+
+static inline struct timespec d2t(double time)
+{
+    struct timespec tmp;
+
+    tmp.tv_sec = (long) time;
+    tmp.tv_nsec = (long)((time - (double)tmp.tv_sec) * 1000000000);
+
+    return tmp;
+}
+
+#endif /* _MARTE_MISC_TIMESPEC_OPERATIONS_H_ */
index 8d99e3ca08731cadc6c34af64c302ffafd677400..a3a7b955b7f5b4ae83fb60eb6932a082596a8988 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -8,7 +8,6 @@ endif
 
 
 CFLAGS += -D$(PLATFORM) \
-        -I$(FRSH_PATH)/include \
         -I$(FOSA_PATH)/include \
         -I$(UTILS_PATH)/include
 
index b63cd075d8e491b866283ab1d8c913dcf78f5018..757f5beb7232e7eb87c9c75399bd54445a62e04e 100644 (file)
 // before suspend or activate it.
 // -----------------------------------------------------------------------
 
-#include "fosa_app_def_sched.h"
-#include "fosa_configuration_parameters.h"
-#include "fosa_threads_and_signals.h"
-#include "frsh_error.h"
-#include "frsh_fosa.h"
+#include "fosa.h"
 
 #include <pthread.h>
 #include <stdio.h>
@@ -367,7 +363,7 @@ void * scheduler_thread_code(void *arg) {
                sch_thread_data->scheduler_ops.signal
                   (scheduler_data,
                   event.event_info.siginfo.si_signo,
-                  *((frsh_signal_info_t *)(&(event.event_info.siginfo.si_value))),
+                  *((fosa_signal_info_t *)(&(event.event_info.siginfo.si_value))),
                   // the above casting construct is used to overcome the compiler
                   // restriction that does not allow casts between unions
                   &sched_actions,
@@ -519,7 +515,7 @@ int fosa_ads_scheduler_create
  * implementation and dependant applications
  **/
 int fosa_thread_attr_set_appscheduled
-        (frsh_thread_attr_t *attr,
+        (fosa_thread_attr_t *attr,
          bool appscheduled)
 {
    int error_code;
@@ -554,7 +550,7 @@ int fosa_thread_attr_set_appscheduled
  * implementation and dependant applications
  **/
 int fosa_thread_attr_get_appscheduled
-        (const frsh_thread_attr_t *attr,
+        (const fosa_thread_attr_t *attr,
          bool *appscheduled)
 {
    int policy, ret_value;
@@ -592,7 +588,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)
 {
@@ -622,7 +618,7 @@ int fosa_thread_attr_set_appsched_params
  * 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)
 {
@@ -653,7 +649,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)
 {
    int error_code = 0;
@@ -696,7 +692,7 @@ int fosa_ads_set_appscheduled
  * implementation and dependant applications
  **/
 int fosa_ads_get_appscheduled
-        (frsh_thread_id_t thread,
+        (fosa_thread_id_t thread,
          bool *appscheduled)
 {
    int error_code, policy;
@@ -735,7 +731,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)
 {
@@ -766,7 +762,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)
 {
@@ -820,7 +816,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)
 {
 #ifdef FULL_ERROR_CHECKING
   // check errors
@@ -866,7 +862,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)
 {
 #ifdef FULL_ERROR_CHECKING
@@ -909,7 +905,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)
 {
 #ifdef FULL_ERROR_CHECKING
    // check errors
@@ -985,7 +981,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)
 {
@@ -1041,7 +1037,7 @@ int fosa_adsactions_add_thread_notification(
  * 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 size)
+int fosa_ads_set_handled_signal_set(fosa_signal_t set[], int size)
 {
    int i;
 
@@ -1076,7 +1072,7 @@ int fosa_ads_set_handled_signal_set(frsh_signal_t set[], int size)
  * notification message.
  *
  * Besides for the scheduler we don't have always a destinator
- * thread_id needed in frsh_signal_queue for OSE.
+ * thread_id needed in fosa_signal_queue for OSE.
  *
  * So the fosa implementation will solve this issue internally.
  *
@@ -1092,11 +1088,11 @@ int fosa_ads_set_handled_signal_set(frsh_signal_t set[], int size)
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_signal_queue_scheduler(frsh_signal_t signal, frsh_signal_info_t info)
+int fosa_signal_queue_scheduler(fosa_signal_t signal, fosa_signal_info_t info)
 {
    // In MaRTE OS this function is completely equivalent to
    // fosa_signal_queue, because there is no notion of receiver.
-   frsh_thread_id_t receiver = 0; // Dummy value, not used by MaRTE OS
+   fosa_thread_id_t receiver = 0; // Dummy value, not used by MaRTE OS
    return fosa_signal_queue(signal, info, receiver);
 }
 
index 3a732f4eaa755782acf5d2920eca5838ff5084bf..03f0b68e2c8d0a685d528fa3648cd6bc08af0b4c 100644 (file)
@@ -115,7 +115,7 @@ int fosa_clock_get_time(fosa_clock_id_t clockid, struct timespec *current_time)
  * implementation and dependant applications
  **/
 int fosa_thread_get_cputime_clock
-    (frsh_thread_id_t tid, fosa_clock_id_t *clockid)
+    (fosa_thread_id_t tid, fosa_clock_id_t *clockid)
 {
   return pthread_getcpuclockid(tid,clockid);
 }
@@ -159,7 +159,7 @@ int fosa_thread_get_cputime_clock
  * implementation and dependant applications
  **/
  int fosa_timer_create
-      (fosa_clock_id_t clockid, frsh_signal_t signal, frsh_signal_info_t info,
+      (fosa_clock_id_t clockid, fosa_signal_t signal, fosa_signal_info_t info,
        fosa_timer_id_t *timerid)
 {
   struct sigevent evp;
@@ -190,8 +190,8 @@ int fosa_thread_get_cputime_clock
  * implementation and dependant applications
  **/
  int fosa_timer_create_with_receiver
-      (fosa_clock_id_t clockid, frsh_signal_t signal, frsh_signal_info_t info,
-       fosa_timer_id_t *timerid, frsh_thread_id_t receiver)
+      (fosa_clock_id_t clockid, fosa_signal_t signal, fosa_signal_info_t info,
+       fosa_timer_id_t *timerid, fosa_thread_id_t receiver)
 {
   // in POSIX the receiver thread cannot be specified
   return fosa_timer_create(clockid,signal,info,timerid);
index 417c94ab6867a7d03d23148cebaa8aa9be4f65ac..7a29265be35379a8a7703dbbbc43b936b7a90637 100644 (file)
@@ -64,9 +64,9 @@
 //================================================
 
 #include <stdio.h>
-#include "fosa_long_jump.h"
-#include "fosa_configuration_parameters.h"
-#include "fosa_threads_and_signals.h"
+#include <stdlib.h>
+
+#include "fosa.h"
 #include <marte_non_local_jmp.h>
 
 /**
@@ -74,7 +74,7 @@
  */
 
 static int handler_installed=0;
-static frsh_thread_id_t handler_tid;
+static fosa_thread_id_t handler_tid;
 
 /**
  *  fosa_long_jump_save_context
@@ -157,16 +157,16 @@ int fosa_long_jump_was_performed
 
 void * fosa_long_jump_handler (void * arg) {
 
-  frsh_signal_t set[1];
-  frsh_signal_t sig;
-  frsh_signal_info_t siginfo;
+  fosa_signal_t set[1];
+  fosa_signal_t sig;
+  fosa_signal_info_t siginfo;
 
   fosa_long_jump_context_t *info;
 
   // initialize signal handling
   set[0]=FOSA_LONG_JUMP_SIGNAL;
   if (fosa_set_accepted_signals(set, 1) !=0) {
-      printf("FRSH_ERR_INTERNAL_ERROR, Error setting the signal mask\n");
+      printf("FOSA_ERR_INTERNAL_ERROR, Error setting the signal mask\n");
       exit(1); 
   }
 
@@ -174,7 +174,7 @@ void * fosa_long_jump_handler (void * arg) {
   while (1) {
     // Wait for a budget overrun signal
     if ((fosa_signal_wait(set, 1, &sig, &siginfo)) == -1) {
-      printf("FRSH_ERR_INTERNAL_ERROR, signal wait in long jump handler\n");
+      printf("FOSA_ERR_INTERNAL_ERROR, signal wait in long jump handler\n");
       exit(1);
     }
     // Restore thread's context
@@ -228,9 +228,9 @@ void * fosa_long_jump_handler (void * arg) {
  *  implementation and dependant applications
  */
 int fosa_long_jump_install_handler
-(frsh_signal_t *signal, frsh_thread_id_t *handler)
+(fosa_signal_t *signal, fosa_thread_id_t *handler)
 {
-  frsh_thread_attr_t attr;
+  fosa_thread_attr_t attr;
   int err;
   
   if (!handler_installed) {
@@ -242,7 +242,7 @@ int fosa_long_jump_install_handler
     //////////////////////////////////////////////////
     
     // Create the thread attributes object
-    err=frsh_thread_attr_init (&attr);
+    err=fosa_thread_attr_init (&attr);
     if (err != 0) {
       printf("Error while initializing the attributes\n");
       return err;
@@ -264,7 +264,7 @@ int fosa_long_jump_install_handler
     }
     
     // destroy the thread attributes object
-    err=frsh_thread_attr_destroy (&attr);
+    err=fosa_thread_attr_destroy (&attr);
     if (err != 0) {
       printf("Error while destroying the attributes\n");
       return err;
index 59acd210c2d6ba51b5cac20ef4e5f033bc0c0967..e8b4123f6cbf5f81409b4c316f2ea3c729149f8a 100644 (file)
@@ -95,7 +95,7 @@
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_init(frsh_mutex_t *mutex, int prioceiling)
+int fosa_mutex_init(fosa_mutex_t *mutex, int prioceiling)
 {
   pthread_mutexattr_t attr;
   int ret_value;
@@ -133,7 +133,7 @@ int fosa_mutex_init(frsh_mutex_t *mutex, int prioceiling)
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_destroy(frsh_mutex_t *mutex)
+int fosa_mutex_destroy(fosa_mutex_t *mutex)
 {
   return pthread_mutex_destroy(mutex);
 }
@@ -157,7 +157,7 @@ int fosa_mutex_destroy(frsh_mutex_t *mutex)
  * implementation and dependant applications
  **/
 int fosa_mutex_set_prioceiling
-   (frsh_mutex_t *mutex, int new_ceiling, int *old_ceiling)
+   (fosa_mutex_t *mutex, int new_ceiling, int *old_ceiling)
 {
   return pthread_mutex_setprioceiling(mutex,new_ceiling,old_ceiling);
 }
@@ -177,7 +177,7 @@ int fosa_mutex_set_prioceiling
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_get_prioceiling(const frsh_mutex_t *mutex, int *ceiling)
+int fosa_mutex_get_prioceiling(const fosa_mutex_t *mutex, int *ceiling)
 {
   return pthread_mutex_getprioceiling(mutex,ceiling);
 }
@@ -201,7 +201,7 @@ int fosa_mutex_get_prioceiling(const frsh_mutex_t *mutex, int *ceiling)
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_mutex_lock(frsh_mutex_t *mutex)
+int fosa_mutex_lock(fosa_mutex_t *mutex)
 {
   return pthread_mutex_lock(mutex);
 }
@@ -224,7 +224,7 @@ int fosa_mutex_lock(frsh_mutex_t *mutex)
  * implementation is allowed to notify it to the system console and
  * then terminate the FRSH implementation and dependant applications
  **/
-int fosa_mutex_trylock(frsh_mutex_t *mutex)
+int fosa_mutex_trylock(fosa_mutex_t *mutex)
 {
   return pthread_mutex_trylock(mutex);
 }
@@ -247,7 +247,7 @@ int fosa_mutex_trylock(frsh_mutex_t *mutex)
  * implementation is allowed to notify it to the system console and
  * then terminate the FRSH implementation and dependant applications
  **/
-int fosa_mutex_unlock(frsh_mutex_t *mutex)
+int fosa_mutex_unlock(fosa_mutex_t *mutex)
 {
   return pthread_mutex_unlock(mutex);
 }
@@ -366,7 +366,7 @@ int fosa_cond_broadcast(fosa_cond_t *cond)
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_cond_wait(fosa_cond_t *cond, frsh_mutex_t *mutex)
+int fosa_cond_wait(fosa_cond_t *cond, fosa_mutex_t *mutex)
 {
   return pthread_cond_wait(cond,mutex);
 }
@@ -390,7 +390,7 @@ int fosa_cond_wait(fosa_cond_t *cond, frsh_mutex_t *mutex)
  * implementation is allowed to notify it to the system console and
  * then terminate the FRSH implementation and dependant applications
  **/
-int fosa_cond_timedwait(fosa_cond_t *cond, frsh_mutex_t *mutex,
+int fosa_cond_timedwait(fosa_cond_t *cond, fosa_mutex_t *mutex,
       const struct timespec *abstime)
 {
   return pthread_cond_timedwait(cond,mutex,abstime);
index 39af09b952cb12c5836b2ca775eb99e2934eb5ad..bb35efffc77d4cb46369f3df723cab18f58ab0fc 100644 (file)
@@ -137,7 +137,7 @@ void init_keys() {
  * 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)
 {
   return pthread_equal(t1,t2);
 }
@@ -148,11 +148,103 @@ 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()
 {
   return pthread_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)
+{
+  int ret_value;
+
+  ret_value=pthread_attr_init(attr);
+  if (ret_value==0) {
+    // set the default values
+
+    // detachstate = detached thread (no join operation allowed)
+    CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
+
+    // inheritsched = explicit, so that we can explicitly set the attributes
+    CHK(pthread_attr_setinheritsched(attr,PTHREAD_EXPLICIT_SCHED));
+
+    // schedpolicy = fixed priorities
+    CHK(pthread_attr_setschedpolicy(attr,SCHED_FIFO));
+
+    // detachstate = detached thread (no join operation allowed)
+    CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
+
+  }
+  return ret_value;
+}
+
+/**
+ * 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)
+{
+  return pthread_attr_destroy(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)
+{
+  return pthread_attr_setstacksize(attr,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)
+{
+  return pthread_attr_getstacksize(attr,stacksize);
+}
+
 
 /*************************
  * Thread creation and termination
@@ -184,8 +276,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)
 {
   return pthread_create(tid,attr,code,arg);
 }
@@ -226,6 +318,7 @@ int fosa_key_create(int *key)
   int i,ret_value;
   bool found=false;
 
+  ret_value = 0;
   // initialize the keys data structure if needed
   CHK(pthread_once(&keys_initialized, init_keys));
 
@@ -296,7 +389,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)
 {
   return pthread_setspecific_for(key_list[key],tid,value);
 }
@@ -316,7 +409,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)
 {
   return pthread_getspecific_from(key_list[key],tid,value);
@@ -373,7 +466,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)
 {
   struct sched_param param;
 
@@ -392,7 +485,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)
 {
   struct sched_param param;
   int ret_value;
@@ -420,7 +513,7 @@ int fosa_thread_attr_get_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)
 {
   struct sched_param param;
   int policy, ret_value;
@@ -442,7 +535,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)
 {
   struct sched_param param;
   int policy, ret_value;
@@ -464,7 +557,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.
  *******************************************************************/
@@ -487,7 +580,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)
 {
   sigset_t signalset;
   int i;
@@ -541,8 +634,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)
 {
   // note: in MaRTE OS the signal is sent to any interested thread
   pid_t pid=1; // dummy value; the pid is ignored in MaRTE OS
@@ -583,8 +676,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)
 {
   int err,i;
   sigset_t signalset;
@@ -598,7 +691,7 @@ int fosa_signal_wait
   err=sigwaitinfo(&signalset,&siginfo);
   if (err!=-1) {
     *signal_received=siginfo.si_signo;
-    *info=*((frsh_signal_info_t *)(&siginfo.si_value));
+    *info=*((fosa_signal_info_t *)(&siginfo.si_value));
     return 0;
   } else {
     return errno;
@@ -625,8 +718,8 @@ int fosa_signal_wait
  * 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)
 {
 
   // the implementation of sigtimedwait is not yet available in MaRTE OS
similarity index 59%
rename from src_marte/frsh_fosa.c
rename to src_marte/fosa_time.c
index 66c64e9a353f31fa03343ceab3c0954bf271c50a..b62a9d6cedbe528fe3507611d740c1bdcb4aa997 100644 (file)
@@ -49,7 +49,7 @@
 // however invalidate any other reasons why the executable file might be
 // covered by the GNU Public License.
 // -----------------------------------------------------------------------
-//frsh_fosa.c
+// fosa_time.c
 //==============================================
 //  ********  ******    ********  **********
 //  **///// /**    **  **//////  /**     /**
@@ -63,7 +63,7 @@
 // FOSA(Frescor Operating System Adaptation layer)
 //================================================
 
-#include "frsh_fosa.h"
+#include "fosa.h"
 #include <pthread.h>
 #include <stdio.h>
 #include <time.h>
 
 #include <misc/error_checks.h>
 
-/*************************
- * Thread attributes
- *************************/ 
 
 /**
- * frsh_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 frsh_thread_attr_init(frsh_thread_attr_t *attr)
-{
-  int ret_value;
-
-  ret_value=pthread_attr_init(attr);
-  if (ret_value==0) {
-    // set the default values
-
-    // detachstate = detached thread (no join operation allowed)
-    CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
-
-    // inheritsched = explicit, so that we can explicitly set the attributes
-    CHK(pthread_attr_setinheritsched(attr,PTHREAD_EXPLICIT_SCHED));
-
-    // schedpolicy = fixed priorities
-    CHK(pthread_attr_setschedpolicy(attr,SCHED_FIFO));
-
-    // detachstate = detached thread (no join operation allowed)
-    CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
-
-  }
-  return ret_value;
-}
-
-/**
- * frsh_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 frsh_thread_attr_destroy(frsh_thread_attr_t *attr)
-{
-  return pthread_attr_destroy(attr);
-}
-
-/**
- * frsh_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 frsh_thread_attr_set_stacksize
-     (frsh_thread_attr_t *attr, size_t stacksize)
-{
-  return pthread_attr_setstacksize(attr,stacksize);
-}
-
-/**
- * frsh_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 frsh_thread_attr_get_stacksize
-      (const frsh_thread_attr_t *attr, size_t *stacksize)
-{
-  return pthread_attr_getstacksize(attr,stacksize);
-}
-
-
-/**
- * frsh_eat()
+ * fosa_eat()
  *
  * Eat some time using system clock facilities
  **/
@@ -174,7 +82,7 @@ int frsh_thread_attr_get_stacksize
     #include <fosa_vt.h>
 #endif
 
-void inline frsh_eat(const struct timespec *cpu_time)
+void inline fosa_eat(const struct timespec *cpu_time)
 {
 #ifdef VIRTUAL_TIME
     vt_time_t vt_clock;
@@ -197,3 +105,6 @@ void inline frsh_eat(const struct timespec *cpu_time)
     }
 #endif
 }
+
+
+
index 9cda36bac1faa0fea1c754960c90764b0c948dd6..d745e7abb5d270803811a6f0105f23b0b9ec8e9b 100644 (file)
@@ -18,13 +18,13 @@ static void inline assert(expression)
 int main () {
    int err;
    fosa_clock_id_t clockid = FOSA_CLOCK_REALTIME;
-   frsh_signal_t signal = FOSA_SIGNAL_MAX;
-   frsh_signal_t received;
-   frsh_signal_info_t info, info_received;
+   fosa_signal_t signal = FOSA_SIGNAL_MAX;
+   fosa_signal_t received;
+   fosa_signal_info_t info, info_received;
    fosa_timer_id_t timerid;
    bool abstime = false;
    struct timespec timerval;
-   frsh_signal_t set[1];
+   fosa_signal_t set[1];
 
    info.sival_int=69;
 
index 9dbf63cd1117d58e03fcd2e0adb8d5d7da7395ee..2dfd6c5c08a2d0cf3d7f17109666573fae738eb5 100644 (file)
@@ -31,17 +31,17 @@ int main ()
 {
     int err = -1;
 
-    frsh_thread_attr_t attr;
-    frsh_thread_id_t tid;
+    fosa_thread_attr_t attr;
+    fosa_thread_id_t tid;
 
-    frsh_signal_t signal_received;
-    frsh_signal_info_t info_programmed, info_received;
+    fosa_signal_t signal_received;
+    fosa_signal_info_t info_programmed, info_received;
     struct timespec work_interval = {3, 200000000}; // 3.2 seconds
     fosa_clock_id_t clockid;
     fosa_timer_id_t timerid;
 
     struct timespec budget = {-1, -1};
-    frsh_signal_t signal_set[1];
+    fosa_signal_t signal_set[1];
 
 
 
@@ -67,7 +67,7 @@ int main ()
 
     /* Create the thread attributes and define its priority */
     /********************************************************/
-    if (frsh_thread_attr_init (&attr) != 0) {
+    if (fosa_thread_attr_init (&attr) != 0) {
         printf("Error while initializing the attributes\n");
         exit(1);
     }
@@ -110,7 +110,7 @@ int main ()
     /* and real time differ                                  */
     /*********************************************************/
     printf("Main works for some time...\n");
-    frsh_eat(&work_interval);
+    fosa_eat(&work_interval);
 
     /* Now we do the wait in order to allow the thread to run */
     /**********************************************************/
@@ -149,7 +149,7 @@ static void * thread_body(void *thread_arg)
         printf("Start periodic work  at %d, %d\n", 
                before_work_time.tv_sec, before_work_time.tv_nsec);
 
-        frsh_eat(&work_interval);
+        fosa_eat(&work_interval);
 
         err = fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_work_time);
         assert(err == 0);
index cb1448e50620657cb61a3251aca8c6f6498c6017..378004f34feb5fb64c6bedcd2fac2402223a11dd 100644 (file)
@@ -33,15 +33,15 @@ int main ()
 {
     int err = -1;
 
-    frsh_thread_attr_t attr;
-    frsh_thread_id_t tid;
+    fosa_thread_attr_t attr;
+    fosa_thread_id_t tid;
 
-    frsh_signal_t signal_received;
-    frsh_signal_info_t info_received;
+    fosa_signal_t signal_received;
+    fosa_signal_info_t info_received;
 
     struct timespec work_interval = {3, 200000000}; // 3.2 seconds
 
-    frsh_signal_t signal_set[1];
+    fosa_signal_t signal_set[1];
 
 
 
@@ -67,7 +67,7 @@ int main ()
     /* At the same time ensure that the main priority is    */
     /* higher  */
     /********************************************************/
-    if (frsh_thread_attr_init (&attr) != 0) {
+    if (fosa_thread_attr_init (&attr) != 0) {
         printf("Error while initializing the attributes\n");
         exit(1);
     }
@@ -91,7 +91,7 @@ int main ()
     /* and real time differ                                  */
     /*********************************************************/
     printf("Main works for some time...\n");
-    frsh_eat(&work_interval);
+    fosa_eat(&work_interval);
 
     /* Now we do the wait in order to allow the thread to run */
     /**********************************************************/
@@ -123,7 +123,7 @@ static void * thread_body(void *thread_arg)
     fosa_timer_id_t timerid;
     struct timespec budget = {-1, -1};
 
-    frsh_signal_info_t info_programmed;
+    fosa_signal_info_t info_programmed;
 
     memset(&clockid, 0, sizeof(clockid) );
     memset(&timerid, 0, sizeof(timerid) );
@@ -160,7 +160,7 @@ static void * thread_body(void *thread_arg)
         printf("Start periodic work  at %d, %d\n", 
                before_work_time.tv_sec, before_work_time.tv_nsec);
 
-        frsh_eat(&work_interval);
+        fosa_eat(&work_interval);
 
         err = fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_work_time);
         assert(err == 0);
index 3e32461b95990a757f121b72cbf64d1e0cb5a06e..486d7f0bf563a1fc0661e3d85b6e553aff71d520 100644 (file)
 // covered by the GNU Public License.
 // -----------------------------------------------------------------------
 
-#include "fosa_app_def_sched.h"
-#include "fosa_threads_and_signals.h"
-#include "fosa_mutexes_and_condvars.h"
-#include "fosa_clocks_and_timers.h"
 #include <stdio.h>  // for printf
 #include <string.h> // for strlen, strncpy
 #include <unistd.h> // for sleep
 #include <time.h> // for nanosleep
-#include <misc/load.h> // for adjust, eat
+
 
 // TODO: use #include <assert.h> when it works for all architectures
 #include <stdlib.h> // for exit in assert
 
+#include "fosa.h"
+
 static void inline assert(expression)
 {
     if (!expression) {
@@ -77,42 +75,42 @@ static void inline assert(expression)
 
 static void *thread_code(void *arg);
 
-static void frsh_callback_init
+static void fosa_callback_init
                 (void *sched_data, void *arg);
 
-static void frsh_callback_new_thread
+static void fosa_callback_new_thread
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_thread_terminate
+static void fosa_callback_thread_terminate
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_thread_ready
+static void fosa_callback_thread_ready
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_thread_block
+static void fosa_callback_thread_block
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_change_sched_param_thread
+static void fosa_callback_change_sched_param_thread
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_explicit_call_with_data
+static void fosa_callback_explicit_call_with_data
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  const void * msg,
                  size_t msg_size,
                  void *reply,
@@ -120,28 +118,28 @@ static void frsh_callback_explicit_call_with_data
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_notification_for_thread
+static void fosa_callback_notification_for_thread
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  fosa_clock_id_t clock,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_timeout
+static void fosa_callback_timeout
                 (void *sched_data,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_signal
+static void fosa_callback_signal
                 (void *sched_data,
-                 frsh_signal_t signal,
-                 frsh_signal_info_t siginfo,
+                 fosa_signal_t signal,
+                 fosa_signal_info_t siginfo,
                  fosa_ads_actions_t *actions,
                  struct timespec *current_time);
 
-static void frsh_callback_appsched_error
+static void fosa_callback_appsched_error
                 (void *sched_data,
-                 frsh_thread_id_t thread,
+                 fosa_thread_id_t thread,
                  fosa_ads_error_cause_t cause,
                  fosa_ads_actions_t *actions);
 
@@ -150,20 +148,20 @@ static void frsh_callback_appsched_error
 ///////////////////////////////////////////////////////
 
 static fosa_ads_scheduler_ops_t scheduler_ops = {
-    .init = frsh_callback_init,
-    .new_thread = frsh_callback_new_thread,
-    .thread_terminate = frsh_callback_thread_terminate,
-    .thread_ready = frsh_callback_thread_ready,
-    .thread_block = frsh_callback_thread_block,
-    .change_sched_param_thread = frsh_callback_change_sched_param_thread,
-    .explicit_call_with_data = frsh_callback_explicit_call_with_data,
-    .notification_for_thread = frsh_callback_notification_for_thread,
-    .timeout = frsh_callback_timeout,
-    .signal = frsh_callback_signal,
-    .appsched_error = frsh_callback_appsched_error,
+    .init = fosa_callback_init,
+    .new_thread = fosa_callback_new_thread,
+    .thread_terminate = fosa_callback_thread_terminate,
+    .thread_ready = fosa_callback_thread_ready,
+    .thread_block = fosa_callback_thread_block,
+    .change_sched_param_thread = fosa_callback_change_sched_param_thread,
+    .explicit_call_with_data = fosa_callback_explicit_call_with_data,
+    .notification_for_thread = fosa_callback_notification_for_thread,
+    .timeout = fosa_callback_timeout,
+    .signal = fosa_callback_signal,
+    .appsched_error = fosa_callback_appsched_error,
 };
 
-static frsh_mutex_t lock;
+static fosa_mutex_t lock;
 
 const unsigned int MX_INIT_ARGS_STRING = 30;
 const unsigned int MX_PRIO = 20;
@@ -173,7 +171,7 @@ const unsigned int MX_PRIO = 20;
 typedef struct {
     fosa_ads_urgency_t array_prio[MX_THREADS];
     int array_status[MX_THREADS];
-} frsh_sched_data_t;
+} fosa_sched_data_t;
 
 typedef struct {
     fosa_ads_urgency_t prio;
@@ -186,7 +184,7 @@ typedef enum {
 } command_t;
 
 typedef struct {
-    frsh_thread_id_t thread_id;
+    fosa_thread_id_t thread_id;
     command_t command;
 } signal_action_t;
 
@@ -198,16 +196,15 @@ int main () {
 
     int err;
     char init_args_string[MX_INIT_ARGS_STRING + 1];
-    frsh_thread_id_t tid1, tid2, tid3;
-    frsh_thread_attr_t th_attr;
+    fosa_thread_id_t tid1, tid2, tid3;
+    fosa_thread_attr_t th_attr;
     bool is_appsched;
     appsched_params_t params;
-    frsh_signal_info_t timer_info;
+    fosa_signal_info_t timer_info;
     fosa_timer_id_t timerid;
     struct timespec timerval;
     signal_action_t signal_action;
 
-    adjust(); // for function eat
 
     err = fosa_thread_set_prio (fosa_thread_self(), MX_PRIO + 1);
     printf("set main to highest priority, err=%d\n", err);
@@ -229,7 +226,7 @@ int main () {
 
     err = fosa_ads_scheduler_create
             (&scheduler_ops,
-             sizeof(frsh_sched_data_t),
+             sizeof(fosa_sched_data_t),
              init_args_string, // INIT IS CALLED INMEDIATELY??!!!
              strlen(init_args_string) + 1);
     printf("scheduler created, err=%d\n", err);
@@ -242,11 +239,11 @@ int main () {
     printf("--------------------------------------------------\n");
     printf("2b) Create two application scheduled threads\n");
 
-    err = frsh_thread_attr_init(&th_attr);
+    err = fosa_thread_attr_init(&th_attr);
     printf("thread attributes object initialized, err=%d\n", err);
     assert(err == 0);
 
-    err = frsh_thread_attr_set_stacksize(&th_attr,40000);
+    err = fosa_thread_attr_set_stacksize(&th_attr,40000);
     printf("thread attr set stack size to 40000, err=%d\n", err);
     assert(err == 0);
 
@@ -289,7 +286,7 @@ int main () {
     printf("created thread 3 (rejected=%d), err=%d\n",
             (err == FOSA_EREJECT), err);
 
-    err = frsh_thread_attr_destroy(&th_attr);
+    err = fosa_thread_attr_destroy(&th_attr);
     printf("thread attributes object destroyed, err=%d\n",err);
     assert(err == 0);
 
@@ -393,6 +390,7 @@ static void *thread_code (void * arg)
     char whoami[] = "who am i?";
     int reply;
     size_t reply_size;
+    struct timespec one_second = {1, 0};
 
     printf("THREAD %d - starts\n", (int)arg);
     for (i=1;i<50;i++) {
@@ -402,7 +400,7 @@ static void *thread_code (void * arg)
         err=fosa_mutex_lock(&lock);
         assert(err == 0);
 
-        eat (1.0);
+        fosa_eat (&one_second);
 
         printf("THREAD %d - unlocking mutex\n", (int)arg);
         err=fosa_mutex_unlock(&lock);
@@ -425,12 +423,12 @@ static void *thread_code (void * arg)
 ///////////////////////////////////////////////////////
 // 4) Implementation of Application Defined Callbacks
 ///////////////////////////////////////////////////////
-static void frsh_callback_init
+static void fosa_callback_init
         (void *sched_data, void *arg)
 {
-    frsh_sched_data_t *frsh = (frsh_sched_data_t *)sched_data;
+    fosa_sched_data_t *frsh = (fosa_sched_data_t *)sched_data;
     int i, err;
-    frsh_signal_t sched_signal = FOSA_SIGNAL_MAX; // HOW TO PUT SIGNALS IF IS OPAQUE??
+    fosa_signal_t sched_signal = FOSA_SIGNAL_MAX; // HOW TO PUT SIGNALS IF IS OPAQUE??
 
     printf ("BEGIN CALLBACK: %s \n", __func__);
     printf ("init args string received: %s \n", (char *)arg);
@@ -446,15 +444,15 @@ static void frsh_callback_init
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_new_thread
+static void fosa_callback_new_thread
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          fosa_ads_actions_t *actions,
          struct timespec *current_time)
 {
     int err;
     unsigned int i, index;
-    frsh_sched_data_t *frsh = (frsh_sched_data_t *)sched_data;
+    fosa_sched_data_t *frsh = (fosa_sched_data_t *)sched_data;
     appsched_params_t params;
     size_t size;
 
@@ -483,9 +481,9 @@ static void frsh_callback_new_thread
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_thread_terminate
+static void fosa_callback_thread_terminate
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          fosa_ads_actions_t *actions,
          struct timespec *current_time)
 {
@@ -504,9 +502,9 @@ static void frsh_callback_thread_terminate
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_thread_ready
+static void fosa_callback_thread_ready
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          fosa_ads_actions_t *actions,
          struct timespec *current_time)
 {
@@ -514,9 +512,9 @@ static void frsh_callback_thread_ready
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_thread_block
+static void fosa_callback_thread_block
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          fosa_ads_actions_t *actions,
          struct timespec *current_time)
 {
@@ -535,9 +533,9 @@ static void frsh_callback_thread_block
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_change_sched_param_thread
+static void fosa_callback_change_sched_param_thread
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          fosa_ads_actions_t *actions,
          struct timespec *current_time)
 {
@@ -546,9 +544,9 @@ static void frsh_callback_change_sched_param_thread
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_explicit_call_with_data
+static void fosa_callback_explicit_call_with_data
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          const void * msg,
          size_t msg_size,
          void *reply,
@@ -563,9 +561,9 @@ static void frsh_callback_explicit_call_with_data
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_notification_for_thread
+static void fosa_callback_notification_for_thread
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          fosa_clock_id_t clock,
          fosa_ads_actions_t *actions,
          struct timespec *current_time)
@@ -574,7 +572,7 @@ static void frsh_callback_notification_for_thread
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_timeout // WHY NOT WATCHDOG????
+static void fosa_callback_timeout // WHY NOT WATCHDOG????
         (void *sched_data,
          fosa_ads_actions_t *actions,
          struct timespec *current_time) // WHY IS IN OUT and not IN???
@@ -585,16 +583,16 @@ static void frsh_callback_timeout // WHY NOT WATCHDOG????
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_signal
+static void fosa_callback_signal
         (void *sched_data,
-         frsh_signal_t signal,
-         frsh_signal_info_t siginfo, // HOW DO I KNOW THE ORIGIN (see signal_info type)
+         fosa_signal_t signal,
+         fosa_signal_info_t siginfo, // HOW DO I KNOW THE ORIGIN (see signal_info type)
          fosa_ads_actions_t *actions,
          struct timespec *current_time)
 {
     int err;
     signal_action_t *signal_action = (signal_action_t *)siginfo.sival_ptr;
-    frsh_sched_data_t *frsh = (frsh_sched_data_t *)sched_data;
+    fosa_sched_data_t *frsh = (fosa_sched_data_t *)sched_data;
 
     printf ("BEGIN CALLBACK: %s \n", __func__);
 
@@ -613,15 +611,16 @@ static void frsh_callback_signal
         case CAUSE_ERROR:
             // cause an error by overwriting actions with 666 ;D
             *(int *)actions = 666;
+            err = 666;
             printf("causing an error, err=%d\n", err);
             break;
     }
     printf ("END CALLBACK: %s \n", __func__);
 }
 
-static void frsh_callback_appsched_error
+static void fosa_callback_appsched_error
         (void *sched_data,
-         frsh_thread_id_t thread,
+         fosa_thread_id_t thread,
          fosa_ads_error_cause_t cause,
          fosa_ads_actions_t *actions)
 {
diff --git a/src_marte/tests/test_fosa_general/Makefile b/src_marte/tests/test_fosa_general/Makefile
new file mode 100644 (file)
index 0000000..0884262
--- /dev/null
@@ -0,0 +1,4 @@
+include ../../../config.mk
+include ../../../rules.mk
+
+
index 8ee17ee89ad8c3197b52e7fb0e9119e076aedfd3..6851a48b7a0d8f5182668aa8cf0344ba65061144 100644 (file)
@@ -104,19 +104,19 @@ int main () {
 
   int stsize, prio;
 
-  frsh_thread_id_t tid1=fosa_thread_self();
-  frsh_thread_id_t tid2=fosa_thread_self();
+  fosa_thread_id_t tid1=fosa_thread_self();
+  fosa_thread_id_t tid2=fosa_thread_self();
   printf("equal thread comparison=%d\n",fosa_thread_equal(tid1,tid2));
 
-  frsh_thread_attr_t th_attr;
+  fosa_thread_attr_t th_attr;
 
-  err=frsh_thread_attr_init(&th_attr);
+  err=fosa_thread_attr_init(&th_attr);
   printf("thread attributes object initialized, err=%d\n",err);
 
-  err=frsh_thread_attr_set_stacksize(&th_attr,40000);
+  err=fosa_thread_attr_set_stacksize(&th_attr,40000);
   printf("thread attr set stack size to 40000, err=%d\n",err);
 
-  err=frsh_thread_attr_get_stacksize(&th_attr,&stsize);
+  err=fosa_thread_attr_get_stacksize(&th_attr,&stsize);
   printf("thread attr get stack size=%d, err=%d\n",stsize,err);
 
   err=fosa_thread_attr_set_prio(&th_attr,27);
@@ -130,7 +130,7 @@ int main () {
 
   sleep(2);
 
-  err=frsh_thread_attr_destroy(&th_attr);
+  err=fosa_thread_attr_destroy(&th_attr);
   printf("thread attributes object destroyed, err=%d\n",err);
 
   //////////////////////////////////
@@ -140,12 +140,12 @@ int main () {
   printf("--------------------------------------------------\n");
   printf("test signals\n");
 
-  frsh_signal_t received;
-  frsh_signal_info_t sigvalue,  value_received;
+  fosa_signal_t received;
+  fosa_signal_info_t sigvalue,  value_received;
   struct timespec timeout;
-  frsh_signal_t sig=FOSA_SIGNAL_MIN+1;
-  frsh_signal_t timer_sig=FOSA_SIGNAL_MIN+3;
-  frsh_signal_t siglist[2];
+  fosa_signal_t sig=FOSA_SIGNAL_MIN+1;
+  fosa_signal_t timer_sig=FOSA_SIGNAL_MIN+3;
+  fosa_signal_t siglist[2];
 
   siglist[0]=sig;
   siglist[1]=timer_sig;
@@ -175,7 +175,7 @@ int main () {
   printf("--------------------------------------------------\n");
   printf("test timers and signals\n");
 
-  frsh_signal_info_t timer_info;
+  fosa_signal_info_t timer_info;
   fosa_timer_id_t timerid;
   struct timespec timerval, remaining_time;
 
@@ -240,7 +240,7 @@ int main () {
 
   int value=333;
   int key;
-  frsh_thread_id_t tid=fosa_thread_self();
+  fosa_thread_id_t tid=fosa_thread_self();
 
   err=fosa_key_create(&key);
   printf("key created=%d. err=%d\n",key,err);
@@ -274,7 +274,7 @@ int main () {
   printf("--------------------------------------------------\n");
   printf("test mutexes\n");
 
-  frsh_mutex_t lock;
+  fosa_mutex_t lock;
   int old;
 
   err=fosa_mutex_init(&lock,24);
@@ -344,10 +344,10 @@ int main () {
   printf("--------------------------------------------------\n");
   printf("test application-defined scheduling\n");
 
-  frsh_thread_attr_t th1_attr;
+  fosa_thread_attr_t th1_attr;
   bool is_appsched;
 
-  err=frsh_thread_attr_init(&th1_attr);
+  err=fosa_thread_attr_init(&th1_attr);
   printf("thread attributes object initialized, err=%d\n",err);
 
   err=fosa_thread_attr_set_appscheduled(&th1_attr,true);
index da7fd9d0557afe42984c1c371534cb1f37d90a9e..5704ca8360e0db81bdc0e53f440aa2501b95737f 100644 (file)
@@ -1,17 +1,13 @@
 include ../../../config.mk
 include ../../../rules.mk
 
-LDFLAGS += frsh_error.o $(FOSA_PATH)/marte_non_local_jump/non_local_jump.o
+LDFLAGS += $(FOSA_PATH)/marte_non_local_jump/non_local_jump.o
 
-CFLAGS += -I$(FRSH_PATH)/src_ads  # Quick hack for frsh_error
+testbench_long_jump.exe:  testbench_long_jump.c libfosa
 
-frsh_error.o:  frsh_error.c
+test_fosa_long_jump.exe:  test_fosa_long_jump.c libfosa
 
-testbench_long_jump.exe:  testbench_long_jump.c frsh_error.o libfosa
-
-test_fosa_long_jump.exe:  test_fosa_long_jump.c frsh_error.o libfosa
-
-fosa_long_jump_calibrate.exe:  fosa_long_jump_calibrate.c frsh_error.o libfosa
+fosa_long_jump_calibrate.exe:  fosa_long_jump_calibrate.c libfosa
 
 
 
diff --git a/src_marte/tests/test_non_local_jump/frsh_error.c b/src_marte/tests/test_non_local_jump/frsh_error.c
deleted file mode 100644 (file)
index 1653ed3..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-//----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
-//
-//    Universidad de Cantabria,              SPAIN
-//    University of York,                    UK
-//    Scuola Superiore Sant'Anna,            ITALY
-//    Kaiserslautern University,             GERMANY
-//    Univ. Politecnica  Valencia,           SPAIN
-//    Czech Technical University in Prague,  CZECH REPUBLIC
-//    ENEA                                   SWEDEN
-//    Thales Communication S.A.              FRANCE
-//    Visual Tools S.A.                      SPAIN
-//    Rapita Systems Ltd                     UK
-//    Evidence                               ITALY
-//
-//    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.
-//
-//
-//  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
-//
-// This file is part of FRSH (FRescor ScHeduler)
-//
-// 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.
-//
-// 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(FRescor ScHeduler), pronounced "fresh"
-//==============================================
-
-#include <stdio.h>
-#include <string.h>
-
-#include "frsh.h"
-#include "frsh_internal.h"
-
-
-////////////////////////////////////////////////////////////////////////
-//           ERROR REPORTING
-////////////////////////////////////////////////////////////////////////
-
-/* Use to debug an error condition */
-/***********************************/
-int global_error_condition = 0;
-
-
-
-/* These variables get initialised in frsh_init() */
-/**************************************************/
-struct timespec frsh_trace_init_timespec = {-1, -1};
-long frsh_trace_init_timemsec = -1;
-
-
-//error codes to message section
-static const int frsh_strerror_table_size = FRSH_ERR_LAST_VALUE-FRSH_ERR_BASE_VALUE;
-static char * frsh_strerror_table[] = 
-{
-    "TOO_MANY_TASKS                 ",
-    "BAD_ARGUMENT                   ",
-    "INVALID_SYNCH_OBJ_HANDLE       ",
-    "NO_RENEGOTIATION_REQUESTED     ",
-    "CONTRACT_REJECTED              ",
-    "NOT_SCHEDULED_CALLING_THREAD   ",
-    "NOT_BOUND_THREAD               ",
-    "UNKNOWN_SCHEDULED_THREAD       ",
-    "NOT_CONTRACTED_SERVER          ",
-    "NOT_SCHEDULED_THREAD           ",
-    "TOO_MANY_SERVICE_JOBS          ",
-    "TOO_MANY_SYNCH_OBJS            ",
-    "TOO_MANY_SERVERS_IN_SYNCH_OBJ  ",
-    "TOO_MANY_EVENTS_IN_SYNCH_OBJ   ",
-    "INTERNAL_ERROR                 ",
-    "TOO_MANY_SERVERS               ",
-    "INVALID_SCHEDULER_REPLY        ",
-    "TOO_MANY_PENDING_REPLENISHMENTS",
-    "SYSTEM_ALREADY_INITIALIZED     ",
-    "SHARED_OBJ_ALREADY_INITIALIZED ",
-    "SHARED_OBJ_NOT_INITIALIZED     ",
-    "SCHED_POLICY_NOT_COMPATIBLE    ",
-    "SERVER_WORKLOAD_NOT_COMPATIBLE ",
-    "ALREADY_BOUND                  ",
-    "WRONG_NETWORK                  ",
-    "TOO_LARGE                      ",
-    "BUFFER_FULL                    ",
-    "NO_SPACE                       ",
-    "NO_MESSAGES                    ",
-    "MODULE_NOT_SUPPORTED           ",
-    "SYSTEM_NOT_INITIALIZED         ",
-    "TOO_MANY_SHARED_OBJS           ",
-    "CONTRACT_LABEL_ALREADY_EXISTS  ",
-    "BUDGET_EXPIRED                 ",
-    "SHARED_OBJECT_NOT_PROTECTED    ",
-    "NOT_IMPLEMENTED                ",
-    "CONTRACT_TYPE_NOT_COMPATIBLE   ",
-    "CAPACITY_NOT_DECREASING        ",
-    "CONTRACT_LABEL_UNKNOWN         "
-};
-
-
-
-/**
- *  frsh_strerror()
- *
- *  This function converts an error code to an error message that is
- *  stored in the buffer starting at the location pointed to by
- *  message. The size of this buffer is specified by the size
- *  argument. If the error message is longer than size-1, it is
- *  truncated to that length. Regardless of whether the message is
- *  truncated or not, a final zero character that marks the end of the
- *  string is stored in the buffer.  The function fails if the error
- *  code passed does not correspond to any of the frsh error codes.
- *   [@return:
- *    FRSH_ERR_BAD_ARGUMENT :  error is not a valid value
- *   ]
- **/
-int frsh_strerror (int error, char *message, size_t size)
-{
-    char *s;
-//printf("debug: error=%x, LAST=%x, BASE=%x\n", error, FRSH_ERR_LAST_VALUE, FRSH_ERR_BASE_VALUE);
-    if ((error > FRSH_ERR_LAST_VALUE) ||
-        (error <= FRSH_ERR_BASE_VALUE))
-        return FRSH_ERR_BAD_ARGUMENT;
-  
-    s = frsh_strerror_table[error - FRSH_ERR_BASE_VALUE -1];
-    if ( message != NULL && size > 0) {
-        strncpy(message, s, size);
-        message[size-1] = '\0';
-    }
-    return 0;
-}
-
-/* ------------------------------------------------------------------------------------ */
-void my_frsh_strerror(int error, char *sss)
-{
-    char       s[32];
-    frsh_strerror(error, s, 32);
-    printf("(%x ", error);
-    printf(s);
-    printf(") ");
-    printf(sss);
-}
index 9acb841967b20f55a7e103eb27e8340f2ad4ab3b..525b213f576b1fd832b866753a9976ce33a6fb2b 100644 (file)
 //#include <signal.h>
 //#include <frsh.h>
 
-#include <frsh_fosa.h>
-#include <fosa_threads_and_signals.h>
-#include <fosa_clocks_and_timers.h>
-
-
+#include "fosa.h"
 #include "timespec_operations.h"
 
 #include "marte_non_local_jmp.h"
@@ -83,7 +79,7 @@
 #define RT_ERROR_TIMER   -3
 
 typedef struct {
-  frsh_thread_id_t tid;
+  fosa_thread_id_t tid;
   marte_nonlocaljmp_context_t *context_ptr;
   int dummy;
 } budget_timer_info_t;
@@ -111,10 +107,10 @@ static void * signal_handler_thread (void * arg);
 
 int main()
 {
-    frsh_signal_t set[1];
-    frsh_thread_attr_t attr;
+    fosa_signal_t set[1];
+    fosa_thread_attr_t attr;
 
-    frsh_thread_id_t tid1, tid2;
+    fosa_thread_id_t tid1, tid2;
     int terror = 0;
 
     // set signal mask
@@ -125,7 +121,7 @@ int main()
     }
 
     // Create the thread attributes object
-    if (frsh_thread_attr_init (&attr) != 0) {
+    if (fosa_thread_attr_init (&attr) != 0) {
       printf("Error while initializing the attributes\n");
       exit(1);
     }
@@ -171,11 +167,11 @@ void work() {
   printf("start regular code %d\n",i); 
   // regular code 
   // eat one second of budget 
-  frsh_eat(&exec_time); 
+  fosa_eat(&exec_time); 
   // every five cycles eat an additional one second of budget */
   if (i%5==0) { 
     printf("aqui\n");
-    frsh_eat(&exec_time); 
+    fosa_eat(&exec_time); 
     printf("aqui tambien\n");
   } 
 }
@@ -193,7 +189,7 @@ static void * thread_body(void *thread_arg)
     fosa_timer_id_t timerid;
     fosa_clock_id_t clockid;
     budget_timer_info_t timerinfo;
-    frsh_signal_info_t siginfo;
+    fosa_signal_info_t siginfo;
     int i=0;
 
     timerinfo.tid=pthread_self();
@@ -266,9 +262,9 @@ static void * thread_body(void *thread_arg)
 
 void * signal_handler_thread (void * arg) {
 
-  frsh_signal_t set[1];
-  frsh_signal_t sig;
-  frsh_signal_info_t siginfo;
+  fosa_signal_t set[1];
+  fosa_signal_t sig;
+  fosa_signal_info_t siginfo;
 
   budget_timer_info_t *info;
 
index e7a7fd8fa4ea704da2a8782bfa16738a4f0d4e17..8848b61717136bcc66f9bb7c9717f679e9ae4d28 100644 (file)
 #include <unistd.h>
 #include <time.h> // For clock_nanosleep
 
-#include "frsh_error.h"
 #include "fosa.h"
-#include "frsh_fosa.h"
 #include "timespec_operations.h"
 
+#include <misc/error_checks.h>
+
+
+
 /*************************/
 /* D E F I N I T I O N S */
 /*************************/
@@ -39,10 +41,9 @@ static void work_under_a_interruptible_budget();
 
 int main()
 {
-    int terror = -1;
-    frsh_thread_attr_t periodic_attr;
-    frsh_signal_t signal_set[1];
-    frsh_thread_id_t periodic_tid;
+    fosa_thread_attr_t periodic_attr;
+    fosa_signal_t signal_set[1];
+    fosa_thread_id_t periodic_tid;
 
     memset(&context, 0, sizeof(context) );
 
@@ -53,12 +54,13 @@ int main()
 
     /* We set the signal mask */
     signal_set[0] = FOSA_LONG_JUMP_SIGNAL;
-    PRW(  fosa_set_accepted_signals(signal_set, 1) );
+
+    CHK(  fosa_set_accepted_signals(signal_set, 1) );
 
     /* We create a new thread with a given priority */
-    PRW(  frsh_thread_attr_init(&periodic_attr) );
-    PRW(  fosa_thread_attr_set_prio(&periodic_attr, PERIODIC_THREAD_PRIORITY)  );
-    PRW(  fosa_thread_create(&periodic_tid, &periodic_attr, periodic_code, NULL) );
+    CHK(  fosa_thread_attr_init(&periodic_attr) );
+    CHK(  fosa_thread_attr_set_prio(&periodic_attr, PERIODIC_THREAD_PRIORITY)  );
+    CHK(  fosa_thread_create(&periodic_tid, &periodic_attr, periodic_code, NULL) );
 
     printf("Main goes to sleep...\n");
 
@@ -72,13 +74,11 @@ int main()
 
 static void *periodic_code(void *thread_arg)
 {
-    int terror = -1;
-
     struct timespec period = {2, 500000000};  // 2.5 secs
-    frsh_thread_id_t jump_handler_thread;
+    fosa_thread_id_t jump_handler_thread;
 
-    frsh_signal_t jump_signal;
-    frsh_signal_info_t jump_signal_info;
+    fosa_signal_t jump_signal;
+    fosa_signal_info_t jump_signal_info;
 
     fosa_clock_id_t clock_id;
     fosa_timer_id_t jump_timer;
@@ -94,7 +94,7 @@ static void *periodic_code(void *thread_arg)
     /* - This creates the thread that will wait for */
     /*   FOSA_JUMP_SIGNAL                           */
     /************************************************/
-    PXW(  fosa_long_jump_install_handler(&jump_signal, &jump_handler_thread) );
+    CHK(  fosa_long_jump_install_handler(&jump_signal, &jump_handler_thread) );
     
     /* We create a budget timer using the thread's CPU clock */
     /*                                                       */
@@ -104,9 +104,9 @@ static void *periodic_code(void *thread_arg)
     /*                                                       */
     /* This signal is delivered to the handler thread.       */
     /*********************************************************/
-    PXW(  fosa_thread_get_cputime_clock( fosa_thread_self(), &clock_id) );
+    CHK(  fosa_thread_get_cputime_clock( fosa_thread_self(), &clock_id) );
     jump_signal_info.sival_ptr = &context;
-    PXW(  fosa_timer_create_with_receiver(clock_id, jump_signal, jump_signal_info, 
+    CHK(  fosa_timer_create_with_receiver(clock_id, jump_signal, jump_signal_info, 
                                           &jump_timer, jump_handler_thread)  );
 
     
@@ -124,7 +124,7 @@ static void *periodic_code(void *thread_arg)
         jumped = 0;
 
         /* For statistical purposes we read the activation time */
-        PXW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &activation_time) );
+        CHK(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &activation_time) );
 
 
 
@@ -132,18 +132,18 @@ static void *periodic_code(void *thread_arg)
         /************************************/
 
         /* We arm the jump_timer */
-        PXW(  fosa_timer_arm(jump_timer, false, &budget) );
+        CHK(  fosa_timer_arm(jump_timer, false, &budget) );
 
         /* This is the point where the jump returns */
-        PXW(  fosa_long_jump_save_context(&context) );
+        CHK(  fosa_long_jump_save_context(&context) );
 
         /* Query if we come from a jump */
-        PXW(  fosa_long_jump_was_performed(&context, &jumped) );
+        CHK(  fosa_long_jump_was_performed(&context, &jumped) );
         if (!jumped)
         {
             /* HERE COMES THE WORK THAT CAN BE INTERRUPTED */
             work_under_a_interruptible_budget();
-            PRW(  fosa_timer_disarm(&jump_timer, NULL) );
+            CHK(  fosa_timer_disarm(jump_timer, NULL) );
             printf("NOT JUMPPED\n");
         }
         else
@@ -159,7 +159,7 @@ static void *periodic_code(void *thread_arg)
         
         /* Now we measure the time duration of the block */
         /*************************************************/
-        PXW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &old_activation_time)  );
+        CHK(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &old_activation_time)  );
         decr_timespec(&old_activation_time, &activation_time);
         printf("Execution time: %6.3f\n", t2d(old_activation_time) );
     
@@ -183,17 +183,17 @@ static void work_under_a_interruptible_budget()
     i++;
     printf("Start regular work\n");
 
-    frsh_eat(&exec_time);
+    fosa_eat(&exec_time);
 
     /* Once in every 5 executions we work over the budget */
     if (i % 5 == 0)
     {
-        frsh_eat(&exec_time);
-        frsh_eat(&exec_time);
-        frsh_eat(&exec_time);
-        frsh_eat(&exec_time);
-        frsh_eat(&exec_time);
-        frsh_eat(&exec_time);
+        fosa_eat(&exec_time);
+        fosa_eat(&exec_time);
+        fosa_eat(&exec_time);
+        fosa_eat(&exec_time);
+        fosa_eat(&exec_time);
+        fosa_eat(&exec_time);
     }
 
     printf("End regular work\n");
index 302ea8fa82884e1657126301823df13493e0e5e2..4fef93453dff972c0dbfa00120006050007ead68 100644 (file)
 #include <unistd.h>
 #include <time.h> // For clock_nanosleep
 
-#include "frsh_error.h"
 #include "fosa.h"
-#include "frsh_fosa.h"
 #include "timespec_operations.h"
 
+#include <misc/error_checks.h>
 
 
 /*************************/
@@ -66,10 +65,9 @@ struct timespec before_jump_timestamp = {-1, -1};
 
 int main()
 {
-    int terror = -1;
-    frsh_thread_attr_t periodic_attr;
-    frsh_signal_t signal_set[1];
-    frsh_thread_id_t periodic_tid;
+    fosa_thread_attr_t periodic_attr;
+    fosa_signal_t signal_set[1];
+    fosa_thread_id_t periodic_tid;
     results_t results;
 
     memset(&context, 0, sizeof(context) );
@@ -81,14 +79,14 @@ int main()
 
     /* We set the signal mask */
     signal_set[0] = FOSA_LONG_JUMP_SIGNAL;
-    PRW(  fosa_set_accepted_signals(signal_set, 1) );
+    CHK(  fosa_set_accepted_signals(signal_set, 1) );
 
     /* We create a new thread with a given priority */
-    PRW(  fosa_thread_set_prio(fosa_thread_self(), MAIN_THREAD_PRIORITY) );
+    CHK(  fosa_thread_set_prio(fosa_thread_self(), MAIN_THREAD_PRIORITY) );
 
-    PRW(  frsh_thread_attr_init(&periodic_attr) );
-    PRW(  fosa_thread_attr_set_prio(&periodic_attr, PERIODIC_THREAD_PRIORITY)  );
-    PRW(  fosa_thread_create(&periodic_tid, &periodic_attr, periodic_code, &results) );
+    CHK(  fosa_thread_attr_init(&periodic_attr) );
+    CHK(  fosa_thread_attr_set_prio(&periodic_attr, PERIODIC_THREAD_PRIORITY)  );
+    CHK(  fosa_thread_create(&periodic_tid, &periodic_attr, periodic_code, &results) );
 
     printf("Main waits for the periodic code to finish...\n");
     pthread_join(periodic_tid, NULL);
@@ -110,13 +108,10 @@ int main()
 
 static void *periodic_code(void *thread_arg)
 {
-    int terror = -1;
+    fosa_thread_id_t jump_handler_thread;
 
-    struct timespec period = {2, 500000000};  // 2.5 secs
-    frsh_thread_id_t jump_handler_thread;
-
-    frsh_signal_t jump_signal;
-    frsh_signal_info_t jump_signal_info;
+    fosa_signal_t jump_signal;
+    fosa_signal_info_t jump_signal_info;
 
     fosa_clock_id_t clock_id;
     fosa_timer_id_t jump_timer;
@@ -138,7 +133,7 @@ static void *periodic_code(void *thread_arg)
     /* - This creates the thread that will wait for */
     /*   FOSA_JUMP_SIGNAL                           */
     /************************************************/
-    PXW(  fosa_long_jump_install_handler(&jump_signal, &jump_handler_thread) );
+    CHK(  fosa_long_jump_install_handler(&jump_signal, &jump_handler_thread) );
     
     /* We create a budget timer using the thread's CPU clock */
     /*                                                       */
@@ -148,9 +143,9 @@ static void *periodic_code(void *thread_arg)
     /*                                                       */
     /* This signal is delivered to the handler thread.       */
     /*********************************************************/
-    PXW(  fosa_thread_get_cputime_clock( fosa_thread_self(), &clock_id) );
+    CHK(  fosa_thread_get_cputime_clock( fosa_thread_self(), &clock_id) );
     jump_signal_info.sival_ptr = &context;
-    PXW(  fosa_timer_create_with_receiver(clock_id, jump_signal, jump_signal_info, 
+    CHK(  fosa_timer_create_with_receiver(clock_id, jump_signal, jump_signal_info, 
                                           &jump_timer, jump_handler_thread)  );
 
     results->number_of_jumps = 0;