Re: WriteFile()
- From: "m" <mbond@xxxxxxxxxxxxx>
- Date: Tue, 12 Apr 2005 17:03:55 -0400
There is a subtle complication here:
For regular IO, WriteFile can complete successfully with less than the
requested number of bytes written.
If the Handle is opened with the FILE_FLAG_OVERLAPPED flag, then the IO
cannon partially complete regardless of whether or not the IO is blocking or
not.
Consider two threads that write to overlapping sections of a file. In order
to ensure sequential consistency, the first IOP MUST complete totally before
the seccond hits the disk.
"Slava M. Usov" <stripit.slough@xxxxxxx> wrote in message
news:#v#4dW1PFHA.2356@xxxxxxxxxxxxxxxxxxxxxxx
> "Hector Santos" <nospamhere@xxxxxxxxxxxxxx> wrote in message
> news:uyxFNMtPFHA.3196@xxxxxxxxxxxxxxxxxxxxxxx
>
> [...]
>
> > Synchronous 100% meant a blocked call.
>
> This is what I said.
>
> [...]
>
> > That has nothing to do with the fact whether there is a timeout
> > consideration. It may part of the equation or not.
>
> This is what I said, too.
>
> These two statements contradict with your original statement that
> '"synchronous operation" [...] implies block with no timeouts'.
>
> [...]
>
> > For a blocking WriteFile() when *no timeout* is expected or the device
> > is prepared for *no timeout* behavior, the call is 100% blocked and
there
> > are only two possible result:
> >
> > - Success where request = written
> > - Error
> >
> > Anything else is a unexpected design framework.
>
> 'request = written' can be binary if only one byte is involved. If there
are
> more data, it depends on the medium. For serial ports and sockets, to name
> just two, it can be less than the entire data size. This is not Windows
> specific.
>
> [...]
>
> > I don't know how much simple it can get or why this is even a question.
>
> It is not. The concept is much older than WriteFile(). Have a look at
> _write(). As far as I can tell, it has not changed much since 1972 when
what
> later became known as the C Standard Library was created. And it may also
> complete _successfully_ upon writing _less_ than requested.
>
> S
>
>
.
- Follow-Ups:
- Re: WriteFile()
- From: Slava M. Usov
- Re: WriteFile()
- From: Alexander Grigoriev
- Re: WriteFile()
- References:
- WriteFile()
- From: Frank A. Uepping
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Gary Chanson
- Re: WriteFile()
- From: Chris Burnette
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Chris Burnette
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Alexander Grigoriev
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Slava M. Usov
- Re: WriteFile()
- From: Hector Santos
- Re: WriteFile()
- From: Slava M. Usov
- WriteFile()
- Prev by Date: Re: Two threads reading from same file?
- Next by Date: Re: HANDLE Thread Safety
- Previous by thread: Re: WriteFile()
- Next by thread: Re: WriteFile()
- Index(es):
Relevant Pages
|
Loading