Book Read Free

Just for Fun : The Story of an Accidental Revolutionary

Page 9

by Linus Benedict Torvalds


  Okay, this is the earliest public evidence that a geek in Finland was willing to test the bounds of his computing skill. The POSIX standards are the lengthy rules for each of the hundreds of system calls in Unix—what you need in order to get the computer to perform its operations, starting with Read, Write, Open, Close. POSIX is a Unix-standards body, an organization comprised of representatives from companies that want to agree on common guidelines. Standards are important in order for programmers to be able to write applications to the operating system and have them run on more than one version. The system calls—particularly the important ones—would give me a list of the various functions needed for an operating system. I would then write the code to make each of those functions happen in my own way. By writing to the POSIX standards, my code would be usable by others.

  I didn’t know at the time that I could have bought those rules in hard-copy form directly from POSIX, but it wouldn’t have mattered anyway. Even if I could have afforded the cost, it always took a long time to get things shipped to Finland. Hence my appeal for a version that I could download for free from an ftp site.

  Nobody responded with a source for the POSIX standards, so I went to Plan B. I tracked down manuals for the Sun Microsystems version of Unix at the university, which was operating a Sun server. The manuals contained a basic version of the system calls that was good enough to help me get by. It was possible to look at the manual pages to see what the system call was supposed to do, and then set about the task of implementing it from there. The manual pages didn’t say how to do it, they just said what the end results were. I also gleaned some of the system calls from Andrew Tanenbaum’s book and a few others. Eventually somebody sent me the thick volumes containing the POSIX standards.

  But my email message did not go unnoticed. Any knowledgeable person (and only knowledgeable people would be reading the Minix site) could tell that my project would have to be an operating system. Why else would I want the POSIX rules? The message aroused the curiosity of Ari Lemke, a teaching assistant at Helsinki University of Technology (where I would have studied had I not been so interested in studying theory). Ari sent me a nice reply, offering to make a subdirectory on the university’s ftp site available for when I would be ready to post my operating system for anyone who might be interested in downloading it.

  VII

  Ari Lemke must have been quite an optimist. He created the subdirectory (ftp.funet.fi) long before I had something I wanted to release. I had the password, and everything was set up for me to just log in and upload stuff to it. But it took about four months for me to feel I had anything I was willing to share with the world, or at least with Ari and the few other operating system freaks with whom I had been exchanging email.

  My original goal was to create an operating system that I could eventually use as a replacement for Minix. It didn’t have to do more than Minix, but it had to do the things in Minix that I cared about, and some other things I cared about, too. For example, not only was the Minix terminal emulation bad, but there was no way of performing the job-control function—putting a program in the background while you’re not using it. And memory management was done very simplistically, as it still is in the Mac OS, incidentally.

  The way you create an operating system is to find out what the system calls are supposed to do, and then write your own program to implement those system calls in your own way. Generally speaking, there are a couple of hundred system calls. Some of them can represent multiple functions. Others are quite simple. Some of the more fundamental system calls are really complicated and depend on a great deal of infrastructure being there. Take the system calls of “Write” and “Read.” You need to create a disk driver in order to write something to disk or read something from disk. Take “Open.” You have to create the entire file system layer that parses the names and figures out where on the disk everything is. It took months just to write the “Open” system call. But once it was in place, the same code could be used for other functions.

  That’s how the early development was done. I was reading the standards from either the Sun OS manual or various books, just picking off system calls one by one and trying to make something that worked. It was really frustrating.

  The reason: Because nothing is happening, you can’t really see any progress. You can make small test programs that test whatever it is you just added. But that doesn’t really accomplish anything. After awhile you get to the point where, instead of just reading through a list of system calls, you give up on that approach. It’s getting complete enough that you want to run a real program. The first program you have to run is a shell because, without a shell, it’s pretty hard to run anything else. And besides, the shell itself contains many of the system calls you will need. Get it running and you will be able to print out a running list of the system calls you haven’t implemented.

  In Unix, the shell is kind of the mother of all programs. It’s there to start up other binaries. (A binary is a program in the 1’s and 0’s that a machine reads. Whenever you write a program in a computer language, you then compile the source code and it becomes a binary.) The shell allows you to log on in the first place. Okay, traditionally in a real Unix system the first program you run is called init, but init really needs a lot of infrastructure in order to work. It’s kind of a controller for what goes on. But when you don’t really have anything that works, there isn’t any point to having init.

  So instead of starting init, the first thing my kernel did was to start the shell. I had implemented about twenty-five system calls and, as I mentioned, this was the first real program I was trying to run. The shell wasn’t something I had written myself. I had downloaded onto a disk a clone of the Bourne Shell, which was one of the original Unix shells. It was available over the Internet as free software, and its name was derived from a bad pun. The guy who wrote the original was named Bourne, so was the clone Bourne-Again Shell—commonly referred to as bash.

  When you try and load a real program from disk, invariably there’s a bug in the disk driver or in the loader because it doesn’t understand what it’s reading in. So it prints out a running commentary on what it’s doing. It’s important because that’s how you can find out what is going wrong.

  I got to the point where my program was loading the shell and generating a printout of every system call that the shell contained that I hadn’t yet implemented. I booted, ran the shell, and it would spit back something like: “system call 512 is not done.” Day and night I was looking at printouts of system calls, trying to determine which ones I was doing wrong. But this was much more fun than taking a list of calls and just implementing them. You got to see progress being made.

  It was late August or early September when I finally got the shell working. From that point, things got a lot easier.

  This was a big deal.

  When I got the shell working, I was pretty much immediately able to compile a few other programs. The shell was more complicated than the cp (copy) program, for example, or the 1’s (for getting a directory listing) program. Everything you needed had to be there for the shell already, so once the shell was working it went from close to zero to 100 in nothing flat, because all these pieces had been in place. At some point there was enough in place that I experienced a Let There Be Light moment, because until then, nothing had really worked.

  Yes, I felt a great sense of satisfaction. I think that was particularly important because I hadn’t been doing anything that summer except working on the computer. This is not an exaggeration. The April through August period is pretty much the best time of the year in Finland. Folks are sailing in the archipelago, sunning themselves on beaches, sitting in their summer-cottage saunas. But I rarely even knew if it was day or night, weekend or weekday. Those thick black curtains blocked out the near round-the-clock sunshine, and the world. Some days—nights?—I’d roll out of bed directly into the chair at my computer, less than two feet away. Apparently my dad was bugging my mom to make me get a su
mmer job. But she didn’t mind: I wasn’t bothering her. Sara was a bit annoyed that the phone lines were always tied up when I went online. She could probably write that sentence with a little less diplomacy. It’s not an exaggeration to say that I had virtually no contact with the world outside my computer. Okay, maybe once a week a friend would knock on my window and if I wasn’t scrolling through important code I would invite him in. (It was always a him—remember, this was before geeks were considered cool.) We would drink tea and maybe watch an hour of MTV in the tiny kitchen. Now that I think of it, yes, I do recall going out for an occasional beer or for some snooker after having my window pounded by someone like Juoko (I call him “Avuton,” which means “he who slays dragons,” but that’s another story). But, in all honesty, nothing else was going on in my life at the time.

  And I didn’t feel the least bit like some pathetic, paleskinned, propeller-head loser. The shell was operational, which meant that I had actually built the foundation of a working operating system. And I was having fun.

  With the shell working, I started testing its built-in programs. Then I compiled enough new programs to actually do something. I was compiling everything in Minix, but I moved the shell over to a special partition that I had created for the new operating system. Privately I called it Linux.

  Honest: I didn’t want to ever release it under the name Linux because it was too egotistical. What was the name I reserved for any eventual release? Freax. (Get it? Freaks with the requisite X.) In fact, some of the early make files—the files that describe how to compile the sources—included the word “Freax” for about half a year. But it really didn’t matter. At that point I didn’t need a name for it because I wasn’t releasing it to anybody.

  VIII

  From: torvalds@klaava.Helsinki.Fi (Linus Benedict Torvalds)

  To: Newsgroups: comp.os.inix

  Subject: What would you like to see most in minix? Summary: small poll for my new operating system Message-ID:

  <1991Aug25.205708.9541@klaava.Helsinki.Fi>

  Hello everybody out there using minix-I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386 (486) AT clones. This has been brewing since April, and is starting to get ready. I’d like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) among other things).

  I’ve currently ported bash (1.08) and gcc (1.40), and things seem to work. This implies that I’ll get something practical within a few months, and I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise I’ll implement them:-)

  Linus (torvalds@kruuna.helsinki.fi)

  PS. Yes-it’s free of any minix code, and it has a multithreaded fs. It is NOT portable (uses 386 task switching etc.), and it probably never will support anything other than AT-harddisks, as that’s all I have:-(.

  The most hard-core operating system enthusiasts among the Minix crowd felt a spark. Not many suggestions about Minix features came my way, but there were other inquiries.

  >Tell us more! Does it need a MMU?

  Answer: Yes

  >How much of it is in C? What difficulties will there be in porting? Nobody will believe you about non-portability;-), and I for one would like to port it to my Amiga.

  Answer: It’s mostly in C, but most people wouldn’t call what I write C. It uses every conceivable feature of the 386 I could find, as it was also a project to teach me about the 386. Some of my “C” files are almost as much assembler as C.

  As already mentioned, it uses an MMU, for both paging (not to disk yet) and segmentation. It’s the segmentation that makes it REALLY 386-dependent (every task has a 64Mb segment for code & data-max 64 tasks in 4Gb. Anybody who needs more than 64Mb/task-tough cookies).

  And I even got a few folks offering to be beta testers.

  In the end, it wasn’t much of a decision to post it. That was how I was accustomed to exchanging programs. So the only real decision was, at what point am I comfortable to dare show this off to people? Or, phrased more accurately: When is it good enough that I won’t have to be ashamed of it?

  What I ultimately wanted was to have a compiler and a real environment so that you could create programs in Linux itself, without having to use Minix. But I felt so proud when the gnu shell worked that I was ready to let the world see. Also, I wanted feedback.

  By the time the shell worked, I had a few rudimentary binaries I’d compiled for the operating system. You really couldn’t do anything, but you could see that it was something resembling Unix. In fact, it worked like a very crippled Unix.

  So I just decided I would make it available. I wouldn’t tell anybody publicly. Instead, I just informed a handful of people by private email, probably between five and ten people in all, that I had uploaded it to the ftp site. Among them were Bruce Evans of Minix fame and Ari Lemke. I uploaded the sources to Linux itself and a few binaries so that you could start something. I told people what they needed to do in order to try and run this thing. They still had to have Minix installed—the 386 version—and they still had to have the GCC compiler. In fact they had to have my version of GCC, so I made that available, too.

  There’s a protocol for numbering releases. It’s psychological. When you think a version is truly ready to be released, you number it version 1.0. But before that, you number the earlier versions to indicate how much work you need to accomplish before getting to 1.0. With that in mind, the operating system I posted to the ftp site was numbered version 0.01. That tells everybody it’s not ready for much.

  And yes, I remember the date: September 17, 1991.

  I don’t think more than one or two people ever checked it out. They had to go to the trouble of installing the special compiler, getting a clean partition so they could use that to boot, compiling my kernel, and then running just the shell. Running the shell was basically all you could do. You could print out the sources, which amounted to just 10,000 lines—that’s less than 100 pages of paper if you printed with small font. (Now it’s something on the order of 10 million lines.)

  One of the main reasons I distributed the operating system was to prove that it wasn’t all just hot air, that I had actually done something. On the Internet, talk is cheap. Regardless of what you do, whether it be operating systems or sex, too many people are just faking it in cyberspace. So it’s nice, after talking to a lot of people about building an operating system, to be able to say, “See, I actually got something done. I wasn’t stringing you along. Here’s what I’ve been doing….”

  And Ari Lemke, who insured that it made its way to the ftp site, hated the name Freax. He preferred the other working name I was using—Linux—and named my posting: pub/OS/Linux. I admit that I didn’t put up much of a fight. But it was his doing. So I can honestly say I wasn’t egotistical, or half-honestly say I wasn’t egotistical. But I thought, okay, that’s a good name, and I can always blame somebody else for it, which I’m doing now.

  As I mentioned, my operating system really wasn’t very useful. For one thing, it would crash very easily if you filled up memory or if you did anything nasty. Even if you weren’t doing anything nasty, the operating system would crash if you kept it running for any length of time. But it wasn’t meant to be run at that stage. It was meant to be looked at. Yes, and admired.

  So it wasn’t intended to be anything but a specialty for the few people who were interested in creating new operating systems. Very technical people—and even within technical people, a special interest group.

  Their reaction was invariably positive, but positive in a kind of “It would be nice if it could also do this” kind of sense, or “It looks cool but it really doesn’t work on my computer at all.”

  I remember one email whose writer said he really liked my operating system, and he went on for at least one paragraph to tell me how nice it was. Then he explained that it had just eaten his hard disk, and that my dis
k driver was flaky or something. He had lost all the work he had done, but he was still very positive. It was fun to read that kind of email. It was a bug report about something that screwed him up.

  That was just the sort of feedback I was looking for. I fixed some bugs, like the one that caused it to lock up when it ran out of memory. And I made the big step of porting the GCC compiler to the operating system, so I could compile small programs. That meant users wouldn’t need to load my GCC compiler before running the operating system.

  IX

  Do you pine for the days when men were men and wrote their own device drivers?

  —announcement of the posting of Linux version 0.02

  Early October saw the release of version 0.02, which included some fixed bugs and a few additional programs. The following month I released version 0.03.

  I probably would have stopped by the end of 1991. I had done a lot of things I thought were interesting. Everything didn’t really work perfectly, but in a software kind of world I find that once you solve the fundamental problems of a project, it’s easy to lose interest. And that’s what was happening to me. Trying to debug software is not very engaging. Then two things happened to keep me going. First, I destroyed my Minix partition by mistake. Second, people kept sending me feedback.

  Back then I was booting into Linux but used Minix as the main development environment. Most of what I was doing under Linux was reading email and news from the university’s computer via the terminal emulator I had written. The university computer was constantly busy, so I had written a program that auto-dialed into it. But in December, I mistakenly auto-dialed my hard disk instead of my modem. I was trying to auto-dial devtty1, which is the serial line. But by mistake I auto-dialed devhda1, which is the hard disk device. The end result was that I inadvertently overwrote some of the most critical parts of the of the partition where I had Minix. Yes, that meant I couldn’t boot Minix anymore.

 

‹ Prev