From: Jan Kiszka <jan.kiszka@domain.hid>
To: Daniel Adams <dadams81@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] A few questions about rt_printf
Date: Mon, 02 Nov 2009 08:52:07 +0100 [thread overview]
Message-ID: <4AEE8FA7.7040804@domain.hid> (raw)
In-Reply-To: <ba9b368a0911012316h393aae27y7418e74b2c8a8428@domain.hid>
[-- 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 --]
next prev parent reply other threads:[~2009-11-02 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-02 7:16 [Xenomai-help] A few questions about rt_printf Daniel Adams
2009-11-02 7:52 ` Jan Kiszka [this message]
2009-11-02 8:20 ` Daniel Adams
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=4AEE8FA7.7040804@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=dadams81@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.