Download Operating Systems I and more Lecture notes Operating Systems in PDF only on Docsity!
Operating Systems I
Steven Hand
Michaelmas / Lent Term 2007/
16 lectures for CST IA
Operating Systems — MN/MWF/
i
Course Outline
- Part I: Computer Organisation
- Computer Foundations
- Operation of a Simple Computer.
- Input/Output.
- Part II: Operating System Functions.
- Introduction to Operating Systems.
- Processes & Scheduling.
- Memory Management.
- I/O & Device Management.
- Protection.
- Filing Systems.
- Part III: Case Studies.
Outline iii
Recommended Reading
- Tannenbaum A S Structured Computer Organization (3rd Ed) Prentice-Hall 1990.
- Patterson D and Hennessy J Computer Organization & Design (2rd Ed) Morgan Kaufmann 1998.
- Bacon J [ and Harris T ] Concurrent Systems or Operating Systems Addison Wesley 1997, Addison Wesley 2003
- Silberschatz A, Peterson J and Galvin P Operating Systems Concepts (5th Ed.) Addison Wesley 1998.
- Leffler S J The Design and Implementation of the 4.3BSD UNIX Operating System. Addison Wesley 1989
- Solomon D and Russinovich M Inside Windows 2000 (3rd Ed) or Windows Internals (4th Ed) Microsoft Press 2000, Microsoft Press 2005
Books iv
The Von Neumann Architecture
Memory
Control Unit
Arithmetic Logical Unit
Accumulator
Output
Input
- 1945: ENIAC (Eckert & Mauchley, U. Penn):
- 30 tons, 1000 square feet, 140 kW,
- 18K vacuum tubes, 20×10-digit accumulators,
- 100KHz, circa 300 MPS.
- Used to calculate artillery firing tables.
- (1946) blinking lights for the media...
- But: “programming” is via plugboard ⇒ v. slow.
- 1945: von Neumann drafts “EDVAC” report:
- design for a stored-program machine
- Eckert & Mauchley mistakenly unattributed
Computer Organisation — Foundations 2
Further Progress...
- 1947: “point contact” transistor invented (Shockley, Bardeen & Brattain, Bell Labs)
- 1949: EDSAC, the world’s first stored-program computer (Wilkes & Wheeler, U. Cambridge)
- 3K vacuum tubes, 300 square feet, 12 kW,
- 500KHz, circa 650 IPS, 225 MPS.
- 1024 17-bit words of memory in mercury ultrasonic delay lines.
- 31 word “operating system” (!)
- 1954: TRADIC, first electronic computer without vacuum tubes (Bell Labs)
- 1954: first silicon (junction) transistor (TI)
- 1959: first integrated circuit (Kilby & Noyce, TI)
- 1964: IBM System/360, based on ICs.
- 1971: Intel 4004, first micro-processor (Ted Hoff):
- 2300 transistors, 60 KIPS.
- 1978: Intel 8086/8088 (used in IBM PC).
- ∼ 1980: first VLSI chip (> 100,000 transistors)
Today: ∼ 800M transistors, ∼ 0. 045 nm, ∼ 3 GHz.
Computer Organisation — Foundations 3
Layered Virtual Machines
Virtual Machine M5 (Language L5)
Virtual Machine M4 (Language L4)
Virtual Machine M3 (Language L3)
Meta-Language Level
Compiled Language Level
Assembly Language Level
Virtual Machine M2 (Language L2)
Virtual Machine M1 (Language L1)
Digital Logic Level
Operating System Level
Actual Machine M0 (Language L0)
Conventional Machine Level
- In one sense, there is a set of different machines M 0 , M 1 ,... Mn, each built on top of the other.
- Can consider each machine Mi to understand only machine language Li.
- Levels 0, -1 pot. done in Dig. Elec., Physics...
- This course focuses on levels 1 and 2.
- NB: all levels useful; none “the truth”.
Computer Organisation — Abstraction 5
A (Simple) Modern Computer
Control Unit e.g. 1 GByte2^30 x 8 = 8,589,934,592bits
Address Data Control
Processor
Reset
Bus
Memory Execution Unit
Register File (including PC)
Sound Card
Framebuffer
Hard Disk
Super I/O
Mouse Keyboard Serial
- Processor (CPU): executes programs.
- Memory: stores both programs & data.
- Devices: for input and output.
- Bus: transfers information.
Computer Organisation — Anatomy of a Computer 6
Memory Hierarchy
Register File 64K ROM
(^) Execution Unit
ControlUnit
Address Data Control
CPU
Cache^ Data
Instruction Cache
Cache (SRAM) Main Memory
Bus Interface Unit
1GB DRAM
Bus
- Use cache between main memory and register: try to hide delay in accessing (relatively) slow DRAM.
- Cache made from faster SRAM:
- more expensive, so much smaller
- holds copy of subset of main memory.
- Split of instruction and data at cache level ⇒ “Harvard” architecture.
- Cache ↔ CPU interface uses a custom bus.
- Today have ∼ 8 MB cache, ∼ 2 GB RAM.
Computer Organisation — Anatomy of a Computer 8
The Fetch-Execute Cycle
Control Unit
Decode IB
Execution Unit
Register File
PC
- A special register called PC holds a memory address; on reset, initialised to 0.
- Then:
- Instruction fetched from memory address held in PC into instruction buffer (IB).
- Control Unit determines what to do: decodes instruction.
- Execution Unit executes instruction.
- PC updated, and back to Step 1.
- Continues pretty much forever...
Computer Organisation — Central Processing Unit 9
Arithmetic Logic Unit
k
N
Carry In
Carry Out
ALU
Function Code input a
input b
output (d)
An N-bit ALU
N
N
- Part of the execution unit.
- Inputs from register file; output to register file.
- Performs simple two-operand functions:
- a + b
- a - b
- a AND b
- a OR b
- etc.
- Typically perform all possible functions; use function code to select (mux) output.
Computer Organisation — Arithmetic and Logical Operations 11
Number Representation
00002 016 01102 616 11002 C 16 00012 116 01112 716 11012 D 16 00102 216 10002 816 11102 E 16 00112 316 10012 916 11112 F 16 01002 416 10102 A 16 100002 1016 01012 516 10112 B 16 100012 1116
- a n-bit register bn− 1 bn− 2... b 1 b 0 can represent 2 n different values.
- Call bn− 1 the most significant bit (msb), b 0 the least significant bit (lsb).
- Unsigned numbers: treat the obvious way, i.e. val = bn− 12 n−^1 + bn− 22 n−^2 + · · · + b 121 + b 020 , e.g. 11012 = 2^3 + 2^2 + 2^0 = 8 + 4 + 1 = 13.
- Represents values from 0 to 2 n^ − 1 inclusive.
- For large numbers, binary is unwieldy: use hexadecimal (base 16).
- To convert, group bits into groups of 4, e.g. 11111010102 = 0011| 1110 | 10102 = 3EA 16.
- Often use “ 0 x” prefix to denote hex, e.g. 0 x 107.
- Can use dot to separate large numbers into 16-bit chunks, e.g. 0 x 3 F F.F F F F.
Computer Organisation — Arithmetic and Logical Operations 12
Unsigned Arithmetic
0 0 1 1 1 0 0 1 1 0
C 4 C 3 C 2 C 1
0 (0) 1 (1) 1 (1) 0 (0) 1
( 0)
= = (1) (1) ( 0) (0)
( 0)
C (^) out C 5 C 0 Cin ( 0)
- (we use 5-bit registers for simplicity)
- Unsigned addition: Cn means “carry”:
00101 5 11110 30
0 01100 12 1 00101 5
- Unsigned subtraction: Cn means “borrow”:
11110 30 00111 7
1 00011 3 0 11101 29
Computer Organisation — Arithmetic and Logical Operations 14
Signed Arithmetic
- In signed arithmetic, carry no good on its own. Use the overflow flag, V = (Cn⊕ Cn− 1 ).
- Also have negative flag, N = bn− 1 (i.e. the msb).
- Signed addition:
00101 5 01010 10
0 01100 12 0 10001 -
0 1
- Signed subtraction: 01010 10 10110 -
1 00011 3 1 01100 12
1 0
- Note that in overflow cases the sign of the result is always wrong (i.e. the N bit is inverted).
Computer Organisation — Arithmetic and Logical Operations 15