From: Jan Kiszka <kiszka@domain.hid>
To: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] [PATCH] fixes, clarifications, cleanups for RTDM
Date: Mon, 07 Nov 2005 17:29:35 +0100 [thread overview]
Message-ID: <436F80EF.5020302@domain.hid> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 477 bytes --]
Hi,
this patch
o fixes a cleanup-on-error problem with rtdm_task_init()
o moves this call into drvlib (i.e. de-inlines it)
o gets rid of __u64 and __s64 usages in favour of uint64_t and int64_t
(for consistent types in both kernel and user space)
o tries to improve the documentation of rtdm_device.device_name and
RTDM_EXECUTE_ATOMICALLY and
o moves EXPORT_SYMBOLs to their related functions
Tested, caused no regressions so far. Please apply.
Jan
[-- Attachment #1.2: rtdm_task_init_etc.patch --]
[-- Type: text/plain, Size: 11005 bytes --]
Index: skins/rtdm/drvlib.c
===================================================================
--- skins/rtdm/drvlib.c (revision 112)
+++ skins/rtdm/drvlib.c (working copy)
@@ -58,7 +58,7 @@
*
* Rescheduling: never.
*/
-__u64 rtdm_clock_read(void);
+uint64_t rtdm_clock_read(void);
#endif /* DOXYGEN_CPP */
/** @} */
@@ -69,7 +69,6 @@
* @{
*/
-#ifdef DOXYGEN_CPP /* Only used for doxygen doc generation */
/**
* @brief Intialise and start a real-time task
*
@@ -96,8 +95,40 @@
*/
int rtdm_task_init(rtdm_task_t *task, const char *name,
rtdm_task_proc_t task_proc, void *arg,
- int priority, __u64 period);
+ int priority, uint64_t period)
+{
+ int res;
+
+ res = xnpod_init_thread(task, name, priority, 0, 0);
+ if (res)
+ goto error_out;
+
+ if (period != XN_INFINITE) {
+ res = xnpod_set_thread_periodic(task, XN_INFINITE,
+ xnpod_ns2ticks(period));
+ if (res)
+ goto cleanup_out;
+ }
+
+ res = xnpod_start_thread(task, 0, 0, XNPOD_ALL_CPUS, task_proc, arg);
+ if (res)
+ goto cleanup_out;
+
+ return res;
+
+
+ cleanup_out:
+ xnpod_delete_thread(task);
+
+ error_out:
+ return res;
+}
+
+EXPORT_SYMBOL(rtdm_task_init);
+
+
+#ifdef DOXYGEN_CPP /* Only used for doxygen doc generation */
/**
* @brief Destroy a real-time task
*
@@ -153,7 +184,7 @@
*
* Rescheduling: possible.
*/
-int rtdm_task_set_period(rtdm_task_t *task, __u64 period);
+int rtdm_task_set_period(rtdm_task_t *task, uint64_t period);
/**
* @brief Wait on next real-time task period
@@ -246,7 +277,9 @@
xnlock_put_irqrestore(&nklock, s);
}
+EXPORT_SYMBOL(rtdm_task_join_nrt);
+
/**
* @brief Sleep a specified amount of time
*
@@ -266,7 +299,7 @@
*
* Rescheduling: always.
*/
-int rtdm_task_sleep(__u64 delay)
+int rtdm_task_sleep(uint64_t delay)
{
xnthread_t *thread = xnpod_current_thread();
@@ -276,7 +309,9 @@
return xnthread_test_flags(thread, XNBREAK) ? -EINTR : 0;
}
+EXPORT_SYMBOL(rtdm_task_sleep);
+
/**
* @brief Sleep until a specified absolute time
*
@@ -296,7 +331,7 @@
*
* Rescheduling: always, unless the specified time already passed.
*/
-int rtdm_task_sleep_until(__u64 wakeup_time)
+int rtdm_task_sleep_until(uint64_t wakeup_time)
{
xnthread_t *thread = xnpod_current_thread();
xnsticks_t delay;
@@ -320,7 +355,9 @@
return err;
}
+EXPORT_SYMBOL(rtdm_task_sleep_until);
+
/**
* @brief Busy-wait a specified amount of time
*
@@ -337,13 +374,15 @@
*
* Rescheduling: never.
*/
-void rtdm_task_busy_sleep(__u64 delay)
+void rtdm_task_busy_sleep(uint64_t delay)
{
xnticks_t wakeup = xnarch_get_cpu_tsc() + xnarch_ns_to_tsc(delay);
while (xnarch_get_cpu_tsc() < wakeup)
cpu_relax();
}
+
+EXPORT_SYMBOL(rtdm_task_busy_sleep);
/** @} */
@@ -368,8 +407,10 @@
xnlock_put_irqrestore(&nklock, s);
}
+EXPORT_SYMBOL(_rtdm_synch_flush);
+
/*!
* @ingroup driverapi
* @defgroup rtdmsync Synchronisation Services
@@ -431,7 +472,7 @@
*
* Rescheduling: never.
*/
-void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, __s64 timeout);
+void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, int64_t timeout);
#endif /* DOXYGEN_CPP */
/** @} */
@@ -552,7 +593,9 @@
xnlock_put_irqrestore(&nklock, s);
}
+EXPORT_SYMBOL(rtdm_event_signal);
+
/**
* @brief Wait on event occurrence
*
@@ -605,7 +648,9 @@
return err;
}
+EXPORT_SYMBOL(rtdm_event_wait);
+
/**
* @brief Wait on event occurrence with timeout
*
@@ -638,7 +683,7 @@
*
* Rescheduling: possible.
*/
-int rtdm_event_timedwait(rtdm_event_t *event, __s64 timeout,
+int rtdm_event_timedwait(rtdm_event_t *event, int64_t timeout,
rtdm_toseq_t *timeout_seq)
{
xnthread_t *thread;
@@ -687,6 +732,8 @@
return err;
}
+
+EXPORT_SYMBOL(rtdm_event_timedwait);
/** @} */
@@ -787,7 +834,9 @@
return err;
}
+EXPORT_SYMBOL(rtdm_sem_down);
+
/**
* @brief Decrement a semaphore with timeout
*
@@ -823,7 +872,7 @@
*
* Rescheduling: possible.
*/
-int rtdm_sem_timeddown(rtdm_sem_t *sem, __s64 timeout,
+int rtdm_sem_timeddown(rtdm_sem_t *sem, int64_t timeout,
rtdm_toseq_t *timeout_seq)
{
xnthread_t *thread;
@@ -871,7 +920,9 @@
return err;
}
+EXPORT_SYMBOL(rtdm_sem_timeddown);
+
/**
* @brief Increment a semaphore
*
@@ -905,6 +956,8 @@
xnlock_put_irqrestore(&nklock, s);
}
+
+EXPORT_SYMBOL(rtdm_sem_up);
/** @} */
@@ -1001,7 +1054,9 @@
return err;
}
+EXPORT_SYMBOL(rtdm_mutex_lock);
+
/**
* @brief Request a mutex with timeout
*
@@ -1036,7 +1091,7 @@
*
* Rescheduling: possible.
*/
-int rtdm_mutex_timedlock(rtdm_mutex_t *mutex, __s64 timeout,
+int rtdm_mutex_timedlock(rtdm_mutex_t *mutex, int64_t timeout,
rtdm_toseq_t *timeout_seq)
{
xnthread_t *thread;
@@ -1084,7 +1139,9 @@
return err;
}
+EXPORT_SYMBOL(rtdm_mutex_timedlock);
+
/**
* @brief Release a mutex
*
@@ -1115,6 +1172,8 @@
xnlock_put_irqrestore(&nklock, s);
}
+
+EXPORT_SYMBOL(rtdm_mutex_unlock);
/** @} */
/** @} Synchronisation services */
@@ -1520,19 +1579,3 @@
/** @} */
#endif /* DOXYGEN_CPP */
-
-
-EXPORT_SYMBOL(rtdm_task_join_nrt);
-EXPORT_SYMBOL(rtdm_task_sleep);
-EXPORT_SYMBOL(rtdm_task_sleep_until);
-EXPORT_SYMBOL(rtdm_task_busy_sleep);
-EXPORT_SYMBOL(_rtdm_synch_flush);
-EXPORT_SYMBOL(rtdm_event_wait);
-EXPORT_SYMBOL(rtdm_event_timedwait);
-EXPORT_SYMBOL(rtdm_event_signal);
-EXPORT_SYMBOL(rtdm_sem_down);
-EXPORT_SYMBOL(rtdm_sem_timeddown);
-EXPORT_SYMBOL(rtdm_sem_up);
-EXPORT_SYMBOL(rtdm_mutex_lock);
-EXPORT_SYMBOL(rtdm_mutex_timedlock);
-EXPORT_SYMBOL(rtdm_mutex_unlock);
Index: skins/rtdm/rtdm_driver.h
===================================================================
--- skins/rtdm/rtdm_driver.h (revision 112)
+++ skins/rtdm/rtdm_driver.h (working copy)
@@ -381,7 +381,7 @@
/** Size of driver defined appendix to struct rtdm_dev_context */
size_t context_size;
- /** Named device identification */
+ /** Named device identification (orthogonal to Linux device name space) */
char device_name[RTDM_MAX_DEVNAME_LEN+1];
/** Protocol device identification: protocol family (PF_xxx) */
@@ -477,7 +477,7 @@
/* --- clock services --- */
-static inline __u64 rtdm_clock_read(void)
+static inline uint64_t rtdm_clock_read(void)
{
return xnpod_ticks2ns(xnpod_get_time());
}
@@ -500,7 +500,7 @@
* Generally, it is illegal to suspend the current task by calling
* rtdm_task_sleep(), rtdm_event_wait(), etc. while holding a spinlock. In
* contrast, this macro allows to combine several operations including
- * potentially rescheduling calls to an atomic code block with respect to
+ * a potentially rescheduling call to an atomic code block with respect to
* other RTDM_EXECUTE_ATOMICALLY() blocks. The macro is a light-weight
* alternative for protecting code blocks via mutexes, and it can even be used
* to synchronise real-time and non-real-time contexts.
@@ -511,7 +511,9 @@
* @c break, @c return, @c goto, etc. This would leave the global lock held
* during the code block execution in an inconsistent state. Moreover, do not
* embed complex operations into the code bock. Consider that they will be
- * executed under preemption lock with interrupts switched-off.
+ * executed under preemption lock with interrupts switched-off. Also note that
+ * invocation of rescheduling calls may break the atomicity until the task
+ * gains the CPU again.
*
* Environments:
*
@@ -841,29 +843,10 @@
/** @} */
-static inline int rtdm_task_init(rtdm_task_t *task, const char *name,
- rtdm_task_proc_t task_proc, void *arg,
- int priority, __u64 period)
-{
- int res;
+int rtdm_task_init(rtdm_task_t *task, const char *name,
+ rtdm_task_proc_t task_proc, void *arg,
+ int priority, uint64_t period);
- res = xnpod_init_thread(task, name, priority, 0, 0);
- if (res)
- goto done;
-
- if (!__builtin_constant_p(period) || (period != XN_INFINITE)) {
- res = xnpod_set_thread_periodic(task, XN_INFINITE,
- xnpod_ns2ticks(period));
- if (res)
- goto done;
- }
-
- res = xnpod_start_thread(task, 0, 0, XNPOD_ALL_CPUS, task_proc, arg);
-
- done:
- return res;
-}
-
static inline void rtdm_task_destroy(rtdm_task_t *task)
{
xnpod_delete_thread(task);
@@ -877,7 +860,7 @@
xnpod_schedule();
}
-static inline int rtdm_task_set_period(rtdm_task_t *task, __u64 period)
+static inline int rtdm_task_set_period(rtdm_task_t *task, uint64_t period)
{
return xnpod_set_thread_periodic(task, XN_INFINITE,
xnpod_ns2ticks(period));
@@ -901,16 +884,16 @@
return xnpod_wait_thread_period();
}
-int rtdm_task_sleep(__u64 delay);
-int rtdm_task_sleep_until(__u64 wakeup_time);
-void rtdm_task_busy_sleep(__u64 delay);
+int rtdm_task_sleep(uint64_t delay);
+int rtdm_task_sleep_until(uint64_t wakeup_time);
+void rtdm_task_busy_sleep(uint64_t delay);
/* --- timeout sequences */
-typedef __u64 rtdm_toseq_t;
+typedef uint64_t rtdm_toseq_t;
-static inline void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, __s64 timeout)
+static inline void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, int64_t timeout)
{
*timeout_seq = xnpod_get_time() + xnpod_ns2ticks(timeout);
}
@@ -937,7 +920,7 @@
}
int rtdm_event_wait(rtdm_event_t *event);
-int rtdm_event_timedwait(rtdm_event_t *event, __s64 timeout,
+int rtdm_event_timedwait(rtdm_event_t *event, int64_t timeout,
rtdm_toseq_t *timeout_seq);
void rtdm_event_signal(rtdm_event_t *event);
@@ -971,7 +954,7 @@
}
int rtdm_sem_down(rtdm_sem_t *sem);
-int rtdm_sem_timeddown(rtdm_sem_t *sem, __s64 timeout,
+int rtdm_sem_timeddown(rtdm_sem_t *sem, int64_t timeout,
rtdm_toseq_t *timeout_seq);
void rtdm_sem_up(rtdm_sem_t *sem);
@@ -995,7 +978,7 @@
}
int rtdm_mutex_lock(rtdm_mutex_t *mutex);
-int rtdm_mutex_timedlock(rtdm_mutex_t *mutex, __s64 timeout,
+int rtdm_mutex_timedlock(rtdm_mutex_t *mutex, int64_t timeout,
rtdm_toseq_t *timeout_seq);
void rtdm_mutex_unlock(rtdm_mutex_t *mutex);
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
next reply other threads:[~2005-11-07 16:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-07 16:29 Jan Kiszka [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-11-07 16:29 [Xenomai-core] [PATCH] fixes, clarifications, cleanups for RTDM Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=436F80EF.5020302@domain.hid \
--to=kiszka@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.