Systems Performance 2nd Ed.



BPF Performance Tools book

Recent posts:
Blog index
About
RSS

Control T for TENEX

05 Oct 2013

I originally posted this at http://dtrace.org/blogs/brendan/2013/10-05/control-t-for-tenex.

I recently wrote about FreeBSD, and while on that OS I ran "sleep 5" then hit Control-T:

freebsd10$ sleep 5
load: 0.67  cmd: sleep 90628 [nanslp] 0.92r 0.00u 0.00s 0% 1464k
sleep: about 4 second(s) left out of the original 5

Wow! This prints the "load:" and "sleep:" status lines, showing information about the process. This works with other commands too, like dd(1). The "load:" line comes from the kernel, and extra lines are up to the process. As a performance engineer, I find it pretty interesting.

This magic works via detection of a STATUS control character, Control-T, by the kernel tty driver, which then prints the load line via tty_info() on FreeBSD or ttyinfo_locked() on Mac OS X. It also sends a SIGINFO to the process, so it can run its own routine. See STATUS in the termios(4) man page.

FreeBSD has the most detailed "load:" line, beginning with the 1 minute load average, then "cmd:" and the process name and PID of the most interesting process to report on (as decided by proc_compare(), based on recentness and CPU usage), state of that process, the real, user, and system times, percent CPU, and finally its RSS (resident set size).

Mac OS X has similar details, ending with user and sys time. This sleep doesn't do the "sleep:" line.

brendan@macbook:~> sleep 5
load: 1.05  cmd: sleep 426 waiting 0.00u 0.00s

I wish this was in other kernels as well, like illumos and Linux. While they may not support Control-T and "load:", their processes may still have a status signal. For example, GNU dd(1) prints status on a SIGUSR1, which you can send using kill(1) from another terminal. And in another terminal, you can dig the "load:" line details out using other commands. Control-T just makes it easier.

Origins

Where did Control-T come from? In a Mac OS X forum, a 2012 post makes the comment: "Not sure if this was available before 10.7" (2011). I don't know if it's new in Mac OS X, but it certainly isn't new.

I learned about it while researching a book on Systems Performance, and reading the following in a 1972 paper on the TENEX operating system [Bobrow 72]:

Control-C was familiar, but Control-T? Having mostly used Solaris- and Linux-based systems, I wasn't familiar with Control-T. Could it still be around?

Feeling a little foolish, I opened a terminal on my macbook and typed Control-T. Nothing. Then I tried while a command was running, and was stunned to see the status line printed.

Did TENEX, circa 1969-72, include this first? Probably. I haven't found an earlier example, and the description in [Bobrow 72] sounds like it's new in TENEX. I did check some docs for CTSS (1961+) and Multics (late 1960s), and didn't find it. RSTS (1970) could be modified to support it. (Coincidentally, two days ago I was teased with a photo of RSTS from monktoberfest; original probably from here.)

I did find Control-T in a TOPS-10 (1967+) simulator, although I suspect this is a later version:

.Day: 14.86 Run: 0.00 Rd:0 Wr:0 OPSER 3+6P Ctx:1  ^C  PC:401336
Input wait for CTY:

Here's TOPS-20 (1969+), from the panda simulator, which TENEX became:

@ 16:01:04 Used 0:00:00.0 in 0:00:03, Load   0.25

Is the T in Control-T for TENEX? I don't know. But it is for TENEX in tcsh. :-)