Re: When does `write' return?
- From: Jean-David Beyer <jdbeyer@xxxxxxxxxxx>
- Date: Thu, 12 Jan 2006 23:00:17 -0500
Andrew Xue wrote:
> Jean-David Beyer 写道:
>
>
>> It depends on a coupla things. If you have much more than 1GBytes of
>> ram, the write could return as soon as the data get to a memory buffer.
>> Possibly some of the cache would have to be paged out, but not
>> necessarily.
>>
>
> My ram is a little bit large, 4GB. And my biggest test file is 1.8GB, so
> I think it's cached entirely.
>
>
>> It also depends if file fd is a raw file or not (if you are using raw
>> file systems, you probably already know enough to answer your
>> questions; so probably not a raw file). If it is, I believe you must
>> wait until the write completes, but OTOH, you do not need to take the
>> time to find system buffer space and copy from user space to system
>> space, and you might be able to do it in a giant "spiral write" as DEC
>> used to call it. Depends on hardware and the low level driver, I would
>> expect.
>
> Could you please explain it in more details? I could not find anything
> about "spiral write" by google. Does it mean something of copy-on-write?
>
Sorry. That was a DEC thing on their hard drives in the very late 1960s, at
least on the PDP-11 and VAX-11 series machines. It has nothing to do with
copy-on-write.
Their disks had 512-byte sectors and UNIX at the time normally read in one
sector at a time, and if it detected sequential reading, it might read the
next block as well.
But the hardware controller for the disk drives allowed you to read any
multiple of 512 bytes you wanted. I do not remember the numbers, so I will
make them up here, but you will get the idea. Imagine there are 19 tracks
per cylinder and 20 sectors per track. If you started at block zero and read
512 * 20 * 19 bytes, you would read the whole cylinder.
But if you read 512 * 20 * 29 bytes, the controller would accept that, read
the whole cylinder and do an automatic seek with no intervention from the OS
and read about half the next cylinder as well. You could go as much as you
wanted, up to almost 65536 bytes (which would use up all the data space in
any one process).
--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ PGP-Key: 9A2FC99A Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 22:35:00 up 14 days, 13:21, 3 users, load average: 4.19, 4.28, 4.21
.
- Follow-Ups:
- Re: When does `write' return?
- From: Andrew Xue
- Re: When does `write' return?
- References:
- When does `write' return?
- From: Andrew Xue
- Re: When does `write' return?
- From: Jean-David Beyer
- Re: When does `write' return?
- From: Andrew Xue
- When does `write' return?
- Prev by Date: Sexy *nix
- Next by Date: Re: dialup in linux???
- Previous by thread: Re: When does `write' return?
- Next by thread: Re: When does `write' return?
- Index(es):
Relevant Pages
|