Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

readv/writev

29 views
Skip to first unread message

j...@jgk.org

unread,
Sep 13, 2011, 6:08:59 PM9/13/11
to
In theory this sounds like a great idea. In practice how often i have
seen it used is--never.

Are they useful? When is this better than calls to read/write or going
through getc/putc/fread/fwrite or something else.

Urs Thuermann

unread,
Sep 19, 2011, 3:42:58 PM9/19/11
to
I've used readv() and writev() quite a number of times. Compared to
read() and write() it has two adavantages: readv()/writev() are
atomic and you can save system calls, i.e. context switches, and
therefore improve performance.

Last time I used it was when writing/reading to a ring buffer. Say
you have a large buffer, that is nearly full, say 500 bytes left, and
want to read 4K. You could read 500 bytes to the current position in
the buffer and then another 3596 bytes to the beginning of the
buffer. Or call just a single readv().

urs
0 new messages