Top Banner
Principles, rules, hints and art of computer system design Lin Zhong
32

Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

May 07, 2018

Download

Documents

truongdieu
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Principles, rules, hints and art of computer system design

Lin Zhong

Page 2: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Guiding principles Acknowledgment of human limitation

Page 3: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Keep It Simple• When in doubt, use brute force

• time favors brute force

• When in doubt, leave it out

• adding a feature increases development effort disproportionally

• Avoid excessive generality

• If it’s good for everything, it’s good for nothing

Page 4: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Make it availableOpen design principle

Let anyone comment on the design; You need all the help you can get

Principles of Computer System Design by Salzter & Kaashoek

Page 5: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Linus’s Law

• “Given enough eyeballs, all bugs are shallow” —Linus Torvalds

Page 6: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

How to structure your system

Page 7: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

End to end principle• “ functions placed at low levels of a system may

be redundant or of little value when compared with the cost of providing them at that low level”

• functions: security, reliability, safety,…

End-to End Arguments in System Design by Saltzer, Reed and Clark, 1984

Page 8: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Separation of mechanism and policy

• Mechanism: access control & allocation of resources

• Policy: who has access and get what resources

Page 9: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Why separation?

• Policy changes faster

• Policy and mechanism require different privilege

• Policy and mechanism may come from different sources.

Page 10: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Separation of concerns

Page 11: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Separate interface from implementation

• Keep interface constant

Page 12: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Rule of Modularity• Write simple parts connected by clean interfaces

Page 13: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Robustness principle

• Be tolerant of inputs, strict on outputs

Principles of Computer System Design by Salzter & Kaashoek

Page 14: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The CMOS Inverter:A First Glance

VDD

Vin Vout

CL

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

CMOS Inverter VTC

Vout

Vin1 2 3 4 51

23

45

NMOS linPMOS off

NMOS satPMOS sat

NMOS offPMOS lin

NMOS satPMOS lin

NMOS linPMOS sat

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The CMOS Inverter:A First Glance

VDD

Vin Vout

CL

Page 15: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The Regenerative Property

(a) A chain of inverters.

v0, v2, ...

v1, v3, ... v1, v3, ...

v0, v2, ...(b) Regenerative gate

f(v)

finv(v)

finv(v)

f(v)

(c) Non-regenerative gate

v0 v1 v2 v3 v4 v5 v6

...

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The CMOS Inverter:A First Glance

VDD

Vin Vout

CL

The regenerative property of CMOS gates

Page 16: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The Regenerative Property

(a) A chain of inverters.

v0, v2, ...

v1, v3, ... v1, v3, ...

v0, v2, ...(b) Regenerative gate

f(v)

finv(v)

finv(v)

f(v)

(c) Non-regenerative gate

v0 v1 v2 v3 v4 v5 v6

...

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The CMOS Inverter:A First Glance

VDD

Vin Vout

CL

The regenerative property of CMOS gates

Page 17: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The Regenerative Property

(a) A chain of inverters.

v0, v2, ...

v1, v3, ... v1, v3, ...

v0, v2, ...(b) Regenerative gate

f(v)

finv(v)

finv(v)

f(v)

(c) Non-regenerative gate

v0 v1 v2 v3 v4 v5 v6

...

Digital Integrated Circuits © Prentice Hall 1995InverterInverter

The CMOS Inverter:A First Glance

VDD

Vin Vout

CL

The regenerative property of CMOS gates

Page 18: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Decouple modules with indirection

• Indirection supports replaceability

Principles of Computer System Design by Salzter & Kaashoek

Page 19: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Decouple modules with indirection

• “All problems in computer science can be solved by another level of indirection”

• David Wheeler

• known as Fundamental theorem of software engineering

• “except for the problem of too many layers of indirection”

• Kevin Henney’s Corollary

Principles of Computer System Design by Salzter & Kaashoek

Page 20: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Rule of Representation• Fold knowledge into the data so that program logic

can be stupid and robust

• “Data is more tractable than program logic. It follows that where you see a choice between complexity in data structures and complexity in code, choose the former. More: in evolving a design, you should actively seek ways to shift complexity from code to data.”

Page 21: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Booting Linux

• The old way (still the way on your PC): the kernel has the knowledge of the hardware

• The new way: the hardware knowledge is in the device tree (DTB). A generic kernel consults it

Page 22: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Checklist

Page 23: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Checklist

Page 24: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong
Page 25: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

About the development process

Page 26: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Rule of Optimization

• Prototype before polishing. Get it working before you optimize it.

Page 27: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Law of diminishing returns

• The more one improves some measure of goodness, the more effort the next improvement will require

Principles of Computer System Design by Salzter & Kaashoek

Page 28: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Law of diminishing returnsGoodness

Effort

Page 29: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Law of diminishing returnsGoodness

Effort

It matters where you are on the curve?

Page 30: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Design for interaction

• You won’t get it right the first time, so make it easy to change

Principles of Computer System Design by Salzter & Kaashoek

Page 31: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Rule of Extensibility• Design for the future, because it will be here sooner

than you think

Page 32: Principles, rules, hints and art of computer system …mobile/elec513/principle-02.pdfPrinciples, rules, hints and art of computer system design Lin Zhong

Rule of Generation

• Avoid hand-hacking; write programs to write programs when you can