[TUHS] vi in cooked mode?

Mary Ann Horton mah at mhorton.net
Sat Nov 5 08:13:17 AEST 2022

I don't think vi would work correctly in cooked mode. It has to redraw 
(some of) the screen, inserting a character on each keystroke, and 
repainting the rest of the line.

As Clem points out, in V6 it used raw, in V7 it used cbreak, which is 
"half cooked" and allows interrupts.

It certainly affected performance when lots of students were using it, 
especially if they all had their own copies of the binary, which was 
typical on non-BSD systems. What really helped there was ensuring that 
the official vi binary was in /usr/ucb (or another standard directory) 
so that only one copy of the instruction space would be in memory, 
shared among all the users.

Bell Labs, which typically ran internal versions of UNIX that didn't 
have vi, created the exptools package with most of the Berkeley tools 
and certain others, such as Montgomery's EMACS. This was partly to 
address the performance issue, and to get people to stop installing 
their own personal copies of everything.


/Mary Ann Horton/ (she/her/ma'am)
maryannhorton.com <https://maryannhorton.com>

"This is a great book" - Monica Helms

"Brave and Important" - Laura L. Engel

       Available on Amazon and bn.com!


On 11/3/22 12:43, Diomidis Spinellis wrote:
> I remember being told back in the 1980s that vi would set the terminal 
> to "cooked mode" when vi was in "insert mode", so as to reduce 
> expensive context switching for each character typed.  Only vi's 
> "command mode" would set the terminal to "raw mode" so as to provide 
> immediate feedback on each (command) character typed. This would be a 
> clever system performance optimization, and would also explain 
> designing vi around distinct insert and command modes.
> However, I can't find such evidence even as far back as BSD 1.  It 
> seems that in insert mode ESC was processed like any other character.
> https://github.com/dspinellis/unix-history-repo/blob/BSD-1-Snapshot-Development/ex-1.1/ex_vops.c#L507 
> Cooked mode was only entered when scrolling in order to receive 
> interrupts.
> https://github.com/dspinellis/unix-history-repo/blob/BSD-1-Snapshot-Development/ex-1.1/ex_vadjust.c#L180 
> Also, for this scheme to work ESC would need to be mapped to an 
> interrupt key, so as to allow exiting the cooked mode through the 
> corresponding signal handler.  Again, grepping for ESC, did not show 
> me any such code.
> I also remember being told that this optimization was what allowed 
> twenty students to concurrently perform interactive editing on a VAX 
> 11/780 (running 4.2BSD and then 4.3BSD), and that Emacs was not 
> provided to students because it was always operating in raw mode.
> Was I misled?  Was there perhaps a hacked version of vi that worked in 
> this way?
> -Diomidis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20221104/522f77d5/attachment.htm>

More information about the TUHS mailing list