I'm writing a serial port class. My team lead said that when using
simple, non-overlapped I/O on Windows 2000, they found that doing 1 and
2 byte reads caused a significant peak in CPU utilization. (All our
packets are read with a 1 byte, then either a 1 or 2 byte read then a
lengthy read.) Do reduce this, they double buffered the reads.

I converted the class to use basic OVERLAPPED I/O. I wrote 2 versions
of the class; one uses straight reads, the other reads the data in
chunks and queues it up for the reader.

When testing both, I found that the process utilization was the same on
average. Does anyone know if OVERLAPPED I/O is already buffering serial
port reads? (Do serial port reads even make a ring transition at the
driver level? Did this possibly change between Windows 2000 and Windows
XP?)

Re: Overlapped Serial Ports and buffering by Alexander

Alexander
Fri Dec 29 20:29:25 CST 2006

There is a fixed overhead per request and it may be high if you read by a
single byte. Use bigger buffers.

OVERLAPPED I/O allows to have parallel read and write requests, and several
pending requests in the queue. It won't reduce your overhead.

"Joe" <joewoodbury@gmail.com> wrote in message
news:1167420543.565990.226000@48g2000cwx.googlegroups.com...
> I'm writing a serial port class. My team lead said that when using
> simple, non-overlapped I/O on Windows 2000, they found that doing 1 and
> 2 byte reads caused a significant peak in CPU utilization. (All our
> packets are read with a 1 byte, then either a 1 or 2 byte read then a
> lengthy read.) Do reduce this, they double buffered the reads.
>
> I converted the class to use basic OVERLAPPED I/O. I wrote 2 versions
> of the class; one uses straight reads, the other reads the data in
> chunks and queues it up for the reader.
>
> When testing both, I found that the process utilization was the same on
> average. Does anyone know if OVERLAPPED I/O is already buffering serial
> port reads? (Do serial port reads even make a ring transition at the
> driver level? Did this possibly change between Windows 2000 and Windows
> XP?)
>



Re: Overlapped Serial Ports and buffering by Pavel

Pavel
Sat Dec 30 06:26:26 CST 2006

AFAIK the overlapped i/o by itself is not related to any
buffering in the serial driver, but the hardware itself can buffer few incoming bytes, so
the next read will get them.
Yes, every serial port read results in a kernel call and ring ttansition.

Regards,
--PA


"Joe" <joewoodbury@gmail.com> wrote in message news:1167420543.565990.226000@48g2000cwx.googlegroups.com...
> I'm writing a serial port class. My team lead said that when using
> simple, non-overlapped I/O on Windows 2000, they found that doing 1 and
> 2 byte reads caused a significant peak in CPU utilization. (All our
> packets are read with a 1 byte, then either a 1 or 2 byte read then a
> lengthy read.) Do reduce this, they double buffered the reads.
>
> I converted the class to use basic OVERLAPPED I/O. I wrote 2 versions
> of the class; one uses straight reads, the other reads the data in
> chunks and queues it up for the reader.
>
> When testing both, I found that the process utilization was the same on
> average. Does anyone know if OVERLAPPED I/O is already buffering serial
> port reads? (Do serial port reads even make a ring transition at the
> driver level? Did this possibly change between Windows 2000 and Windows
> XP?)
>