From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds) Subject: Re: Termios question: Semantics of VMIN/VTIME on Linux/SunOS ? Date: 21 Jul 1992 18:39:46 GMT
In article <arumble.711729320@extro.ucc.su.OZ.AU> arumble@extro.ucc.su.OZ.AU (Anthony Rumble) writes:
>torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds) writes:
>
>>The way linux does this is (a) wait for at least one character (VMIN > 0
>>and VTIME > 0), (b) read as many characters as possible, with a timeout
>>of max 0.10 seconds between any of the first 5 characters. Thus the
>>read can return:
>
>Errm.. Question.. Can you think of a possible USE of this?
>It dosen't seem quite logical to do it this way, it would be
>much more usefull to return on either 5 chars OR timeout regardless
>on the first character..
Ours is not to wonder why... Frankly, the above is what the SunOS
man-pages seem to say, and as that's the only info I have on the
subject, that's how linux does things. SunOS seems to be pretty close
to posix, and following the man-pages has so far worked pretty well. I
don't know the reasons for the POSIX behaviour, and the man-pages might
be wrong (and I might even have misunderstood), but I'd rather be
conforming to weird standards than have problems porting programs later
on when they expect that behaviour.
As I already mentioned, I'm very open to changing the behaviour: but I
need to have actual "chapter and verse" from the posix standard before I
start changing things. The current behaviour works with a lot of
programs, and conforms to the only docs I have, so I really need some
strong arguments to change it.
The VMIN/VTIME arguments are currently understood by linux as (note:
this info is only used when not in canonical mode):
VTIME = 0 VMIN = 0
Instant return, reading as many characters as possible from the
terminal.
VTIME = 0 VMIN > 0
No timeout, and we return once VMIN characters have been read.
We still might return before that in case of signals etc, and if
there are more characters available, they will be read.
VTIME > 0 VMIN = 0
This is a simple timeout-read: we wait VTIME*0.1 seconds or
until at least one character has arrived. The read will not
take more than VTIME*0.1 sec, not counting scheduling etc
overhead.
VTIME > 0 VMIN > 0
VTIME*0.1 seconds is an inter-character timer that is started
after the first character is received, and restarted at each new
character until VMIN characters have been received. The read()
returns at least one character (again not counting signals), as
the timer comes into play only /between/ characters.
All the above have an upper limit of the given buffer-size: none have a
true lower limit (as they can return less than VMIN characters). VMIN
isn't meant to be used for packet-sized communication: it's just used to
help decide when/how to accept timeouts. Can somebody please confirm if
the above is actually the correct behaviour?
Linus