Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!ulysses.att.com!cjc From: cjc@ulysses.att.com (Chris Calabrese[mav]) Newsgroups: comp.unix.wizards Subject: Re: Reserving Space on Disk Summary: should definitely malloc space to be used by read and write Message-ID: <13422@ulysses.att.com> Date: 16 Jul 90 14:38:46 GMT References: <563@hhb.UUCP> <1990Jul15.211608.26025@virtech.uucp> Sender: netnews@ulysses.att.com Lines: 25 In article , moss@cs.umass.edu (Eliot Moss) writes: > [ ... ] > > char buf[ONE_K]; > int i; > > for (i = 0; i < FOUR_K; ++i) > write (fd, buf, ONE_K); > [ ... ] BTW, while reading the various ways to write some large space on the disk which have been passing by, I thought I'd pass a related tidbit along. On many machine architectures, byte copying from user space to kernel space is quite a bit faster if the buffer is word aligned. For this reason, it is better to use malloc to get your buffer than to allocate it off of the stack (as malloc always returns maximally aligned memory). Of course, this assumes that you'll use the buffer more than once, as the time to malloc() is around the same order as the time to deal with the non-aligned bytes at the beginning and end of the buffer. Name: Christopher J. Calabrese Brain loaned to: AT&T Bell Laboratories, Murray Hill, NJ att!ulysses!cjc cjc@ulysses.att.com Obligatory Quote: ``pher - gr. vb. to schlep. phospher - to schlep light.philosopher - to schlep thoughts.''