The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Mary Ann Horton <mah@mhorton.net>
To: tuhs@tuhs.org
Subject: [TUHS] Re: vi in cooked mode?
Date: Fri, 4 Nov 2022 15:13:17 -0700	[thread overview]
Message-ID: <53541ab4-6cec-59b9-075b-bfb9bc949f94@mhorton.net> (raw)
In-Reply-To: <7b249e68-de74-2c81-32b0-18ecb74a85ec@aueb.gr>

[-- Attachment #1: Type: text/plain, Size: 2948 bytes --]

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.

Thanks,

/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!

	<https://www.amazon.com/Trailblazer-Lighting-Transgender-Equality-Corporate-ebook/dp/B0B8F2BR9B>

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

[-- Attachment #2: Type: text/html, Size: 4699 bytes --]

  parent reply	other threads:[~2022-11-04 22:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 19:43 [TUHS] " Diomidis Spinellis
2022-11-03 20:26 ` [TUHS] " Clem Cole
2022-11-03 20:27   ` Clem Cole
2022-11-03 20:55   ` Warner Losh
2022-11-03 21:34     ` Clem Cole
2022-11-03 22:28       ` Warner Losh
2022-11-03 22:52         ` Ron Natalie
2022-11-04  6:43       ` Lars Brinkhoff
2022-11-04 15:18         ` Dan Cross
2022-11-04 17:54           ` Lars Brinkhoff
2022-11-04 18:33   ` Ron Natalie
2022-11-04 23:42     ` Theodore Ts'o
2022-11-05  0:45       ` Dave Horsfall
2022-11-05  1:02         ` Larry McVoy
2022-11-05  1:25           ` Bakul Shah
2022-11-05  1:40             ` Larry McVoy
2022-11-05  2:31               ` Rich Salz
2022-11-05  3:44                 ` Bakul Shah
2022-11-05 18:34               ` Theodore Ts'o
2022-11-05  9:29           ` Otto Moerbeek via TUHS
2022-11-04 22:13 ` Mary Ann Horton [this message]
2022-11-03 20:17 Noel Chiappa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53541ab4-6cec-59b9-075b-bfb9bc949f94@mhorton.net \
    --to=mah@mhorton.net \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).