"Stephen D. Cohen" wrote:

> > -----Original Message-----
> > From: Robert Kavaler [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 26, 2001 1:42 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [rtl] RTF
> >
> >
> > The problem you've outlined here will only happen if you read
> > the fifo one
> > byte at a time.  If you read it 8 bytes at a time then hard
> > interrupts are
> > disabled for the entire duration of the read.  To read 8
> > bytes at a time
> > issue the command "read(fifo_fd, buf, 8);"

>
>
>         This is not true in 3.1, and I do not know if it was true with
> earlier versions.  In 3.1 the read only disables interrupts long enough to
> update the FIFO structure (pointers).  This is done to preserve FIFO
> integrity, not to make sure you always get the number of characters you
> request.

I forgot that reading from the user side uses different code than reading from
the rt side.  But still, if you read 8 bytes at a time, you will only get
interrupted if the fifo wraps in the middle of the data.  It is easy to avoid
this by setting the fifo length to a multiples of the struct size (assuming the
structs are fixed length).  But none of this should matter as long as you make
the writes atomic and you only have ONE reader.

>
>
> > Also, on the writing side, writes will either write all their data
> > into a fifo or none of their data.  So in your example, if the fifo
> > has 4 bytes left and you attempt to write "realtime", the
> > write will fail.
>
>         This is definitely not true in 3.1.  I am also fairly confident that
> this has never been true in RTLinux.  The current code writes as much data
> as possible if it can not write everything.

The code to rtf_put:

int rtf_put(unsigned int minor, void *buf, int count)
{
       rtl_irqstate_t interrupt_state; qstate_t interrupt_state;
       int chars = 0, free = 0, written = 0;
       char *pipebuf;

        if (minor >= RTF_MAX_FIFO) {
                return -ENODEV;
        }
        if (!RTF_ALLOCATED(minor))
                return -EINVAL;

        rtl_spin_lock_irqsave(&RTF_SPIN(minor), interrupt_state);
        if (RTF_FREE(minor) < count) {
                rtl_spin_unlock_irqrestore(&RTF_SPIN(minor), interrupt_state);
                return -ENOSPC;
        }

The last "if" seems to say if the amount of free space is less than the
requested space return with an error code.  Am I missing something??

Robert


-- [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/

Reply via email to