Index ¦ Archives ¦ RSS > Tag: history

Linux Top Origins

(I was recently asked about Linux top. Here is my response.)

Back in the second half of 1991, someone posted about a new Unix like operating system. It was an instant hit for those of us lucky enough to be connected to the Internet. At my university's several computer labs we had good access to a variety of systems, especially large numbers of Sun workstations, some Windows/286 PCs, and a big Pyramid system shared by students and faculty.

If you wanted something Unix like on your own PC there wasn't much choice. The front runner was Minix which was very expensive for students. It was also for the 8086 and didn't take advantage of more than 1MB of RAM or memory protection, plus had single threaded filesystem access making that slow too. There were a big set of patches for the 80386, but they weren't officially supported.

Linus started out with some assembly language hosted by his Minix system that explored the 80386 task switching instructions. It didn't take too much more before it could run processes and access the filesystem. It was just for fun. It was simple, effective and just what so many people were looking for with no barriers to participation. Releases were frequent as people scratched their own itches.

One thing the fledgling Linux didn't have is getting a list of running processes. (It also didn't have sound, mice, networking, gui, or a whole bunch of other normal stuff yet so that wasn't a big omission.) You had to press the Scroll Lock key and it would spew some stuff on the console showing the running processes. That wasn't a huge burden since it only supported 63 processes total. You can still see the descendent of the scroll lock diagnostics by using the SysRq key with t for tasks.

It was also very common to download the source for various parts of the system as they frequently changed to keep up to date with system calls and semantics. For example this included bootloaders, compilers, C libraries, text editors etc. You'd want to recompile everything on each Linux kernel release which took a while. And often you'd want to know if something got stuck, or if things really were proceeding.

Branko Lankester released a version of ps that was a quick hack. Instead of adding "proper" support for getting a list of processes, he added an ioctl to the keyboard driver (since all systems had one making it easy to access).

While ps is nice, it only gives you a snapshot of the system and no idea about what is happening over time. I was already familiar with top and wanted that to monitor the system. The existing top had no hope of working on Linux so I wrote one from scratch. It was pretty much the simplest way of wrapping ps so that it sorted the processes, and then output as many would fit on the screen. That is why the documentation always mentions Branko and his ps.

I did add some unique things over the top I had used. You could specify which fields were shown and in which order. There were less than 26 so I used the letters of the alphabet. It could be saved to a $HOME/.toprc so you didn't need to reconfigure each time you ran. The same configuration was preserved for many years by future authors.

I released my top in early 1992. I then had a 6 month work placement where I no longer had access to a machine I could run Linux on. Others then took over top, updating it as Linux matured, exported process information more sensibly, removed some inefficiencies I had coded, all leading up to what you have today. I would be shocked if any of the original code survives. I am still listed in the credits though.

top was developed on an 80386 system running at 20MHz with 4MB of RAM. It had a 100MB hard drive of which 80MB was used for DOS and 20MB was allocated for Linux. I used vi as the text editor, and had to figure out various library usage (eg dealing with the terminal) by reading library source code.

Category: geek – Tags: linux, history

Contact me