Geschrieben von: Jörg Hoppe
Hauptkategorie: Externes
Kategorie: Literatur
Zugriffe: 21680

 

 

lions_book

 

Autor:  Prof. John Lions
Titel: A COMMENTARY ON THE SIXTH EDITION UNIX OPERATING SYSTEM
Verlag: Peer-to-Peer Communications
ISBN: 1-57398-013-7
Sprache: Englisch
Datum: 1977
Seiten: 115 + 118
Bezug: Erhältlich in moderner Print-Version (z.B. bei amazon), oder aus vielen Quellen frei aus dem Netz. Im attachement befindet sich eine schöne TeX-Version als PDF.

Was steht drin?

Bekanntlich wurde das Betriebssystem UNIX V6 von Dennis Ritchie und Ken Thompson im Jahr 1975 auf der PDP-11/40 entwickelt und überwiegend in C geschrieben.

richie-n-thompson-pdp-11


Das zweibändige Werk von John Lions erklärt nun, was die beiden auf dem Bild gerade machen!
Es enthält

  1. den kompletten Sourcecode des Kernels von UNIX V6: (nur) 9000 Programmzeilen.
  2. einen ausführlichen Kommentar zu den Sourcen, nebst einer Darstellung der PDP-11 Architektur und eine Einführung in die Sprache "C".


Dieser Kommentar zu UNIX V6 wurde 1977 zu Schulungszwecken verfasst, die Verbreitung war aber zwischen 1979 und 1996 von AT&T aus lizenzrechtlichen Gründen untersagt. Daher wurde "Lions Book" jahrelang illegal "im Untergrund" vervielfältigt (das Cover der aktuellen Print-Version nimmt darauf humorvoll Bezug) und hat eine ganze Generation von UNIX Hackern beeinflusst.


Siehe unbedingt die Wikipedia-Einträge (deutsch, englisch), so wie den Eintrag über John Lions. "Lions Book" hat es auch ins "Hacker's Dictionary" geschafft und viele Kurse bzw. Vorlesungen über Betriebssystemtechniken nachhaltig geprägt.

Warum soll man es lesen?

 

Es gibt viele Gründe, mal hineinzuschauen:

Aus Wikipedia/amazon-Bewertungen:

Leseprobe:

Einleitung und die Kapitel über die Grundlagen lassen sich gut lesen. Die eigentlichen Kommentare sind ebenfalls locker und verständlich ... sofern der kommentierte C-Code das erlaubt!

Beispielhaft (und vielleicht zur Abschreckung) sei Code und und Kommentar für die "link()"-Betriebssystem-Funktion aufgeführt. Diese erzeugt einen neuen Direktoryeintrag für einen bestehenden File.

Sourcecode:
 

5907 /* link system call
5908  */
5909 link()
5910 {
5911    register *ip, *xp;
5912    extern uchar;
5913
5914    ip = namei(&uchar, 0);
5915    if(ip == NULL)
5916            return;
5917    if(ip->i_nlink >= 127) {
5918            u.u_error = EMLINK;
5919            goto out;
5920    }
5921    if((ip->i_mode&IFMT)==IFDIR && !suser())
5922            goto out;
5923    /*
5924     * ulock to avoid possible hanging in namei
5925     */
5926    ip->i_flag =& ~ILOCK;
5927    u.u_dirp = u.u_arg[1];
5928    xp = namei(&uchar, 1);
5929    if(xp != NULL) {
5930            u.u_error = EEXIST;
5931            iput(xp);
5932    }
5933    if(u.u_error)
5934            goto out;
5935    if(u.u_pdir->i_dev != ip->i_dev) {
5936            iput(u.u_pdir);
5937            u.u_error = EXDEV;
5938            goto out;
5939    }
5940    wdir(ip);
5941    ip->i_nlink++;
5942    ip->i_flag =| IUPD;
5943
5944 out:
5945    iput(ip);
5946 }

Kommentar dazu:

"19.5 link (5909)

 
This procedure implements a system call which enters a new name for an existing file into the directory structure. Arguments to the procedure are the existing and the new names of the file;


5914: Look up the existing file name;
5917: If the file already has 127 different names, quit in disgust;
5921: If the existing file turns out to be a directory, then only the super-user may rename it;
5926: Unlock the existing file "inode". This is locked when the first call on "namei" does an "iget" (7534, 7664).

Under what conditions would the failure to unlock the "inode" here be disastrous? The chances that the existing file would be a directory encountered in the search for the new name would seem slight, if not impossible.
Most probably the relevant circumstance is where the system is attempting to recreate an alternative file name or alias, which already exists;

5927: Search the directory for the second name, with the intention of creating a new entry;
5930: There is an existing file with the second name;
5935: "u.u_pdir" is set as a side effect of the call on "namei" (5928). Check that the directory resides on the same device as the file;
5940: Write a new directory entry (see below);
5941: Increase the "link" count for the file."

Inhalt

Contents
1 Introduction
2 Fundamentals
3 Reading "C" Programs
4 An Overview
5 Two Files
6 Getting Started
7 Processes
8 Process Management
9 Hardware Interrupts and Traps
10 The Assembler "Trap" Routine
11 Clock Interrupts
12 Traps and System Calls
13 Software Interrupts
14 Program Swapping
15 Introduction to Basic I/O
16 The RK Disk Driver
17 Buff er Manipulation
18 File Access and Control
19 File Directories and Directory Files
20 File Systems
21 Pipes
22 Character Oriented Special Files
23 Character Handling
24 Interactive Terminals
24 The DL11/KL11 Terminal Device
25 The File "tty.c"
26 Suggested Exercises

lions_book_commentary.pdf

lions_book_unixv6_source.pdf