没有合适的资源?快使用搜索试试~ 我知道了~
首页计算机系统概论:程序员视角
计算机系统概论:程序员视角
需积分: 50 127 下载量 183 浏览量
更新于2024-07-19
4
收藏 8.92MB PDF 举报
"CSAPP 英文版" 是一本关于计算机系统的程序员视角的书籍,由Randal E. Bryant和David R. O'Hallaron撰写,主要涵盖了计算机系统的基础知识和重要主题。 本书开篇介绍了计算机系统的基本概念,指出信息是位(bits)与上下文的结合,强调了理解编译系统工作原理的重要性。它详细阐述了处理器如何读取并解释存储在内存中的指令,硬件系统的组织结构以及运行程序(如"hello"程序)的流程。书中还提到了缓存的作用,它们对于提高计算机性能的关键性。 存储设备形成了一个层次结构,从高速缓存到主内存再到外部硬盘,这种层次设计旨在优化数据访问速度和存储容量。操作系统作为硬件的管理者,负责处理进程、线程、虚拟内存管理和文件系统等核心任务。进程是独立执行的程序实例,线程则是在同一进程中并发执行的更小单元。虚拟内存允许程序使用超过物理内存大小的地址空间,而文件系统则管理着数据的持久化存储。 书中进一步探讨了计算机系统间的网络通信,这是全球化信息交换的基础。作者特别强调了并发性和并行性作为计算机系统中的重要概念,以及抽象在系统设计中的关键作用,这些抽象帮助我们理解和简化复杂的系统问题。 总结部分回顾了全书的主要观点,包括硬件、软件、操作系统、网络通信和系统设计原则等多个方面。此外,书后还提供了参考文献,便于读者深入学习和扩展阅读。 这本书是为那些希望深入理解计算机系统运作机制的程序员和计算机科学学生准备的,通过阅读,读者可以提升对底层系统工作的洞察力,从而更好地进行程序设计和优化。
资源详情
资源推荐
Contents xvii
11.5 Web Servers 911
11.5.1 Web Basics 911
11.5.2 Web Content 912
11.5.3 HTTP Transactions 914
11.5.4 Serving Dynamic Content 916
11.6 Putting It Together: The Tiny Web Server 919
11.7 Summary 927
Bibliographic Notes 928
Homework Problems 928
Solutions to Practice Problems 929
12
Concurrent Programming 933
12.1 Concurrent Programming with Processes 935
12.1.1 A Concurrent Server Based on Processes 936
12.1.2 Pros and Cons of Processes 937
12.2 Concurrent Programming with I/O Multiplexing 939
12.2.1 A Concurrent Event-Driven Server Based on I/O
Multiplexing 942
12.2.2 Pros and Cons of I/O Multiplexing 946
12.3 Concurrent Programming with Threads 947
12.3.1 Thread Execution Model 948
12.3.2 Posix Threads 948
12.3.3 Creating Threads 950
12.3.4 Terminating Threads 950
12.3.5 Reaping Terminated Threads 951
12.3.6 Detaching Threads 951
12.3.7 Initializing Threads 952
12.3.8 A Concurrent Server Based on Threads 952
12.4 Shared Variables in Threaded Programs 954
12.4.1 Threads Memory Model 955
12.4.2 Mapping Variables to Memory 956
12.4.3 Shared Variables 956
12.5 Synchronizing Threads with Semaphores 957
12.5.1 Progress Graphs 960
12.5.2 Semaphores 963
12.5.3 Using Semaphores for Mutual Exclusion 964
12.5.4 Using Semaphores to Schedule Shared Resources 966
12.5.5 Putting It Together: A Concurrent Server Based on
Prethreading 970
12.6 Using Threads for Parallelism 974
xviii Contents
12.7 Other Concurrency Issues 979
12.7.1 Thread Safety 979
12.7.2 Reentrancy 980
12.7.3 Using Existing Library Functions in Threaded Programs 982
12.7.4 Races 983
12.7.5 Deadlocks 985
12.8 Summary 988
Bibliographic Notes 989
Homework Problems 989
Solutions to Practice Problems 994
A
Error Handling 999
A.1 Error Handling in Unix Systems 1000
A.2 Error-Handling Wrappers 1001
References 1005
Index 1011
Preface
This book (CS:APP) is for computer scientists, computer engineers, and others
who want to be able to write better programs by learning what is going on “under
the hood” of a computer system.
Our aim is to explain the enduring concepts underlying all computer systems,
and to show you the concrete ways that these ideas affect the correctness, perfor-
mance, and utility of your application programs. Other systems books are written
from a builder’s perspective, describing how to implement the hardware or the sys-
tems software, including the operating system, compiler, and network interface.
This book is written from a programmer’s perspective, describing how application
programmers can use their knowledge of a system to write better programs. Of
course, learning what a system is supposed to do provides a good first step in learn-
ing how to build one, and so this book also serves as a valuable introduction to
those who go on to implement systems hardware and software.
If you study and learn the concepts in this book, you will be on your way to
becoming the rare “power programmer” who knows how things work and how
to fix them when they break. Our aim is to present the fundamental concepts in
ways that you will find useful right away. You will also be prepared to delve deeper,
studying such topics as compilers, computer architecture, operating systems, em-
bedded systems, and networking.
Assumptions about the Reader’s Background
The presentation of machine code in the book is based on two related formats
supported by Intel and its competitors, colloquially known as “x86.” IA32 is the
machine code that has become the de facto standard for a wide range of systems.
x86-64 is an extension of IA32 to enable programs to operate on larger data and to
reference a wider range of memory addresses. Since x86-64 systems are able to run
IA32 code, both of these forms of machine code will see widespread use for the
foreseeable future. We consider how these machines execute C programs on Unix
or Unix-like (such as Linux) operating systems. (To simplify our presentation,
we will use the term “Unix” as an umbrella term for systems having Unix as
their heritage, including Solaris, Mac OS, and Linux.) The text contains numerous
programming examples that have been compiled and run on Linux systems. We
assume that you have access to such a machine and are able to log in and do simple
things such as changing directories.
If your computer runs Microsoft Windows, you have two choices. First, you
can get a copy of Linux (www.ubuntu.com) and install it as a “dual boot” option,
so that your machine can run either operating system. Alternatively, by installing
a copy of the Cygwin tools (www.cygwin.com), you can run a Unix-like shell under
xix
xx Preface
Windows and have an environment very close to that provided by Linux. Not all
features of Linux are available under Cygwin, however.
We also assume that you have some familiarity with C or C++. If your only
prior experience is with Java, the transition will require more effort on your part,
but we will help you. Java and C share similar syntax and control statements.
However, there are aspects of C, particularly pointers, explicit dynamic memory
allocation, and formatted I/O, that do not exist in Java. Fortunately, C is a small
language, and it is clearly and beautifully described in the classic “K&R” text
by Brian Kernighan and Dennis Ritchie [58]. Regardless of your programming
background, consider K&R an essential part of your personal systems library.
Several of the early chapters in the book explore the interactions between
C programs and their machine-language counterparts. The machine-language
examples were all generated by the GNU gcc compiler running on IA32 and x86-
64 processors. We do not assume any prior experience with hardware, machine
language, or assembly-language programming.
New to C? Advice on the C programming language
To help readers whose background in C programming is weak (or nonexistent), we have also included
these special notes to highlight features that are especially important in C. We assume you are familiar
with C++ or Java.
How to Read the Book
Learning how computer systems work from a programmer’s perspective is great
fun, mainly because you can do it actively. Whenever you learn something new,
you can try it out right away and see the result first hand. In fact, we believe that
the only way to learn systems is to do systems, either working concrete problems
or writing and running programs on real systems.
This theme pervades the entire book. When a new concept is introduced, it
is followed in the text by one or more practice problems that you should work
immediately to test your understanding. Solutions to the practice problems are
at the end of each chapter. As you read, try to solve each problem on your own,
and then check the solution to make sure you are on the right track. Each chapter
is followed by a set of homework problems of varying difficulty. Your instructor
has the solutions to the homework problems in an Instructor’s Manual. For each
homework problem, we show a rating of the amount of effort we feel it will require:
◆ Should require just a few minutes. Little or no programming required.
◆◆ Might require up to 20 minutes. Often involves writing and testing some code.
Many of these are derived from problems we have given on exams.
◆◆◆ Requires a significant effort, perhaps 1–2 hours. Generally involves writing
and testing a significant amount of code.
◆◆◆◆ A lab assignment, requiring up to 10 hours of effort.
Preface xxi
code/intro/hello.c
1 #include <stdio.h>
2
3
int main()
4 {
5 printf("hello, world\n");
6 return 0;
7 }
code/intro/hello.c
Figure 1 A typical code example.
Each code example in the text was formatted directly, without any manual
intervention, from a C program compiled with gcc and tested on a Linux system.
Of course, your system may have a different version of gcc, or a different compiler
altogether, and so your compiler might generate different machine code, but the
overall behavior should be the same. All of the source code is available from the
CS:APP Web page at csapp.cs.cmu.edu. In the text, the file names of the source
programs are documented in horizontal bars that surround the formatted code.
For example, the program in Figure 1 can be found in the file hello.c in directory
code/intro/. We encourage you to try running the example programs on your
system as you encounter them.
To avoid having a book that is overwhelming, both in bulk and in content,
we have created a number of Web asides containing material that supplements
the main presentation of the book. These asides are referenced within the book
with a notation of the form CHAP:TOP, where CHAP is a short encoding of the
chapter subject, and TOP is short code for the topic that is covered. For example,
Web Aside data:bool contains supplementary material on Boolean algebra for
the presentation on data representations in Chapter 2, while Web Aside arch:vlog
contains material describing processor designs using the Verilog hardware descrip-
tion language, supplementing the presentation of processor design in Chapter 4.
All of these Web asides are available from the CS:APP Web page.
Aside What is an aside?
You will encounter asides of this form throughout the text. Asides are parenthetical remarks that give
you some additional insight into the current topic. Asides serve a number of purposes. Some are little
history lessons. For example, where did C, Linux, and the Internet come from? Other asides are meant
to clarify ideas that students often find confusing. For example, what is the difference between a cache
line, set, and block? Other asides give real-world examples. For example, how a floating-point error
crashed a French rocket, or what the geometry of an actual Seagate disk drive looks like. Finally, some
asides are just fun stuff. For example, what is a “hoinky”?
剩余1075页未读,继续阅读
PM22k
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 多模态联合稀疏表示在视频目标跟踪中的应用
- Kubernetes资源管控与Gardener开源软件实践解析
- MPI集群监控与负载平衡策略
- 自动化PHP安全漏洞检测:静态代码分析与数据流方法
- 青苔数据CEO程永:技术生态与阿里云开放创新
- 制造业转型: HyperX引领企业上云策略
- 赵维五分享:航空工业电子采购上云实战与运维策略
- 单片机控制的LED点阵显示屏设计及其实现
- 驻云科技李俊涛:AI驱动的云上服务新趋势与挑战
- 6LoWPAN物联网边界路由器:设计与实现
- 猩便利工程师仲小玉:Terraform云资源管理最佳实践与团队协作
- 类差分度改进的互信息特征选择提升文本分类性能
- VERITAS与阿里云合作的混合云转型与数据保护方案
- 云制造中的生产线仿真模型设计与虚拟化研究
- 汪洋在PostgresChina2018分享:高可用 PostgreSQL 工具与架构设计
- 2018 PostgresChina大会:阿里云时空引擎Ganos在PostgreSQL中的创新应用与多模型存储
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功