Thread View: comp.unix.programmer
2 messages
2 total messages
Started by Marcus J. Ranum
Thu, 08 Nov 1990 04:13
when to use readv()/writev() ?
Author: Marcus J. Ranum
Date: Thu, 08 Nov 1990 04:13
Date: Thu, 08 Nov 1990 04:13
20 lines
1411 bytes
1411 bytes
What are some cases when I'd want to use readv() instead of read()? I understand the advantages of being able to break things into several buffers (and possibly avoid having to move data around) but does using writev() give me some kind of possible performance improvement? Does writev() help block my data into popular buffer sizes or something like that ? If I have 2 iovecs with 500 and 524 bytes respectively is the operation performed analogous to write(fd,buf,1024) or is it simply write(fd,buf1,500), write(fd,buf2,524) with the kernel just doing the legwork? I see I still have to sum up the sizes of the contents of the scatter/gather arrays so I can check the return of the write - doesn't it get kind of icky when you have a partial writev()? Please let's *NOT* get into a bOring 6-week long discussion about checking return values. Suffice to say I do. :) mjr.
Re: when to use readv()/writev() ?
Author: Chris Torek
Date: Thu, 08 Nov 1990 06:55
Date: Thu, 08 Nov 1990 06:55
21 lines
1471 bytes
1471 bytes
In article <1990Nov8.041357.29013@decuac.dec.com> mjr@decuac.dec.com (Marcus J. Ranum) writes: > If I have 2 iovecs with 500 and 524 bytes respectively is the >operation performed analogous to write(fd,buf,1024) or is it simply >write(fd,buf1,500), write(fd,buf2,524) with the kernel just doing >the legwork? The latter (except, potentially, to a character device, but there are no character devices in any Unix I have seen that do anything special with multiple IO vectors). > I see I still have to sum up the sizes of the contents of the >scatter/gather arrays so I can check the return of the write - doesn't >it get kind of icky when you have a partial writev()? Yes, it does. This is one of the reasons I elected not to use writev() in my stdio implementation (which has a stdio-level writev-like function whose main raison d'etre is printf()). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads