Two consoles, one machine
Watch / twocons
Filmed on the Apple IIe 80-column display. The same session on the Videx UltraTerm: same keys, same text.
The Videx UltraTerm was an 80-column video card for the Apple IIe, with its own video memory and character generator, real hardware scrolling and more screen modes than the IIe's own 80 columns. This demo runs on either display; the UltraTerm film shows the original Videx UltraTerm, emulated.
A job runs on console 1, a loop that appends a tick to a log every five seconds. chvt 2 moves to a second console with a shell of its own, where vi is used and quit. chvt 1 comes back to the same screen, and the log shows the job kept ticking the whole time.
What it types
The script it writes, line by line:
for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo tick $i >> log sleep 5 done
Everything it types, in order. A line starting with $ is a command at the shell, RET included; keys lines are single keystrokes to a program (RET, ESC and the control keys are named).
$ cd /tmp $ cat > tick keys: <^D> $ sh tick > /dev/null & $ chvt 2 $ cd /tmp $ vi note keys: iwritten on console two<ESC>:wq<RET> $ cat note $ cat log $ chvt 1 $ kill %1 $ cat log
Between steps it presses ^L to clear the screen.
What the captions say
- Two consoles. First, a job on this one:
- a loop that ticks into a log file every five seconds.
- chvt 2: a second console, with a shell of its own.
- Use vi over here.
- Is the job still ticking? Look at the log from here.
- chvt 1: back where the job is. Same screen, exactly.
- Stop the job, and read the log again.
- The job ticked on the whole time. Two consoles, one machine.
- V6's process switch is marked: "You are not expected to understand this."
- Here the switch is a write to $C073 and a few soft switches.
The gate that proves it
This film is made by site/demos/twocons.py. Run as assertions, the
same file is make check-demo-twocons, and it runs with the rest of the tests. It requires that console 1’s screen, snapshotted before chvt 2, comes back exactly, followed by the chvt 2 line and a fresh prompt; that console 2 starts fresh and its file is written; that the log read on console 2 and the log read on console 1 after the job is killed are both ticks one to k in order, with at least two more ticks in the second, so the job ran while console 2 was in use; and that the loop had not finished. A variant that stops the job for the whole interval was run and is red. With sleep replaced by a copy of true the demo fails at the Terminated notice; with chvt replaced by true it fails at "console 2 is a fresh, blank screen with a prompt".
Transcript
The screen at every checkpoint the test checks, as the recorder saved it:
== host: console 1 sits at a prompt (t=28.3 s) $ cd /tmp $ cat > tick for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo tick $i >> log sleep 5 done $ sh tick > /dev/null & [1] 6 $ == console 2 is a fresh, blank screen with a prompt (t=36.6 s) $ == console 2 wrote its file (t=54.1 s) $ cd /tmp $ vi note $ cat note written on console two $ == cat log on console 2 (t=62.9 s) $ cd /tmp $ vi note $ cat note written on console two $ cat log tick 1 tick 2 tick 3 tick 4 tick 5 tick 6 tick 7 $ == the log is ticks 1..k, in order, k at least 1 (t=62.9 s) $ cd /tmp $ vi note $ cat note written on console two $ cat log tick 1 tick 2 tick 3 tick 4 tick 5 tick 6 tick 7 $ == console 1 is back: its rows as left, then chvt 2 and a fresh prompt (t=72.0 s) $ cd /tmp $ cat > tick for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo tick $i >> log sleep 5 done $ sh tick > /dev/null & [1] 6 $ chvt 2 $ == the shell reports the job Terminated (t=80.1 s) $ cd /tmp $ cat > tick for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo tick $i >> log sleep 5 done $ sh tick > /dev/null & [1] 6 $ chvt 2 $ kill %1 [1]+ Terminated sh tick $ == cat log on console 1 (t=84.9 s) $ cd /tmp $ cat > tick for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo tick $i >> log sleep 5 done $ sh tick > /dev/null & [1] 6 $ chvt 2 $ kill %1 [1]+ Terminated sh tick $ cat log tick 1 tick 2 tick 3 tick 4 tick 5 tick 6 tick 7 tick 8 tick 9 tick 10 $ == at least 2 more ticks landed after the first read, while console 2 was in use and the glass was switching back (t=84.9 s) $ cd /tmp $ cat > tick for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo tick $i >> log sleep 5 done $ sh tick > /dev/null & [1] 6 $ chvt 2 $ kill %1 [1]+ Terminated sh tick $ cat log tick 1 tick 2 tick 3 tick 4 tick 5 tick 6 tick 7 tick 8 tick 9 tick 10 $ == the job was still running (under 12 ticks) (t=84.9 s) $ cd /tmp $ cat > tick for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo tick $i >> log sleep 5 done $ sh tick > /dev/null & [1] 6 $ chvt 2 $ kill %1 [1]+ Terminated sh tick $ cat log tick 1 tick 2 tick 3 tick 4 tick 5 tick 6 tick 7 tick 8 tick 9 tick 10 $