* [Xenomai-help] Reading Memory Mapped IO
@ 2006-08-02 9:24 Doyle, Alan
2006-08-02 11:50 ` Jan Kiszka
2006-08-02 12:27 ` Gilles Chanteperdrix
0 siblings, 2 replies; 4+ messages in thread
From: Doyle, Alan @ 2006-08-02 9:24 UTC (permalink / raw)
To: xenomai
[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]
Hi,
I have an application where I need to read four contiguous memory mapped
data registers in response to an interrupt. As its real time critical I
intend to implement the read in Xenomai. Having read and processed the
data it later needs to be passed to a Linux domain application, I am
hoping to use a Posix message queue for this purpose.
I seem to have two options as to how to implement this, I could register
the interrupt in a Xenomai user space thread and mmap the data registers
so that on receiving the interrupt the registers could be read.
Alternatively I could write a Xenomai RTDM driver to read the registers
on interrupt and use the driver read call from the Xenomai user space
thread to access register data. In each case the data would then be
passed to the Linux domain via a message to a Posix queue - after some
further processing that is not real time critical.
Could you enlighten me as to the pros and cons of each approach, I am
particularly unclear as to the implications of using mmap in the Xenomai
domain and what if any affect it might have on the real time
responsiveness (I understand mmap() to be a call back into the Linux
kernel rather than to the Xenomai nucleus).
Thanks
Alan
[-- Attachment #2: Type: text/html, Size: 1826 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] Reading Memory Mapped IO
2006-08-02 9:24 [Xenomai-help] Reading Memory Mapped IO Doyle, Alan
@ 2006-08-02 11:50 ` Jan Kiszka
2006-08-02 12:14 ` Jan Kiszka
2006-08-02 12:27 ` Gilles Chanteperdrix
1 sibling, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2006-08-02 11:50 UTC (permalink / raw)
To: Doyle, Alan; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 2481 bytes --]
Doyle, Alan wrote:
> Hi,
>
> I have an application where I need to read four contiguous memory mapped
> data registers in response to an interrupt. As its real time critical I
> intend to implement the read in Xenomai. Having read and processed the
> data it later needs to be passed to a Linux domain application, I am
> hoping to use a Posix message queue for this purpose.
>
> I seem to have two options as to how to implement this, I could register
> the interrupt in a Xenomai user space thread and mmap the data registers
> so that on receiving the interrupt the registers could be read.
> Alternatively I could write a Xenomai RTDM driver to read the registers
> on interrupt and use the driver read call from the Xenomai user space
> thread to access register data. In each case the data would then be
> passed to the Linux domain via a message to a Posix queue - after some
> further processing that is not real time critical.
>
> Could you enlighten me as to the pros and cons of each approach, I am
> particularly unclear as to the implications of using mmap in the Xenomai
> domain and what if any affect it might have on the real time
> responsiveness (I understand mmap() to be a call back into the Linux
> kernel rather than to the Xenomai nucleus).
To call mmap from real-time code is actually a generic issue. If you
look at the design of other time-critical, though not hard-RT drivers
like video4linux, they also try to avoid mmap'ing on demand. Instead one
should set up mappings ahead-of-time during device initialisation. Use
rings of premapped buffers that cycle between the driver and the
application.
Unless you have really specific requirements, going the RTDM path has
the advantage of introducing a clear abstraction between the hardware
accessing driver and some application. If you happen to reuse your
hardware for a different project later, you will then be able to reuse
the driver as well.
Your application could become a multi-threaded Xenomai program: one
thread accessing the RTDM device under strict time constraints and
pushing information into the message queue, some other thread(s)
(SCHED_OTHER, but mapped to Xenomai) reading the queue under primary
mode and handling the data under secondary mode like a normal Linux
thread. If you can isolate all time critical work in the driver, you may
even access the device directly from the second thread, making the first
one obsolete.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] Reading Memory Mapped IO
2006-08-02 11:50 ` Jan Kiszka
@ 2006-08-02 12:14 ` Jan Kiszka
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2006-08-02 12:14 UTC (permalink / raw)
To: Doyle, Alan; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 1830 bytes --]
Jan Kiszka wrote:
> Doyle, Alan wrote:
>> Hi,
>>
>> I have an application where I need to read four contiguous memory mapped
>> data registers in response to an interrupt. As its real time critical I
>> intend to implement the read in Xenomai. Having read and processed the
>> data it later needs to be passed to a Linux domain application, I am
>> hoping to use a Posix message queue for this purpose.
>>
>> I seem to have two options as to how to implement this, I could register
>> the interrupt in a Xenomai user space thread and mmap the data registers
>> so that on receiving the interrupt the registers could be read.
>> Alternatively I could write a Xenomai RTDM driver to read the registers
>> on interrupt and use the driver read call from the Xenomai user space
>> thread to access register data. In each case the data would then be
>> passed to the Linux domain via a message to a Posix queue - after some
>> further processing that is not real time critical.
>>
>> Could you enlighten me as to the pros and cons of each approach, I am
>> particularly unclear as to the implications of using mmap in the Xenomai
>> domain and what if any affect it might have on the real time
>> responsiveness (I understand mmap() to be a call back into the Linux
>> kernel rather than to the Xenomai nucleus).
>
> To call mmap from real-time code is actually a generic issue. If you
> look at the design of other time-critical, though not hard-RT drivers
> like video4linux, they also try to avoid mmap'ing on demand. Instead one
> should set up mappings ahead-of-time during device initialisation. Use
> rings of premapped buffers that cycle between the driver and the
> application.
One thing I forgot to mention: likely you want to have a look at
rtdm_mmap_to_user() for this purpose.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] Reading Memory Mapped IO
2006-08-02 9:24 [Xenomai-help] Reading Memory Mapped IO Doyle, Alan
2006-08-02 11:50 ` Jan Kiszka
@ 2006-08-02 12:27 ` Gilles Chanteperdrix
1 sibling, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2006-08-02 12:27 UTC (permalink / raw)
To: Doyle, Alan; +Cc: xenomai
Doyle, Alan wrote:
>
> Hi,
>
> I have an application where I need to read four contiguous memory mapped
> data registers in response to an interrupt. As its real time critical I
> intend to implement the read in Xenomai. Having read and processed the
> data it later needs to be passed to a Linux domain application, I am
> hoping to use a Posix message queue for this purpose.
>
> I seem to have two options as to how to implement this, I could register
> the interrupt in a Xenomai user space thread and mmap the data registers
> so that on receiving the interrupt the registers could be read.
> Alternatively I could write a Xenomai RTDM driver to read the registers
> on interrupt and use the driver read call from the Xenomai user space
> thread to access register data. In each case the data would then be
> passed to the Linux domain via a message to a Posix queue - after some
> further processing that is not real time critical.
>
> Could you enlighten me as to the pros and cons of each approach,
The advantage of the "all in user-space" approach is that you will be
able to get rapidly something that works, because debugging in
user-space is much easier than in kernel-space. On the other
hand, writing a driver using RTDM will result in a clear separation
between application code and driver code that will be easier to maintain
on the long run. Imagine what will happen in the two cases when the
hardware changes.
--
Gilles Chanteperdrix.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-08-02 12:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-02 9:24 [Xenomai-help] Reading Memory Mapped IO Doyle, Alan
2006-08-02 11:50 ` Jan Kiszka
2006-08-02 12:14 ` Jan Kiszka
2006-08-02 12:27 ` Gilles Chanteperdrix
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.