]> rtime.felk.cvut.cz Git - frescor/fosa.git/blobdiff - include/fosa_clocks_and_timers.h
Time abstraction added to FOSA to replace timespec_operations
[frescor/fosa.git] / include / fosa_clocks_and_timers.h
index d21caac82ec01f2d4180edee96ad75fdcb44e1c1..0a544a0db8c70b7cfb375e3ee21e0470e53f7a30 100644 (file)
@@ -105,7 +105,7 @@ FOSA_CPP_BEGIN_DECLS
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_clock_get_time(fosa_clock_id_t clockid, struct timespec *current_time);
+int fosa_clock_get_time(fosa_clock_id_t clockid, fosa_abs_time_t *current_time);
 
 
 /**
@@ -208,21 +208,47 @@ int fosa_thread_get_cputime_clock(fosa_thread_id_t tid, fosa_clock_id_t *clockid
 int fosa_timer_delete(fosa_timer_id_t timerid);
 
 /**
- * fosa_timer_arm()
+ * fosa_rel_timer_arm()
  *
- * Arm a timer
+ * Arm a timer with a relative time interval
  *
  * The timer specified by timer is armed and starts counting time.
  *
- * If abstime is true, the value pointed to by value is the absolute
- * time at which the timer will expire. If value specifies a time instant
- * in the past, the timer expires immediately.
+ * The value pointed to by value is the relative interval that must
+ * elapse for the timer to expire.  Negative values cause the timer to
+ * expire immediately.
  *
- * If abstime is false, the value pointed to by value is the relative interval
- * that must elapse for the timer to expire.
+ * The time is measured with the clock associated with the timer when
+ * it was created. 
  *
- * In both cases, absolute or relative, the time is measured with the clock
- * associated with the timer when it was created.
+ * If the timer was already armed, the previous time or interval is discarded
+ * and the timer is rearmed with the new value.
+ *
+ * When the timer expires, it is disarmed.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ *    FOSA_EINVAL: the value of timerid or value is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_rel_timer_arm
+      (fosa_timer_id_t timerid, const fosa_rel_time_t *value);
+
+/**
+ * fosa_abs_timer_arm()
+ *
+ * Arm a timer that will expire in an absolute time instant.
+ *
+ * The timer specified by timer is armed and starts counting time.
+ *
+ * The value pointed to by value is the absolute time at which the
+ * timer will expire. If value specifies a time instant in the past,
+ * the timer expires immediately. 
+ *
+ * The time is measured with the clock associated with the timer when
+ * it was created. 
  *
  * If the timer was already armed, the previous time or interval is discarded
  * and the timer is rearmed with the new value.
@@ -236,9 +262,11 @@ int fosa_timer_delete(fosa_timer_id_t timerid);
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_timer_arm
-      (fosa_timer_id_t timerid, bool abstime,
-       const struct timespec *value);
+int fosa_abs_timer_arm
+      (fosa_timer_id_t timerid, const fosa_abs_time_t *value);
+
+
+
 
 /**
  * fosa_timer_get_remaining_time()
@@ -259,7 +287,7 @@ int fosa_timer_arm
  * implementation and dependant applications
  **/
 int fosa_timer_get_remaining_time
-    (fosa_timer_id_t timerid, struct timespec *remaining_time);
+    (fosa_timer_id_t timerid, fosa_rel_time_t *remaining_time);
 
 /**
  * fosa_timer_disarm()
@@ -281,8 +309,8 @@ int fosa_timer_get_remaining_time
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_timer_disarm(fosa_timer_id_t timerid, struct timespec
-                           *remaining_time);
+int fosa_timer_disarm(fosa_timer_id_t timerid, 
+                      fosa_rel_time_t *remaining_time);
 
 
 /*@}*/