Dngrong Yi wrote:
> Consider such a scenerio, one rtlinux's program and one normal linux
> program. The rtlinux program write to a fifo with
> very high rate a structure, and the fifo is created to be
> the same size
> as that of the structure. The user program read the same
> structure from
> that same fifo.
>
> What will happen that during the user program is reading from
> the fifo when rtlinux program come and take the resource
> over ? I can not
> imagine how this issue be dealt with rtlinux.
RTLinux will not be able to write the entire structure to the FIFO,
and you will get a failure with an ENOSPC return code. The solution to this
is to use FIFOs the way they are meant to be used, as FIFOs rather than
shared memory.
What do I mean? Unless you have a really *huge* structure to
communicate (larger than hundreds of kilobytes) or are severely memory
restricted, you should allocate the FIFO to be several times larger than
your structure. This allows some buffering to handle the cases where your
user space task does not get control immediately when RTLinux returns
control to Linux, etc. Remember, you are not the only process running in
user space.
If, on the other hand, your structure *is* huge, or you *are*
severely memory limited, you should be using shared memory (mbuf) for this
communications. Use a very small RTLinux FIFO to communicate the state of
the mbuf back and forth between the RTLinux and user space worlds. Think of
the FIFO as a simple conduit for token passing between the RTLinux and user
space in this case.
> Another issue, consider again a rtlinux process, and a normal process.
> This time the normal process write a structure to a fifo and
> the rtlinux
> read it. What will happen that when the linux process only
> write half of
> the fifo when the rtlinux come to read it?
RTLinux will only read half of the data from the FIFO. You need to
check the return value to see that you got all of the data you require. If
not, you should store what you did get and wait for the rest. By "wait for
the rest", I do not mean block the RTLinux task, but rather continue
computation and return to check the FIFO later.
> Are such issues are considered already by rtlinux kernel or
> the user (like
> me) of rtlinux should take care of it ?
I guess the answer is "a little bit of both". Fortunately, each
handles the part that it is best suited to handle.
Regards,
Steve
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/