This procedure is called via “klwrite” (8067) when output is to be sent to the terminal.
If the terminal is inactive, do nothing;
Loop for each character to be transmitted ...
While there are still an adequate number of characters queued for transmission to the terminal ...
call “ttstart” just in case it is time to send another character to the terminal;
Setting the “ASLEEP” flag here (also in
“wflushtty” (8224)) is rather pointless since is is never interrogated and never reset until the file is closed;
Go to sleep. In the meanwhile the interrupt handler will be draining characters from the output queue and sending them down the line to the terminal;
Call “ttyoutput” to insert the character in the output queue and arrange to have it transmitted;
Call “ttstart” again, for luck.