资料简介:
本书从程序员的视角详细阐述计算机系统的本质概念,并展示这些概念如何实实在在地影响应用程序的正确性、性能和实用性。全书共12章,主要包括信息的表示和处理、程序的机器级表示、处理器体系结构、优化程序性能、存储器层次结构、链接、异常控制流、虚拟存储器、系统级I/O、网络编程、并发编程等内容。书中提供了大量的例子和练习题,并给出部分答案,有助于读者加深对正文所述概念和知识的理解
资料目录:
A Tour of Computer Systems 1
1.1Information Is Bits + Context 3
1.2Programs Are Translated by Other Programs into Different Forms 4
1.3It Pays to Understand How Compilation Systems Work 6
1.4Processors Read and Interpret Instructions Stored in Memory 7
1.4.1Hardware Organization of a System 8
1.4.2Running the helloProgram 10
1.5Caches Matter 11
1.6Storage Devices Form a Hierarchy 14
1.7The Operating System Manages the Hardware 14
1.7.1Processes 15
1.7.2Threads 17
1.7.3Virtual Memory 18
1.7.4Files 19
1.8Systems Communicate with Other Systems Using Networks 19
1.9Important Themes 22
1.9.1Amdahl’s Law 22
1.9.2Concurrency and Parallelism 24
1.9.3The Importance of Abstractions in Computer Systems 26
1.10Summary 27 Bibliographic Notes 28 Solutions to Practice Problems 28
Part I Program Structure and Execution
2
Representing and Manipulating Information 31
2.1Information Storage 34
2.1.1Hexadecimal Notation 36
2.1.2Data Sizes 39
2.1.3 Addressing and Byte Ordering 42
2.1.4 Representing Strings 49
2.1.5 Representing Code 49
2.1.6 Introduction to Boolean Algebra 50
2.1.7 Bit-Level Operations in C 54
2.1.8 Logical Operations in C 56
2.1.9 Shift Operations in C 57
2.2 Integer Representations 59
2.2.1 Integral Data Types 60
2.2.2 Unsigned Encodings 62
2.2.3 Two’s-Complement Encodings 64
2.2.4 Conversions between Signed and Unsigned 70
2.2.5 Signed versus Unsigned in C 74
2.2.6 Expanding the Bit Representation of a Number 76
2.2.7 Truncating Numbers 81
2.2.8 Advice on Signed versus Unsigned 83
2.3 Integer Arithmetic 84
2.3.1 Unsigned Addition 84
2.3.2 Two’s-Complement Addition 90
2.3.3 Two’s-Complement Negation 95
2.3.4 Unsigned Multiplication 96
2.3.5 Two’s-Complement Multiplication 97
2.3.6 Multiplying by Constants 101
2.3.7 Dividing by Powers of 2 103
2.3.8 Final Thoughts on Integer Arithmetic 107
2.4 Floating Point 108
2.4.1 Fractional Binary Numbers 109
2.4.2 IEEE Floating-Point Representation 112
2.4.3 Example Numbers 115
2.4.4 Rounding 120
2.4.5 Floating-Point Operations 122
2.4.6 Floating Point in C 124
2.5 Summary 126
Bibliographic Notes 127
Homework Problems 128
Solutions to Practice Problems 143
3
Machine-Level Representation of Programs 163
3.1 A Historical Perspective 166
3.2Program Encodings 169
3.2.1Machine-Level Code 170
3.2.2Code Examples 172
3.2.3Notes on Formatting 175
3.3Data Formats 177
3.4Accessing Information 179
3.4.1Operand Speci.ers 180
3.4.2Data Movement Instructions 182
3.4.3Data Movement Example 186
3.4.4Pushing and Popping Stack Data 189
3.5Arithmetic and Logical Operations 191
3.5.1Load Effective Address 191
3.5.2Unary and Binary Operations 194
3.5.3Shift Operations 194
3.5.4Discussion 196
3.5.5Special Arithmetic Operations 197
3.6Control 200
3.6.1Condition Codes 201
3.6.2Accessing the Condition Codes 202
3.6.3Jump Instructions 205
3.6.4Jump Instruction Encodings 207
3.6.5Implementing Conditional Branches withConditional Control 209
3.6.6Implementing Conditional Branches withConditional Moves 214
3.6.7Loops 220
3.6.8Switch Statements 232
3.7Procedures 238
3.7.1The Run-Time Stack 239
3.7.2Control Transfer 241
3.7.3Data Transfer 245
3.7.4Local Storage on the Stack 248
3.7.5Local Storage in Registers 251
3.7.6Recursive Procedures 253
3.8Array Allocation and Access 255
3.8.1Basic Principles 255
3.8.2Pointer Arithmetic 257
3.8.3Nested Arrays 258
3.8.4Fixed-Size Arrays 260
3.8.5Variable-Size Arrays 262
3.9 Heterogeneous Data Structures 265
3.9.1 Structures 265
3.9.2 Unions 269
3.9.3 Data Alignment 273
3.10 Combining Control and Data in Machine-Level Programs 276
3.10.1 Understanding Pointers 277
3.10.2 Life in the Real World: Using the gdbDebugger 279
3.10.3 Out-of-Bounds Memory References and Buffer Over.ow 279
3.10.4 Thwarting Buffer Over.ow Attacks 284
3.10.5 Supporting Variable-Size Stack Frames 290
3.11 Floating-Point Code 293
3.11.1 Floating-Point Movement and Conversion Operations 296
3.11.2 Floating-Point Code in Procedures 301
3.11.3 Floating-Point Arithmetic Operations 302
3.11.4 De.ning and Using Floating-Point Constants 304
3.11.5 Using Bitwise Operations in Floating-Point Code 305
3.11.6 Floating-Point Comparison Operations 306
3.11.7 Observations about Floating-Point Code 309
3.12 Summary 309
Bibliographic Notes 310
Homework Problems 311
Solutions to Practice Problems 325
4
Processor Architecture 351
4.1The Y86-64 Instruction Set Architecture 355
4.1.1Programmer-Visible State 355
4.1.2Y86-64 Instructions 356
4.1.3Instruction Encoding 358
4.1.4Y86-64 Exceptions 363
4.1.5Y86-64 Programs 364
4.1.6Some Y86-64 Instruction Details 370
4.2Logic Design and the Hardware Control Language HCL 372
4.2.1Logic