# ➢ Computer Organization and Design 笔记 - Arithmetic for Computers

1. Add (add), and immediate (addi), and subtract (sub) cause exceptions on overflow. MIPS detects overflow with an exception (or interrupt ), which is an unscheduled procedure call. The address of current instruction is saved and the computer jumps to predefined address to invoke the appropriate routine for that exception.

MIPS uses exception program counter (EPC) to contain the address of the instruction that causes the exception. The instruction move from system control (mfc0) is used to copy EPC into a general-purpose register.

2. Add unsigned (addu), add immediate unsigned (addiu), and subtract unsigned (subu) do not cause exceptions on overflow. Programmers can trap overflow anyway: when overflow occurs, the sign bit of the result is not properly set. Compairing with sign bits of operands, the sign bit of the result can be determined.

SIMD (single instruction, multiple data): By partitioning the carry chains within a 64-bit adder, a processor could perform simultaneous operations on a short vecters of eight 8-bit operands, four 16-bit operands, etc. Vectors and 8-bit data often appears in multimedia routine.

# ➢ Computer Organization and Design 笔记 - Instructions

Common goal of computer designers: to find a language that makes it easy to build the hardware and the compiler while maximizing performance and minimizing cost and power.

Stored-program concept

The idea that instructions and data of many types can be stored in memory as numbers, leading to the stored-program computer.

# ➢ Computer Organization and Design 笔记 - Abstractions

## Concepts

Moore’s law

Over the history of computing hardware, the number of transistors on integrated circuits doubles approximately every two years.

Compiler

A program that translates high-level language statements into assembly language statements.

Assembler

A program that translates a symbolic version of instructions into the binary version.

High-level programming langrage

A portable language that is composed of words and algebraic notation that can be translated by a compiler into assembly language.

Assembly language

Asymbolic representation of machine instructions.

Machine language

A binary representation of machine instructions.

5 components of a computer

Input, Output, Memory, Control, Datapath

The last two sometimes combined and called the processor.

Instruction set architecture One key interface between the levels of abstraction is the instruction set architecture-the interface between the hardware and low-level software.

# ➢ Modern Operating Systems 笔记 - Linux

## History of Unix and Linux

### MULTICS & UNICS

• Researchers at M.I.T. joined forces with Bell Labs and Generic Electric and began designing a second-generation system, MULTICS(Multiplexed Information and Computing Service)
• One of the Bell Labs researchers, Ken Thompson wrote a stripped-down MULTICS on a PDP-7 minicomputer. The system is called UNICS(UNiplexed Information and Computing Service) jokingly by Brian Kernighan, Bell Labs.
• Thompson tied to rewite UNIX with B language of his own design and failed. Ritchie then designed a successor to B, called C. Working together, they rewrote UNIX in C.
• Steve Johnson of Bell Labs designed and implemented the portable C compiler, which could be retargeted to produce code for any resonable machine with a only a moderate amount of effort.

### Standard UNIX

• AT&T released its first commercial UNIX: System III, then System V.
• Aided by U.S. Dept. of Defense, Berkeley released an improved PDP-11 called 1BSD(First Berkeley Software Distribution), which supported virtual memory, TCP/IP, vi, csh, etc.
• IEEE came up with POSIX(Portable Operating System of UNIXish), witch reconcile the two flavors of UNIX.

# ➢ Modern Operating Systems 笔记 - File System

## Files

File structures

Byte sequence , Record sequence , Tree

File Types

Regular files , Directories , Character special files , Block special files

File operations

Create , Delete , Open , Close , Read , Write , Append , Seek , Get attributes , Set attributes , Rename.

# ➢ Makefile 入门

make是软件开发中常用的工具程序（Utility software），常被用来构建C程序。make通过读取叫做“makefile”的文件，来自动化建构软件。

# ➢ Modern Operating Systems 笔记 - Input/Output

## Principles of I/O Hardware

### Devices & Controllers

• block devices stores information in fixed-size blocks, each one with its own address.
• character devices delivers or accepts a stream of characters, without regard to any block structure.
• device controller/adapter takes the form of a chip on the parentboard or a printed circuit card that can be inserted into a (PCI) expansion slot.

### Memory-Mapped I/O

Each control register is assigned a unique memory address to which no memory is assigned.

Pros:

• if special I/O instructions are needed to read/write the device control registers, access to them requires nothing more than standard C code, otherwise needs the use of addembly code.
• with memory-mapped I/O, no special protection mechanism is needed to keep user processes from performing I/O.
• With memory-mapped I/O, every instruction that can reference memory can also reference control registers.

Cons:

• most computers nowadays have some form of caching of memory words. Caching a device control register would be disastrous.
• If there is only one address space, then all memory modules and all I/O devices must examine all memory references to see which ones to respond to.