* function read() isn't quick enough for reading in ttyS*
@ 2008-08-01 23:13 Federico Tula Rovaletti
2008-08-04 5:44 ` Stalin Kenny
2008-08-04 17:35 ` Glynn Clements
0 siblings, 2 replies; 3+ messages in thread
From: Federico Tula Rovaletti @ 2008-08-01 23:13 UTC (permalink / raw)
To: linux-c-programming
Hi all! I'm a novice in Linux
In a program I'm writing in c, when I use the read() function for
reading a byte in the serial port with a configuration: 115200 bps,
8N2
takes from 2ms to 6ms (aleatory, even if read up to 10 bytes takes the
same time), which is too long.
(ioctl(fd, FIONREAD, &bytes) last the same)
This is the time is suppose to last:
8 bits: data
2 bits: stop
1 bit: start
time = ((8+2+1)bits/115200bps) = 0.095ms,
then when I read the byte with the function inb_p() takes ~ 0.1ms
which is perfect, what I'm needing for my project.
The problem I'm having is that I use signals (with fcntl(fd, F_SETFL,
O_ASYNC) ) but this signals last the same time in occur that the
read() (unacceptable) so I guess that this is a problem of the driver
that is to slow.
So the question is, is there any way to improve the performance of the
driver, or how can I have a faster response with read()? (doing inb_p
is very nasty). Do I'm doing something wrong?
Thanks in advance!, I expect as soon as possible any answer
PD: sorry for my bad English,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: function read() isn't quick enough for reading in ttyS*
2008-08-01 23:13 function read() isn't quick enough for reading in ttyS* Federico Tula Rovaletti
@ 2008-08-04 5:44 ` Stalin Kenny
2008-08-04 17:35 ` Glynn Clements
1 sibling, 0 replies; 3+ messages in thread
From: Stalin Kenny @ 2008-08-04 5:44 UTC (permalink / raw)
To: Federico Tula Rovaletti; +Cc: linux-c-programming
> In a program I'm writing in c, when I use the read() function for
> reading a byte in the serial port with a configuration: 115200 bps,
> 8N2
>
> takes from 2ms to 6ms (aleatory, even if read up to 10 bytes takes the
> same time), which is too long.
> (ioctl(fd, FIONREAD, &bytes) last the same)
>
> This is the time is suppose to last:
> 8 bits: data
> 2 bits: stop
> 1 bit: start
> time = ((8+2+1)bits/115200bps) = 0.095ms,
>
> then when I read the byte with the function inb_p() takes ~ 0.1ms
> which is perfect, what I'm needing for my project.
>
I guess the context switch that is taking place when you issue ioctl
is contributing to the extra time that you are noticing.
Stalin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: function read() isn't quick enough for reading in ttyS*
2008-08-01 23:13 function read() isn't quick enough for reading in ttyS* Federico Tula Rovaletti
2008-08-04 5:44 ` Stalin Kenny
@ 2008-08-04 17:35 ` Glynn Clements
1 sibling, 0 replies; 3+ messages in thread
From: Glynn Clements @ 2008-08-04 17:35 UTC (permalink / raw)
To: Federico Tula Rovaletti; +Cc: linux-c-programming
Federico Tula Rovaletti wrote:
> In a program I'm writing in c, when I use the read() function for
> reading a byte in the serial port with a configuration: 115200 bps,
> 8N2
>
> takes from 2ms to 6ms (aleatory, even if read up to 10 bytes takes the
> same time), which is too long.
> (ioctl(fd, FIONREAD, &bytes) last the same)
>
> This is the time is suppose to last:
> 8 bits: data
> 2 bits: stop
> 1 bit: start
> time = ((8+2+1)bits/115200bps) = 0.095ms,
>
> then when I read the byte with the function inb_p() takes ~ 0.1ms
> which is perfect, what I'm needing for my project.
>
> The problem I'm having is that I use signals (with fcntl(fd, F_SETFL,
> O_ASYNC) ) but this signals last the same time in occur that the
> read() (unacceptable) so I guess that this is a problem of the driver
> that is to slow.
>
> So the question is, is there any way to improve the performance of the
> driver, or how can I have a faster response with read()? (doing inb_p
> is very nasty). Do I'm doing something wrong?
Are you using real-time scheduling?
Getting such low latency in user space is tricky, but not impossible.
You might want to look at JACK (www.jackaudio.org) for clues; they
have similar issues
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-04 17:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-01 23:13 function read() isn't quick enough for reading in ttyS* Federico Tula Rovaletti
2008-08-04 5:44 ` Stalin Kenny
2008-08-04 17:35 ` Glynn Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).