[Xenomai-git] Philippe Gerum : cobalt/rtdm: update API dealing with periodic tasks

2015-10-06 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 1c8a4e81df26498e2408828ada7b6139ccc19790
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1c8a4e81df26498e2408828ada7b6139ccc19790

Author: Philippe Gerum 
Date:   Fri Sep 25 17:57:46 2015 +0200

cobalt/rtdm: update API dealing with periodic tasks

rtdm_task_set_period() is updated to accept an initial date for
delimiting the time line.

rtdm_task_wait_period() now accepts a parameter to retrieve the count
of overruns upon -ETIMEDOUT error.

In addition, using the periodic task API from a Cobalt thread is
now allowed.

This enables more sophisticated periodic task processing, and closely
matches the inner xnthread* interface those calls are based on.

---

 include/cobalt/kernel/rtdm/driver.h  |9 +---
 kernel/cobalt/rtdm/drvlib.c  |   29 +-
 kernel/cobalt/thread.c   |8 +++
 kernel/drivers/autotune/autotune.c   |2 +-
 kernel/drivers/net/stack/rtcfg/rtcfg_timer.c |2 +-
 5 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 80308ca..541fb04 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -1033,12 +1033,15 @@ static inline void rtdm_task_set_priority(rtdm_task_t 
*task, int priority)
 }
 
 static inline int rtdm_task_set_period(rtdm_task_t *task,
+  nanosecs_abs_t start_date,
   nanosecs_rel_t period)
 {
if (period < 0)
period = 0;
+   if (start_date == 0)
+   start_date = XN_INFINITE;
 
-   return xnthread_set_periodic(task, XN_INFINITE, XN_RELATIVE, period);
+   return xnthread_set_periodic(task, start_date, XN_ABSOLUTE, period);
 }
 
 static inline int rtdm_task_unblock(rtdm_task_t *task)
@@ -1054,11 +1057,11 @@ static inline rtdm_task_t *rtdm_task_current(void)
return xnthread_current();
 }
 
-static inline int rtdm_task_wait_period(void)
+static inline int rtdm_task_wait_period(unsigned long *overruns_r)
 {
if (!XENO_ASSERT(COBALT, !xnsched_unblockable_p()))
return -EPERM;
-   return xnthread_wait_period(NULL);
+   return xnthread_wait_period(overruns_r);
 }
 
 static inline int rtdm_task_sleep(nanosecs_rel_t delay)
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index ca46531..7b3ab1a 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -200,17 +200,36 @@ void rtdm_task_set_priority(rtdm_task_t *task, int 
priority);
 /**
  * @brief Adjust real-time task period
  *
- * @param[in,out] task Task handle as returned by rtdm_task_init()
- * @param[in] period New period in nanoseconds of a cyclic task, 0 for
- * non-cyclic mode
+ * @param[in,out] task Task handle as returned by rtdm_task_init(), or
+ * NULL for referring to the current RTDM task or Cobalt thread (see
+ * note).
+ *
+ * @param[in] start_date The initial (absolute) date of the first
+ * release point, expressed in nanoseconds.  @a task will be delayed
+ * by the first call to rtdm_task_wait_period() until this point is
+ * reached. If @a start_date is zero, the first release point is set
+ * to @a period nanoseconds after the current date.
+
+ * @param[in] period New period in nanoseconds of a cyclic task, zero
+ * for non-cyclic mode.
  *
  * @coretags{task-unrestricted}
+ *
+ * @note Both RTDM tasks in kernel space and Cobalt threads in
+ * user-space are based on Xenomai core threads, which implement this
+ * service. For this reason, enabling periodic timing for a Cobalt
+ * thread via the RTDM interface is possible.
  */
-int rtdm_task_set_period(rtdm_task_t *task, nanosecs_rel_t period);
+int rtdm_task_set_period(rtdm_task_t *task, nanosecs_abs_t start_date,
+nanosecs_rel_t period);
 
 /**
  * @brief Wait on next real-time task period
  *
+ * @param[in] overrun_r Address of a long word receiving the count of
+ * overruns if -ETIMEDOUT is returned, or NULL if the caller don't
+ * need that information.
+ *
  * @return 0 on success, otherwise:
  *
  * - -EINVAL is returned if calling task is not in periodic mode.
@@ -220,7 +239,7 @@ int rtdm_task_set_period(rtdm_task_t *task, nanosecs_rel_t 
period);
  *
  * @coretags{primary-only, might-switch}
  */
-int rtdm_task_wait_period(void);
+int rtdm_task_wait_period(unsigned long *overruns_r);
 
 /**
  * @brief Activate a blocked real-time task
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 6a571af..508ed69 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1236,10 +1236,10 @@ EXPORT_SYMBOL_GPL(xnthread_unblock);
  * @param idate The initial (absolute) date of the first release
  * point, expressed in nanoseconds. The affected thread will be
  * delayed by the first call to xnthread_wait_period() until this
- * point is reached. If @a idate is equa

[Xenomai-git] Philippe Gerum : cobalt/rtdm: update API dealing with periodic tasks

2015-10-03 Thread git repository hosting
Module: xenomai-3
Branch: arm64
Commit: 1c8a4e81df26498e2408828ada7b6139ccc19790
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1c8a4e81df26498e2408828ada7b6139ccc19790

Author: Philippe Gerum 
Date:   Fri Sep 25 17:57:46 2015 +0200

cobalt/rtdm: update API dealing with periodic tasks

rtdm_task_set_period() is updated to accept an initial date for
delimiting the time line.

rtdm_task_wait_period() now accepts a parameter to retrieve the count
of overruns upon -ETIMEDOUT error.

In addition, using the periodic task API from a Cobalt thread is
now allowed.

This enables more sophisticated periodic task processing, and closely
matches the inner xnthread* interface those calls are based on.

---

 include/cobalt/kernel/rtdm/driver.h  |9 +---
 kernel/cobalt/rtdm/drvlib.c  |   29 +-
 kernel/cobalt/thread.c   |8 +++
 kernel/drivers/autotune/autotune.c   |2 +-
 kernel/drivers/net/stack/rtcfg/rtcfg_timer.c |2 +-
 5 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 80308ca..541fb04 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -1033,12 +1033,15 @@ static inline void rtdm_task_set_priority(rtdm_task_t 
*task, int priority)
 }
 
 static inline int rtdm_task_set_period(rtdm_task_t *task,
+  nanosecs_abs_t start_date,
   nanosecs_rel_t period)
 {
if (period < 0)
period = 0;
+   if (start_date == 0)
+   start_date = XN_INFINITE;
 
-   return xnthread_set_periodic(task, XN_INFINITE, XN_RELATIVE, period);
+   return xnthread_set_periodic(task, start_date, XN_ABSOLUTE, period);
 }
 
 static inline int rtdm_task_unblock(rtdm_task_t *task)
@@ -1054,11 +1057,11 @@ static inline rtdm_task_t *rtdm_task_current(void)
return xnthread_current();
 }
 
-static inline int rtdm_task_wait_period(void)
+static inline int rtdm_task_wait_period(unsigned long *overruns_r)
 {
if (!XENO_ASSERT(COBALT, !xnsched_unblockable_p()))
return -EPERM;
-   return xnthread_wait_period(NULL);
+   return xnthread_wait_period(overruns_r);
 }
 
 static inline int rtdm_task_sleep(nanosecs_rel_t delay)
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index ca46531..7b3ab1a 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -200,17 +200,36 @@ void rtdm_task_set_priority(rtdm_task_t *task, int 
priority);
 /**
  * @brief Adjust real-time task period
  *
- * @param[in,out] task Task handle as returned by rtdm_task_init()
- * @param[in] period New period in nanoseconds of a cyclic task, 0 for
- * non-cyclic mode
+ * @param[in,out] task Task handle as returned by rtdm_task_init(), or
+ * NULL for referring to the current RTDM task or Cobalt thread (see
+ * note).
+ *
+ * @param[in] start_date The initial (absolute) date of the first
+ * release point, expressed in nanoseconds.  @a task will be delayed
+ * by the first call to rtdm_task_wait_period() until this point is
+ * reached. If @a start_date is zero, the first release point is set
+ * to @a period nanoseconds after the current date.
+
+ * @param[in] period New period in nanoseconds of a cyclic task, zero
+ * for non-cyclic mode.
  *
  * @coretags{task-unrestricted}
+ *
+ * @note Both RTDM tasks in kernel space and Cobalt threads in
+ * user-space are based on Xenomai core threads, which implement this
+ * service. For this reason, enabling periodic timing for a Cobalt
+ * thread via the RTDM interface is possible.
  */
-int rtdm_task_set_period(rtdm_task_t *task, nanosecs_rel_t period);
+int rtdm_task_set_period(rtdm_task_t *task, nanosecs_abs_t start_date,
+nanosecs_rel_t period);
 
 /**
  * @brief Wait on next real-time task period
  *
+ * @param[in] overrun_r Address of a long word receiving the count of
+ * overruns if -ETIMEDOUT is returned, or NULL if the caller don't
+ * need that information.
+ *
  * @return 0 on success, otherwise:
  *
  * - -EINVAL is returned if calling task is not in periodic mode.
@@ -220,7 +239,7 @@ int rtdm_task_set_period(rtdm_task_t *task, nanosecs_rel_t 
period);
  *
  * @coretags{primary-only, might-switch}
  */
-int rtdm_task_wait_period(void);
+int rtdm_task_wait_period(unsigned long *overruns_r);
 
 /**
  * @brief Activate a blocked real-time task
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 6a571af..508ed69 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1236,10 +1236,10 @@ EXPORT_SYMBOL_GPL(xnthread_unblock);
  * @param idate The initial (absolute) date of the first release
  * point, expressed in nanoseconds. The affected thread will be
  * delayed by the first call to xnthread_wait_period() until this
- * point is reached. If @a idate is equal

[Xenomai-git] Philippe Gerum : cobalt/rtdm: update API dealing with periodic tasks

2015-09-30 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1c8a4e81df26498e2408828ada7b6139ccc19790
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1c8a4e81df26498e2408828ada7b6139ccc19790

Author: Philippe Gerum 
Date:   Fri Sep 25 17:57:46 2015 +0200

cobalt/rtdm: update API dealing with periodic tasks

rtdm_task_set_period() is updated to accept an initial date for
delimiting the time line.

rtdm_task_wait_period() now accepts a parameter to retrieve the count
of overruns upon -ETIMEDOUT error.

In addition, using the periodic task API from a Cobalt thread is
now allowed.

This enables more sophisticated periodic task processing, and closely
matches the inner xnthread* interface those calls are based on.

---

 include/cobalt/kernel/rtdm/driver.h  |9 +---
 kernel/cobalt/rtdm/drvlib.c  |   29 +-
 kernel/cobalt/thread.c   |8 +++
 kernel/drivers/autotune/autotune.c   |2 +-
 kernel/drivers/net/stack/rtcfg/rtcfg_timer.c |2 +-
 5 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 80308ca..541fb04 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -1033,12 +1033,15 @@ static inline void rtdm_task_set_priority(rtdm_task_t 
*task, int priority)
 }
 
 static inline int rtdm_task_set_period(rtdm_task_t *task,
+  nanosecs_abs_t start_date,
   nanosecs_rel_t period)
 {
if (period < 0)
period = 0;
+   if (start_date == 0)
+   start_date = XN_INFINITE;
 
-   return xnthread_set_periodic(task, XN_INFINITE, XN_RELATIVE, period);
+   return xnthread_set_periodic(task, start_date, XN_ABSOLUTE, period);
 }
 
 static inline int rtdm_task_unblock(rtdm_task_t *task)
@@ -1054,11 +1057,11 @@ static inline rtdm_task_t *rtdm_task_current(void)
return xnthread_current();
 }
 
-static inline int rtdm_task_wait_period(void)
+static inline int rtdm_task_wait_period(unsigned long *overruns_r)
 {
if (!XENO_ASSERT(COBALT, !xnsched_unblockable_p()))
return -EPERM;
-   return xnthread_wait_period(NULL);
+   return xnthread_wait_period(overruns_r);
 }
 
 static inline int rtdm_task_sleep(nanosecs_rel_t delay)
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index ca46531..7b3ab1a 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -200,17 +200,36 @@ void rtdm_task_set_priority(rtdm_task_t *task, int 
priority);
 /**
  * @brief Adjust real-time task period
  *
- * @param[in,out] task Task handle as returned by rtdm_task_init()
- * @param[in] period New period in nanoseconds of a cyclic task, 0 for
- * non-cyclic mode
+ * @param[in,out] task Task handle as returned by rtdm_task_init(), or
+ * NULL for referring to the current RTDM task or Cobalt thread (see
+ * note).
+ *
+ * @param[in] start_date The initial (absolute) date of the first
+ * release point, expressed in nanoseconds.  @a task will be delayed
+ * by the first call to rtdm_task_wait_period() until this point is
+ * reached. If @a start_date is zero, the first release point is set
+ * to @a period nanoseconds after the current date.
+
+ * @param[in] period New period in nanoseconds of a cyclic task, zero
+ * for non-cyclic mode.
  *
  * @coretags{task-unrestricted}
+ *
+ * @note Both RTDM tasks in kernel space and Cobalt threads in
+ * user-space are based on Xenomai core threads, which implement this
+ * service. For this reason, enabling periodic timing for a Cobalt
+ * thread via the RTDM interface is possible.
  */
-int rtdm_task_set_period(rtdm_task_t *task, nanosecs_rel_t period);
+int rtdm_task_set_period(rtdm_task_t *task, nanosecs_abs_t start_date,
+nanosecs_rel_t period);
 
 /**
  * @brief Wait on next real-time task period
  *
+ * @param[in] overrun_r Address of a long word receiving the count of
+ * overruns if -ETIMEDOUT is returned, or NULL if the caller don't
+ * need that information.
+ *
  * @return 0 on success, otherwise:
  *
  * - -EINVAL is returned if calling task is not in periodic mode.
@@ -220,7 +239,7 @@ int rtdm_task_set_period(rtdm_task_t *task, nanosecs_rel_t 
period);
  *
  * @coretags{primary-only, might-switch}
  */
-int rtdm_task_wait_period(void);
+int rtdm_task_wait_period(unsigned long *overruns_r);
 
 /**
  * @brief Activate a blocked real-time task
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 6a571af..508ed69 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1236,10 +1236,10 @@ EXPORT_SYMBOL_GPL(xnthread_unblock);
  * @param idate The initial (absolute) date of the first release
  * point, expressed in nanoseconds. The affected thread will be
  * delayed by the first call to xnthread_wait_period() until this
- * point is reached. If @a idate is equal