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: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to