Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sdd.hp.com!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!decuac!haven!mimsy!mojo!stripes From: stripes@eng.umd.edu (Joshua Osborne) Newsgroups: comp.unix.wizards Subject: Re: Reserving Space on Disk Message-ID: <1990Jul17.032745.3807@eng.umd.edu> Date: 17 Jul 90 03:27:45 GMT References: <13422@ulysses.att.com> <836@mwtech.UUCP> Sender: news@eng.umd.edu (The News System) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 32 In article <836@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes: >In article <13422@ulysses.att.com> cjc@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@eng.umd.edu "Security for Unix is like Josh_Osborne@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