writing from user space through fifo problems
I've got 2 programs, one Xenomai user space real time thread and one normal user space program.
My normal user space is trying to pass a structure to my real time program and failing.
my RT thread reads in a 1ms loop with:
err = rt_pipe_read(control_pipe,k,sizeof(control_t),TM_NONBLOCK);
my regular linux program writes a real time fifo with:
int fd = open(dev, O_WRONLY|O_SYNC);
err = write(fd,&c,sizeof(c)); if(err<=0)error(0,-err, "write failed with %d",err); close(fd);
The user space program succeeds (write returns no error and doesn't block), but the RT thread never see's the data, continually returning -EINTR.
Note that if I change the real time thread to TM_INFINITE it works, but blocks for course, which isn't what I want, since I only want to pull out data at the beginning of a constant loop.
Is this the correct behavior?
Does read have to be set up and waiting for the data to recieve it?
thx,
NZG
Quoted 11 lines · NZG
I've got 2 programs, one Xenomai user space real time thread and one normal user space program.
My normal user space is trying to pass a structure to my real time program and failing.
my RT thread reads in a 1ms loop with:
err = rt_pipe_read(control_pipe,k,sizeof(control_t),TM_NONBLOCK);my regular linux program writes a real time fifo with:
Quoted 7 lines
int fd =
open(dev, O_WRONLY|O_SYNC);
err = write(fd,&c,sizeof(c)); if(err<=0)error(0,-err, "write failed with %d",err); close(fd);The user space program succeeds (write returns no error and doesn't block), but the RT thread never see's the data, continually returning
-EINTR.
Are you sure it is EINTR? A first glance at the possible code path, specifically at xnpipe_recv, suggests that you cannot reach the line returning this error code if TM_NONBLOCK was passed.
What Xenomai version are we talking about BTW? And, as usual:
self-contained simple test cases are always appreciated. :)
Jan
[Xenomai-help] Xenomai maximum latency
Hi all,
I've just started with Xenomai and I'm wondering if on a given Platform does Xenomai garantee a Maximum latency that will never be exeed ?
Regards,
zak
_____________________________________________________________________________
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr
Re: [Xenomai-help] Xenomai maximum latency
Quoted 6 lines · ayoub zaki
Hi all,
I've just started with Xenomai and I'm wondering if on a given Platform does Xenomai garantee a Maximum latency that will never be exeed ?
There is no written garantee as such. What we garantee is to do our best to keep the maximum latency as low as possible.
And we provide the latency test, to measure the maximum latency of your system under the load conditions you define.
Signature · 1 line
Gilles Chanteperdrix
Quoted 3 lines
Are you sure it is EINTR? A first glance at the possible code path, specifically at
xnpipe_recv, suggests that you cannot reach the line returning this error code ifTM_NONBLOCKwas passed.
Your right, my mistake sorry.
It's returning EAGAIN , which is the same thing as EWOULDBLOCK in my kernel headers, which corresponds to the correct value when data i s not available, but doesn't explain why data is never received.
Quoted 1 line
What Xenomai version are we talking about BTW?
2.3.1 (blackfin 537 build)
Quoted 2 lines
And, as usual:
self-contained simple test cases are always appreciated. :)
I'll try to put something together tonight.
thx,
NZG
Quoted 7 lines · NZG
Quoted 3 lines
Are you sure it is EINTR? A first glance at the possible code path, specifically at
xnpipe_recv, suggests that you cannot reach the line returning this error code ifTM_NONBLOCKwas passed.Your right, my mistake sorry.
It's returning EAGAIN , which is the same thing as EWOULDBLOCK in my kernel headers, which corresponds to the correct value when data i s not available, but doesn't explain why data is never received.
OK, that makes more sense.
Quoted 7 lines
Quoted 2 lines
What Xenomai version are we talking about BTW?
2.3.1 (blackfin 537 build)
Quoted 2 lines
And, as usual:
self-contained simple test cases are always appreciated. :)I'll try to put something together tonight.
That's good. This test will also allow you to check it against
- more recent Xenomai (please check the Changelog for pipe-related changes since 2.3.1, I bet there are a few)
- some other arch, specifically x86 (IIRC, there is still some Linux scheduling artifact left in the I-pipe patch for blackfin, but it shouldn't make a difference here - well, who knows...)
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 6 lines · Jan Kiszka
That's good. This test will also allow you to check it against
- more recent Xenomai (please check the Changelog for pipe-related changes since 2.3.1, I bet there are a few)
- some other arch, specifically x86 (IIRC, there is still some Linux scheduling artifact left in the I-pipe patch for blackfin, but it shouldn't make a difference here - well, who knows...)
Well, in the process of writing a simple test I kindof found the problem. My user space program is writing and then immediatly closing, which appears to destroy the data if it hasn't been read by then. Inserting a sleep between write and close causes it to work.
I noticed this because my test program was working because it just so happened to pause until the real time task ended before closing the fd.
I remember doing this before, now that it's figured out, but it's still kind of problematic because it doesn't appear to be possible to block on user space writes.
Opening with O_SYNC does not cause it to block, and fsync(fd) doesn't seem to do anything. anybody have any suggestions on how to know data has been received before closing a pipe after a write? Surely somebody's done this before.
thanks,
NZG
Quoted 7 lines · NZG
Quoted 6 lines · Jan Kiszka
That's good. This test will also allow you to check it against
- more recent Xenomai (please check the Changelog for pipe-related changes since 2.3.1, I bet there are a few)
- some other arch, specifically x86 (IIRC, there is still some Linux scheduling artifact left in the I-pipe patch for blackfin, but it shouldn't make a difference here - well, who knows...)
Quoted 5 lines
Well, in the process of writing a simple test I kindof found the problem. My user space program is writing and then immediatly closing, which appears to destroy the data if it hasn't been read by then. Inserting a sleep between write and close causes it to work.
Yes, releasing a fildes flushes the input queue from lingering data before closing the user-space side.
Quoted 9 lines
I noticed this because my test program was working because it just so happened to pause until the real time task ended before closing the fd.
I remember doing this before, now that it's figured out, but it's still kind of problematic because it doesn't appear to be possible to block on user space writes.
Opening with
O_SYNCdoes not cause it to block, and fsync(fd) doesn't seem to do anything.
O_SYNC support has to be implemented by the driver, and Xenomai implements this for the pipe driver since 2.4-rc1. Therefore, passing O_SYNC to open() using 2.3.1 will just lead to a nop.
anybody have any suggestions on how to know data has been
Quoted 3 lines
received before closing a pipe after a write? Surely somebody's done this before.
The only way I see with 2.3.1 would be to make a non-realtime shadow from your user-space thread (rt_task_shadow() with priority 0), then have it pend on a Xenomai semaphore signaled by your real-time task when it has consumed the packet.
Quoted 11 lines
thanks,
NZG_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Quoted 3 lines · Philippe Gerum
O_SYNCsupport has to be implemented by the driver, and Xenomai implements this for the pipe driver since 2.4-rc1. Therefore, passingO_SYNCtoopen()using 2.3.1 will just lead to a nop.
Ah, well then first thing to try is to just upgrade Xenomai. I'll give it a shot,
thanks for confirming this,
NZG
Quoted 15 lines · NZG
Quoted 6 lines · Jan Kiszka
That's good. This test will also allow you to check it against
- more recent Xenomai (please check the Changelog for pipe-related changes since 2.3.1, I bet there are a few)
- some other arch, specifically x86 (IIRC, there is still some Linux scheduling artifact left in the I-pipe patch for blackfin, but it shouldn't make a difference here - well, who knows...)Well, in the process of writing a simple test I kindof found the problem. My user space program is writing and then immediatly closing, which appears to destroy the data if it hasn't been read by then. Inserting a sleep between write and close causes it to work.
I noticed this because my test program was working because it just so happened to pause until the real time task ended before closing the fd.
Quoted 8 lines
I remember doing this before, now that it's figured out, but it's still kind of problematic because it doesn't appear to be possible to block on user space writes.
Opening with
O_SYNCdoes not cause it to block, and fsync(fd) doesn't seem to do anything. anybody have any suggestions on how to know data has been received before closing a pipe after a write? Surely somebody's done this before.
Well, I do not know the details of the rt_pipe implementation, but intuitively I would say that what you observe is not normal: when you write to the rt_pipe, the reader should be woken up immediately and consume the data, before the producer can close the descriptor. Are you writing data to the pipe from an RT task ?
Signature · 1 line
Gilles Chanteperdrix
Quoted 25 lines · Gilles Chanteperdrix
Quoted 15 lines · NZG
Quoted 6 lines · Jan Kiszka
That's good. This test will also allow you to check it against
- more recent Xenomai (please check the Changelog for pipe-related changes since 2.3.1, I bet there are a few)
- some other arch, specifically x86 (IIRC, there is still some Linux scheduling artifact left in the I-pipe patch for blackfin, but it shouldn't make a difference here - well, who knows...)Well, in the process of writing a simple test I kindof found the problem. My user space program is writing and then immediatly closing, which appears to destroy the data if it hasn't been read by then. Inserting a sleep between write and close causes it to work.
I noticed this because my test program was working because it just so happened to pause until the real time task ended before closing the fd.
Quoted 8 lines
I remember doing this before, now that it's figured out, but it's still kind of problematic because it doesn't appear to be possible to block on user space writes.
Opening with
O_SYNCdoes not cause it to block, and fsync(fd) doesn't seem to do anything. anybody have any suggestions on how to know data has been received before closing a pipe after a write? Surely somebody's done this before.
Quoted 6 lines
Well, I do not know the details of the
rt_pipeimplementation, but intuitively I would say that what you observe is not normal: when you write to thert_pipe, the reader should be woken up immediately and consume the data, before the producer can close the descriptor. Are you writing data to the pipe from an RT task ?
As far as I understand, the reader polls, so userland may close the fildes before the real-time task peeks at its pipe end.
Signature · 1 line
Philippe.
Quoted 34 lines · Philippe Gerum
Quoted 25 lines · Gilles Chanteperdrix
Quoted 15 lines · NZG
Quoted 6 lines · Jan Kiszka
That's good. This test will also allow you to check it against
- more recent Xenomai (please check the Changelog for pipe-related changes since 2.3.1, I bet there are a few)
- some other arch, specifically x86 (IIRC, there is still some Linux scheduling artifact left in the I-pipe patch for blackfin, but it shouldn't make a difference here - well, who knows...)Well, in the process of writing a simple test I kindof found the problem. My user space program is writing and then immediatly closing, which appears to destroy the data if it hasn't been read by then. Inserting a sleep between write and close causes it to work.
I noticed this because my test program was working because it just so happened to pause until the real time task ended before closing the fd.
Quoted 8 lines
I remember doing this before, now that it's figured out, but it's still kind of problematic because it doesn't appear to be possible to block on user space writes.
Opening with
O_SYNCdoes not cause it to block, and fsync(fd) doesn't seem to do anything. anybody have any suggestions on how to know data has been received before closing a pipe after a write? Surely somebody's done this before.Quoted 6 lines
Well, I do not know the details of the
rt_pipeimplementation, but intuitively I would say that what you observe is not normal: when you write to thert_pipe, the reader should be woken up immediately and consume the data, before the producer can close the descriptor. Are you writing data to the pipe from an RT task ?
Quoted 2 lines
As far as I understand, the reader polls, so userland may close the fildes before the real-time task peeks at its pipe end.
Ok, forgot that point.
Signature · 1 line
Gilles Chanteperdrix