Subject: kern/28678: tty-driver failes to handle VMIN and VTIME in select call correctly
To: None <email@example.com, firstname.lastname@example.org,>
From: Wolfgang Stukenbrock <email@example.com>
Date: 12/16/2004 12:03:00
>Synopsis: tty-driver failes to handle VMIN and VTIME in select call correctly
>Arrival-Date: Thu Dec 16 12:03:00 +0000 2004
>Originator: Wolfgang Stukenbrock
>Release: NetBSD 2.0_RC5
Dr. Nagler & Company GmbH
System: NetBSD s012 2.0_RC5 NetBSD 2.0_RC5 (S012) #6: Tue Nov 30 11:38:39 CET 2004 wgstuken@s012:/export/netbsd-2.0rc4/src/sys/arch/i386/compile/S012 i386
If VMIN and VTIME are both set set in the tty-flags, the select() call will fail to return until VMIN chars are recieved.
The problem seems to be, that the check is done like "if (cur-anz-char < VMIN && VTIME != 0) return no-data-available" in ttnread().
If there are already some char present and the timeout has elapsed, the chars are not returned .
The current implementation also failed to return from the select if an additional char arrives - the select() will not participate from the
timeout of the arriving char. It will return only if at least VMIN char are present.
This problem is also present in the 2.0 release. The current kernel has not been tested, but the ttnread() is the same there, so the
problem should also be present there.
Either write a short program with select(), and read() or just use the program screen (see pkgsrc) on a tty-line.
e.g. call screen and then type "^a:screen /dev/dtya". Connect something to ttya and send some chars to this line.
The default setting used by screen (and/or the system) is VMIN 100 VTIME 1.
Screen will display the input if at least 100 chars are recieved. VMIN and VTIME may be modified with stty from another window in order to test
some different configurations.
A workaround is to set VMIN 1 and VTIME 0, but this will lead to may useless context switches and a wast CPU-power, that may overload the machine.
To fix this problem, the timeout after recieving a char has to take care about select() (or poll()) calls.
Some parts of the tty-driver (sys/kern/tty.c) has to redesigned.