* [Xenomai-help] A few questions about rt_printf
@ 2009-11-02 7:16 Daniel Adams
2009-11-02 7:52 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Adams @ 2009-11-02 7:16 UTC (permalink / raw)
To: xenomai
[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]
Hi,
I was looking at using the rt_printf / rt_fprintf for doing deferred logging
and I have a few questions.
1) I was reading through the source and I noticed there is no locking of the
buffer write_pos between tasks during the initial snprint into the buffer.
Is the rt_printf service thread safe? There are calls to
xnarch_read_memory_barrier() and xnarch_write_memory_barrier(), but I'm
assuming they are for SMP and IO ordering although I'm not 100% on what the
barriers imply as I'm fairly new to this kind of hardware.
2) Can the service be called from Linux tasks and Xenomai tasks? We were
trying to get away with a common logging interface (wrapping the service)
which would allow writing to different streams. If it can't be called from a
Linux process then we will have an issue if we try to write to the same
stream from different write tasks.
3) Why is there multiple buffers allowing multiple FIFO's. I've read the
code and can't really see how the extra buffers are used from a users
perspective (I can see how the service prints / manages them). It appears
that whatever buffer you create with rt_print_init or rt_auto_init is the
buffer that get's used for writing too. Is there a way to select the buffer
you want to write to? Also a call to rt_print_init causes a pre-existing
buffer to be written to io from within the callers context and then creates
a new buffer / ring buffer, so that no matter what you are always writing to
the head of the linked list of buffers. How do I get access to an old buffer
once it has been printed? Is there something I'm missing?
I really think I must be missing something, sorry if these are obvious
questions.
Thanks
Dan Adams
[-- Attachment #2: Type: text/html, Size: 1781 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-help] A few questions about rt_printf
2009-11-02 7:16 [Xenomai-help] A few questions about rt_printf Daniel Adams
@ 2009-11-02 7:52 ` Jan Kiszka
2009-11-02 8:20 ` Daniel Adams
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2009-11-02 7:52 UTC (permalink / raw)
To: Daniel Adams; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 2172 bytes --]
Daniel Adams wrote:
> Hi,
>
> I was looking at using the rt_printf / rt_fprintf for doing deferred logging
> and I have a few questions.
>
> 1) I was reading through the source and I noticed there is no locking of the
> buffer write_pos between tasks during the initial snprint into the buffer.
> Is the rt_printf service thread safe? There are calls to
> xnarch_read_memory_barrier() and xnarch_write_memory_barrier(), but I'm
> assuming they are for SMP and IO ordering although I'm not 100% on what the
> barriers imply as I'm fairly new to this kind of hardware.
rt_printf buffers are single-writer/single-reader (one per thread)
lock-less ring buffers, they are safe on both UP and SMP.
>
> 2) Can the service be called from Linux tasks and Xenomai tasks? We were
> trying to get away with a common logging interface (wrapping the service)
> which would allow writing to different streams. If it can't be called from a
> Linux process then we will have an issue if we try to write to the same
> stream from different write tasks.
Yes, in fact the rr_printf/syslog services of rtdk even work without a
single bit of Xenomai, so they can be used in any context.
>
> 3) Why is there multiple buffers allowing multiple FIFO's. I've read the
> code and can't really see how the extra buffers are used from a users
> perspective (I can see how the service prints / manages them). It appears
> that whatever buffer you create with rt_print_init or rt_auto_init is the
> buffer that get's used for writing too. Is there a way to select the buffer
> you want to write to? Also a call to rt_print_init causes a pre-existing
> buffer to be written to io from within the callers context and then creates
> a new buffer / ring buffer, so that no matter what you are always writing to
> the head of the linked list of buffers. How do I get access to an old buffer
> once it has been printed? Is there something I'm missing?
See above, buffers are per thread so that we don't need locking.
>
> I really think I must be missing something, sorry if these are obvious
> questions.
>
> Thanks
>
> Dan Adams
>
HTH,
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-help] A few questions about rt_printf
2009-11-02 7:52 ` Jan Kiszka
@ 2009-11-02 8:20 ` Daniel Adams
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Adams @ 2009-11-02 8:20 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 2435 bytes --]
Ah of course :) I must of been not paying attention while reading the
pthread_getspecific calls. Thanks for the clarification.
Dan
On Mon, Nov 2, 2009 at 3:52 PM, Jan Kiszka <jan.kiszka@domain.hid> wrote:
> Daniel Adams wrote:
> > Hi,
> >
> > I was looking at using the rt_printf / rt_fprintf for doing deferred
> logging
> > and I have a few questions.
> >
> > 1) I was reading through the source and I noticed there is no locking of
> the
> > buffer write_pos between tasks during the initial snprint into the
> buffer.
> > Is the rt_printf service thread safe? There are calls to
> > xnarch_read_memory_barrier() and xnarch_write_memory_barrier(), but I'm
> > assuming they are for SMP and IO ordering although I'm not 100% on what
> the
> > barriers imply as I'm fairly new to this kind of hardware.
>
> rt_printf buffers are single-writer/single-reader (one per thread)
> lock-less ring buffers, they are safe on both UP and SMP.
>
> >
> > 2) Can the service be called from Linux tasks and Xenomai tasks? We were
> > trying to get away with a common logging interface (wrapping the service)
> > which would allow writing to different streams. If it can't be called
> from a
> > Linux process then we will have an issue if we try to write to the same
> > stream from different write tasks.
>
> Yes, in fact the rr_printf/syslog services of rtdk even work without a
> single bit of Xenomai, so they can be used in any context.
>
> >
> > 3) Why is there multiple buffers allowing multiple FIFO's. I've read the
> > code and can't really see how the extra buffers are used from a users
> > perspective (I can see how the service prints / manages them). It appears
> > that whatever buffer you create with rt_print_init or rt_auto_init is the
> > buffer that get's used for writing too. Is there a way to select the
> buffer
> > you want to write to? Also a call to rt_print_init causes a pre-existing
> > buffer to be written to io from within the callers context and then
> creates
> > a new buffer / ring buffer, so that no matter what you are always writing
> to
> > the head of the linked list of buffers. How do I get access to an old
> buffer
> > once it has been printed? Is there something I'm missing?
>
> See above, buffers are per thread so that we don't need locking.
>
> >
> > I really think I must be missing something, sorry if these are obvious
> > questions.
> >
> > Thanks
> >
> > Dan Adams
> >
>
> HTH,
> Jan
>
>
[-- Attachment #2: Type: text/html, Size: 3108 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-02 8:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-02 7:16 [Xenomai-help] A few questions about rt_printf Daniel Adams
2009-11-02 7:52 ` Jan Kiszka
2009-11-02 8:20 ` Daniel Adams
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.