Reserving Space on Disk
Joshua Osborne
stripes at eng.umd.edu
Tue Jul 17 13:27:45 AEST 1990
In article <836 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
>In article <13422 at ulysses.att.com> cjc at ulysses.att.com (Chris Calabrese[mav]) writes:
>: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.
>What is wrong with the following approach (at least on non-BSD-ish
>file systems)?
>
> while file has not desired size
> lseek(2) from current position forward
> disk-block-size bytes minus 1 and write(2)
> one byte
>
>IMHO this should fill the disk and avoids much copying from user-space.
That may cause alot less copying from user-space, but it causes more context
switches from user to kernel & back. Mabie someone wants to try their hand
at writev()? I think you can get writev to seek before each write.
Alternetly how about mmap? You can mmap a half a meg at a time, that ought
to reduce the number of syscalls, only write once every 8K (or whatever
the disk block size is) reducing the memmory bandwidth, but will this result
in fewer context switches then write? Then writev?
--
stripes at eng.umd.edu "Security for Unix is like
Josh_Osborne at Real_World,The Mutitasking for MS-DOS"
"The dyslexic porgramer" - Kevin Lockwood
"Don't try to change C into some nice, safe, portable programming language
with all sharp edges removed, pick another language." - John Limpert
More information about the Comp.unix.wizards
mailing list