Originally Published: Monday, 11 June 2001 Author: Linus Torvalds and David Diamond
Published to: interact_featured_articles/General Page: 1/1 - [Std View]

JUST FOR FUN: The Story of an Accidental Revolutionary

This week Linux.com celebrates the publication of Just for Fun, the new Linus Torvalds biography with this exclusive excerpt. Read in Linus Torvalds own words why he started Linux. Publisher HarperCollins has published a book that is part autobiography and part business philosophy, but mostly the chronicle of a revolution. Join Linux.com all this week for a publication celebration of Just for Fun with a Linux.com Live! Event with co-author David Diamond, plus free book give-aways and much more.

Exclusive excerpt courtesy of HarperCollins Publishers. Used with Permission. All rights reserved.

Don't miss the Linux.com Live Event with author David Diamond on Thursday June 14th, right here on Linux.com

January 2, 1991. It was the first day the stores were open after Christmas and my twenty-first birthday, the two biggest cash-generating days on my calendar.

With my Christmas-and-birthday money in hand, I made this huge economic decision to buy a computer that would cost 18,000 FIM, which was about $3,500. I didn't have that kind of money, so the idea was to put down one third of the cost and buy the computer on credit. Actually, the computer cost 15,000 FM. The rest came from the financing charges that would be paid over three years.

It was at one of these small corner shops, sort of a mom-and-pop computer store, only in this case it was just pop. I didn't care about the manufacturer, so I settled on a no-name, white-box computer. The guy showed you a price list and a smorgasbord of what CPU was available, how much memory, what disk size. I wanted power. I wanted to have 4 megabytes of RAM instead of 2 megabytes. I wanted 33 megahertz. Sure, I could have settled for 16 megahertz, but no, I wanted top of the line.

You told them what you wanted and they would put it together for you. It sounds quaint in this era of the Internet and UPS shipments. You came back three days later to pick it up, but those three days felt like a week. On January 5th I got my dad to help me drive the thing home.

Not only was it no-name, it was also nondescript. It was a basic gray block. I didn't buy this computer because it looked cool. It was a very boring-looking machine with a fourteen-inch screen, the cheapest, most reasonably studly box I could find. Incidentally, by "studly" I mean a powerful computer that a few people owned. I don't intend to make it sound so unappealing-yet-functional, sort of like a Volvo station wagon. But the fact is: I wanted something dependable and with easy access to the upgrades I would inevitably require.

The computer came with a cut-down version of DOS. I wanted to run Minix, the Unix variant, so I ordered it and the operating system took more than a month to make its way to Finland. Oh, you could buy the book on Minix from a computer store, but, since there was so little demand for the operating system itself, you had to order it from the bookstore. The cost was $169 plus taxes, plus conversion factor, plus whatever. I thought it was outrageous at the time. Frankly, I still do. The wasted month felt like about six years. I was even more frustrated by that than I had been during the months I was waiting to buy my PC.

And this was dead-winter. Every time you left your bedroom for the outside world you risked getting knocked onto the snow by old ladies who should have been home making cabbage soup for their families or watching hockey on television while knitting sweaters, not staggering along Mannerheimintie. I basically spent that month playing Prince of Persia on my new computer. When I wasn't doing that, I would read books that helped me understand the computer I had bought.

Minix finally arrived on a Friday afternoon, and I installed it that night. It required feeding sixteen floppy disks into the computer. The entire weekend was devoted to getting accustomed to the new system. I learned what I liked about the operating system -- and, more importantly, what I didn't like. I tried to compensate for its shortcomings by downloading programs that I had gotten used to from the university computer. In all, it took me a month or more to make this my own system.

Andrew Tanenbaum, the professor in Amsterdam who wrote Minix, wanted to keep the operating system as a teaching aid. So it had been crippled on purpose, in bad ways. There were patches to Minix -- improvements, that is -- including a well-known patch made by a hacker in Australia named Bruce Evans, who was the God of Minix 386. His improvement made Minix much more usable on a 386. Before even getting the computer I had been following the Minix newsgroups online, so I knew from the very beginning that I wanted to run his enhanced version. But because of the licensing situation, you had to buy the real version of Minix and then do a lot of work to bootstrap Evans's patches. It was a fairly major thing to do.

There were a number of features that disappointed me with Minix. The biggest letdown was terminal emulation, which was important because it was the program I used to connect to the university computer. I relied upon terminal emulation whenever I wanted to dial up the university's computer to either work on the powerful Unix computer or just go online.

So I began a project to create my own terminal emulation program. I didn't want to do the project under Minix, but instead to do it at the bare hardware level. This terminal emulation project would also be a great opportunity to learn how the 386 hardware worked. As I mentioned, it was winter in Helsinki. I had a studly computer. The most important part of the project was to just figure out what this machine did and have fun with it.

Because I programmed to the bare metal I had to start off from the BIOS, which is the early ROM code that the computer boots into. The BIOS reads either the floppy or the hard disk, and in this case, I had my program on a floppy. The BIOS reads the first sector of the floppy and starts executing it. This was my first PC and I had to learn how all this was done. This all happens in what's called "real mode." But in order to take advantage of the whole CPU and get into 32-bit mode, you have to go into "protected mode." There's a lot of complicated setup you have to do to make this happen.

So to create a terminal emulation program this way, you need to know how the CPU works. In fact, part of the reason I wrote in assembly language was just to learn about the CPU. The other things you need to know are how to write to the screen, how to read keyboard input, how to read and write to the modem. (I hope I'm not losing any of the non-geeks who have steadfastly refused to leap ahead to page 120.)

I wanted to have two independent threads. One thread would read from the modem and then display on the screen. The other thread would read from the keyboard and write out to the modem. And there would be two pipes going both ways. This is called task-switchinig, and a 386 had hardware to support this process. I thought it was a cool idea.

My earliest test program was written to use one thread to write the letter A to the screen. The other thread wrote the letter B. (I know, it sounds unimpressive.) And I programmed this to happen a number of times a second. With the timer interrupt, I wrote it so that the screen would fill with AAAAAAAAAA. Then, all of a sudden, it would switch to BBBBBBBBB. It's a completely useless exercise from any practical standpoint, but it was a good way of showing that my task-switching worked. It took maybe a month to do this because I had to learn everything as I was going along.

So ultimately I was able to change the two threads, the AAAAAAAA and BBBBBBB, so that one read from the modem and wrote to the screen, and the other read from the keyboard and wrote to the modem. I had my own terminal emulation program.

When I wanted to read news, I would put in my floppy and reboot the machine, and I would read news from the university computer using my program. If I wanted to make changes to improve the terminal emulation package, I would boot into Minix and use it for programming.

And I was very proud of it.

My sister Sara knew about my great personal accomplishment. I showed it to her and she looked at the screens of AAAAAA`s and BBBBBBBBs for about five seconds; then she said "Good" and went away, unimpressed. I realized it didn't look like much. It's completely impossible to explain to somebody else that, while something may not look like much, a lot is going on in the background. It's about as impressive as showing somebody a stretch of road you've just filled in with tar. Probably the only other person who saw it was Lars, the other Swedish-speaking computer-acience major who started the same year I did.

It was March, maybe April, and if the snow was turning to slush on Petersgatan. I didn't know-or much care. I was spending most of my time in a bathrobe, huddled over my unattractive new computer, with thick black window shades shielding me from the sunlight, not to mention the outside world. I was eeking out the monthly payments for my PC, which was scheduled to be paid off in three years. What I didn't know was that I would only be sending in payments for another year. By then, I would have written Linux, which would be seen by many more people than just Sara and Lars. By that time, Peter Anvin, who works with me now at Transmeta, would have started a collection on the Internet to get my computer paid off.

Everybody knew I wasn't making any money on Linux. People just started saying, Let's start a collection to pay off Linus's computer.

It was wonderful.

I had absolutely no money. I always felt it was important to not have asked for money or begged for money, but the fact that it was simply given to me was ... I'm getting choked up.

That's how Linux got started. With my test programs turning into a terminal emulation package.

From JUST FOR FUN: The Story of an Accidental Revolutionary by Linus Torvalds and David Diamond. 2001 HarperCollins Publishers. Used by permission.