Operating Systems
2000-01 Fall
M 5:00-6:50
Ciww 109

Allan Gottlieb
gottlieb@nyu.edu
http://allan.ultra.nyu.edu/~gottlieb
715 Broadway, Room 1001
212-998-3344
609-951-2707
email is best


======== START LECTURE #1 ========

Administrivia

Web Pages

There is a web page for the course. You can find it from my home page.

Textbook

Text is Tanenbaum, "Modern Operating Systems".

A Grade of ``Incomplete''

It is university policy that a student's request for an incomplete be granted only in exceptional circumstances and only if applied for in advance. Of course the application must be before the final exam.

Computer Accounts and Mailman mailing list

Homework and Labs

I make a distinction between homework and labs.

Labs are

Homeworks are

Upper left board for assignments and announcements.

Interlude on Linkers

Originally called linkage editors by IBM.

This is an example of a utility program included with an operating system distribution. Like a compiler, it is not part of the operating system per se, i.e. it does not run in supervisor mode. Unlike a compiler it is OS dependent (what object/load file format is used) and is not (normally) language dependent.

What does a Linker Do?

Link of course.

When the assembler has finished it produces an object module that is almost runnable. There are two primary problems that must be solved for the object module to be runnable. Both are involved with linking (that word, again) together multiple object modules.

  1. Relocating relative addresses.


  2. Resolving external references.


The output of a linker is called a load module because it is now ready to be loaded and run.

To see how a linker works lets consider the following example, which is the first dataset from lab #1. The description in lab1 is more detailed.

The target machine is word addressable and has a memory of 1000 words, each consisting of 4 decimal digits. The first (leftmost) digit is the opcode and the remaining three digits form an address.

Each object module contains three parts, a definition list, a use list, and the program text itself. Each definition is a pair (sym, loc). Each use is a pair (sym, loc). The address in loc points to the next use or is 999 to end the chain.

For those text entries that do not form part of a use chain a fifth (leftmost) digit is added. If it is 8, the address in the word is relocatable. If it is 0 (and hence omitted), the address is absolute.

Sample input
1 xy 2
1 z 4
5 81234 5678 2999 88888 7002
0
1 z 3
6 88888 1999 1001 3002 81002 1234
0
1 z 1
2 81234 4999
1 z 2
1 xy 2
3 8000 1999 2001

I will illustrate a two-pass approach: The first pass simply produces the symbol table giving the values for xy and z (2 and 15 respectively). The second pass does the real work (using the values in the symbol table).

It is faster (less I/O) to do a one pass approach, but is harder since you need ``fix-up code'' whenever a use occurs in a module that precedes the module with the definition.

xy=2
z=15

+0
0:      81234           1234+0=1234
1:       5678           5678
2: xy:   2999   ->z     2015
3:      88888           8888+0=8888
4: ->z   7002           7015
+5
0       88888           8888+5=8893
1        1999   ->z     1015
2        1001   ->z     1015
3 ->z    3002           3015
4       81002           1002+5=1007
5        1234           1234
+11
0       81234           1245
1 ->z    4999           4015
+13
0        8000           8000
1        1999   ->xy    1002    
2 z:->xy 2001           2002

The linker on unix is mistakenly called ld (for loader), which is unfortunate since it links but does not load.

Lab #1 Implement a linker. The specific assignment is detailed on the sheet handed out in in class and is due in three weeks 16 February. The content of the handout is available on the web as well (see the class home page).

End of Interlude on Linkers

Chapter 1. Introduction

Homework: Read Chapter 1 (Introduction)

Levels of abstraction (virtual machines)

1.1: What is an operating system?

The kernel itself raises the level of abstraction and hides details. For example a user (of the kernel) can write to a file (a concept not present in hardware) and ignore whether the file resides on a floppy, a CD-ROM, or a hard magnetic disk

The kernel is a resource manager (so users don't conflict).

How is an OS fundamentally different from a compiler (say)?

Answer: Concurrency! Per Brinch Hansen in Operating Systems Principles (Prentice Hall, 1973) writes.

The main difficulty of multiprogramming is that concurrent activities can interact in a time-dependent manner, which makes it practically impossibly to locate programming errors by systematic testing. Perhaps, more than anything else, this explains the difficulty of making operating systems reliable.

1.2 History of Operating Systems

  1. Single user (no OS).
  2. Batch, uniprogrammed, run to completion.
  3. Multiprogrammed
  4. Multiple computers
  5. Real time systems
Homework:1, 2, 5 (unless otherwise stated, problems numbers are from the end of the chapter in Tanenbaum.)

1.3: Operating System Concepts

This will be very brief. Much of the rest of the course will consist in ``filling in the details''.

1.3.1: Processes

A program in execution. If you run the same program twice, you have created two processes. For example if you have two editors running in two windows, each instance of the editor is a separate process.

Often one distinguishes the state or context (memory image, open files) from the thread of control. Then if one has many threads running in the same task, the result is a ``multithreaded processes''.

The OS keeps information about all processes in the process table. Indeed, the OS views the process as the entry. An example of an active entity being viewed as a data structure (cf. discrete event simulations). An observation made by Finkel in his (out of print) OS textbook.

The set of processes forms a tree via the fork system call. The forker is the parent of the forkee. If the parent stops running until the child finishes, the ``tree'' is quite simple, just a line. But the parent (in many OSes) is free to continue executing and in particular is free to fork again producing another child.

A process can send a signal to another process to cause the latter to execute a predefined function (the signal handler). This can be tricky to program since the programmer does not know when in his ``main'' program the signal handler will be invoked.

1.3.2: Files

Modern systems have a hierarchy of files. A file system tree.

Files and directories normally have permissions

Devices (mouse, tape drive, cdrom) are often view as ``special files''. In a unix system these are normally found in the /dev directory. Often utilities that are normally applied to (ordinary) files can be applied as well to some special files. For example, when you are accessing a unix system and do not have anything serious going on (e.g., right after you log in), type the following command

    cat /dev/mouse
and then move the mouse. You kill the cat by typing cntl-C. I tried this on my linux box and no damage occurred. Your mileage may vary.

Many systems have standard files that are automatically made available to a process upon startup. There (initial) file descriptors are fixed

A convenience offered by some command interpretors is a pipe or pipeline. The pipeline

  ls | wc
will give the number of files in the directory (plus other info).

Homework: 3