I was abused by CSAPP

In the last two weekends, I couldn’t stop scrolling CSAPP in the library. I was fascinated by the feeling that I could not understand but still endured the pain and forced myself to read.

This book from the real sense let me realize what is called reading five minutes, two hours of rest.

But we must not learn me, I believe that you are sitting in the absolute cattle than I batch, why? Since I recommend a magic ware to you, let’s first introduce this book.

The book is divided into twelve chapters, and I have drawn a mind map for you, which is relatively straightforward.

The first chapter is a brief chapter, from a Hello world program to lead to C, lead to UNIX, Linux, lead to C language program compilation process, lead to cache, system hardware composition, storage structure, virtual memory, network programming, concurrent programming, very cool. The first chapter is a confidence building chapter that is not difficult to understand. This chapter can give you a feeling of excitement because it is not difficult, but it will open your mind and tie your body of knowledge together.

The first part

Chapter 2 is a bit boring, and I personally think you need some C background, although the introduction of the book says that if you have Java background…

It’s still a little hard to top, so I suggest you learn a wave of C.

Don’t stand in my way, I’m coming to C, and I recommend two books on C. The first one is C Primer Plus, which is a book that crumbles C and teaches you how to use it, and the C Programming Language is also good.

The second chapter is mainly about the storage of data in the computer, the basic data types and various complement code, inverse code expression. Anyway, if you don’t know C, you might feel a little sleepy in this chapter, but the second chapter is actually quite good, and when you read the second chapter of this book, you may find that what you think is just wishful thinking, and the numerical system is not as simple as you think.

The third chapter is the application of the machine level, said if you learn C about after (in fact, if you look at the second chapter, the evil and catch up with the C language data type), so congratulations you, next, you need to learn the assembly, or you simply don’t understand the third chapter is talking about (don’t ask why I know, because I also don’t understand). You may be wondering what pushq, MOVQ, Call, popQ, RET, % RBX, % RDX, etc., and how assembly is written. And you need to know C.

So this book is not a book for beginners at all, it can be said to be a beginner’s retreat book.

Chapter 4 is another chapter to open the door to a new world, this chapter will start directly from the various circuits, this TM immediately directly to the hardware! This paper mainly introduces the design of Y86-64 system, various gate circuits and computer pipeline. After all, the modern microprocessor is arguably one of the most complex systems man has ever created. I’ll also show you the differences between the various instruction sets.

For books related to this chapter, see Computer Composition and Design: Software/Hardware Interfaces and Coding, both very good and very thorough.

This chapter will also tell you about instruction set architectures, which are very complex, unlike application-layer architectures in the macro sense, such as the ARM architecture

This book is a book worth perusing several times.

Chapter 5: Optimizing program performance. All kinds of optimization mentioned in the general sense are inseparable from the content introduced in this chapter, including architecture layer optimization and instruction set optimization. The hard part about tuning is that you need to understand the system, and of course you need to make sure that the original program functions correctly (and has regression tests) before you optimize, otherwise it’s all in vain. For example, you need to understand the performance bottlenecks existing in the system so that you can systematically optimize it and write efficient programs.

Writing effective programs requires the following:

  • Choose the appropriate data structures and algorithms.
  • Write source code that the compiler can effectively optimize to convert into executable code.
  • Tasks are split and the method of parallel computing is adopted.

Chapter 6: Memory Hierarchies. This chapter introduces you to the evolution of storage technology, how big the performance gap is between disk, main memory, and cache, and then introduces the principle of locality, a very powerful caching technique. How cache reads and writes are mapped, the performance impact of different cache parameters, how to write cache-good code, what memory mountains are, and the illustration you’ll see on the cover.

It is highly recommended to read Ulrich Drepper’s classic 114 page paper What Every Programmer Should Know About Memory.

That’s the first part of CSAPP, which focuses on the interaction between the application and the hardware.

In part 2, which focuses on the interaction between programs and the operating system, you’ll learn how to build system-level programs using services provided by the operating system.

The second part

Chapter 7: Links. When we use Linux, there are a lot of incomprehensible errors, many of which are link errors. Link is divided into static link and dynamic link, we write C program in the execution of the process will go through the link stage.

In addition to this chapter, you can also take a look at a book that covers links very thoroughly: The programmer’s self-improvement – link, load and the library, the main teaching instruction code is how to save, how the library files with your application code static link, how the application is loaded into memory and start running, how to implement dynamic link, the working principle of C/C + + runtime, and how the operating system to provide system services are invoked. Very good Chinese book.

Chapter 8: Exception control flow. There is no program that runs perfectly. Any program can make mistakes. This chapter will show you how the operating system handles various exceptions after they occur.

Chapter 9: Virtual memory. Virtual memory is actually an extension of the memory hierarchy. As for why we have a separate chapter, virtual memory is too important. This chapter will show you how our computers with only 8 gigabytes of memory (or whatever) can run programs many times larger than themselves. Virtual memory is sometimes a popular question for interviewers: how virtual memory is mapped, what are page boxes, page tables, and so on.

The third part

The third part mainly introduces the mutual communication between programs, including IO, network programming and concurrent programming.

IO This section describes I/O reading and writing in a UNIX-like system, and mainly describes I/O interfaces at the system level.

The world of the Internet today is based on TCP/IP protocol, Socket has even become a synonym for network programming. This section introduces you to the evolution of the Web, the client-server programming model, the Web server, and finally a Web server.

The networking section is much more complex than this section, and I recommend several books for networking: Computer Networking: The Top-down Approach, TCP/IP In Detail, and Programming for UNIX Networks.

What you must know is W. Richard Stevens, whose personal website is www.kohala.com/start/

This section on concurrency focuses on how to write concurrent programs in C and how to drain the CPU to peak performance.

Recommend a website

Reading CSApp requires some basic knowledge and is not easy (at least for me).

However, there are some good sources in the industry that will get you into the book faster.

Recommend you a website, fengmuzi2003 gitbook. IO/csapp3e /

This site can be interpreted as a guide to CSAPP, introducing each chapter and recommending some good resources.

For example, he shares a b-station course on in-depth understanding of computer systems.

See here there is a surge of emotion to learn immediately?

There are also some ways to download e-books:

CSAPP whether English version have some corrections, some have been corrected, some haven’t change, you can see in www.yiligong.org/csapp3e/ feedback your corrections, some are reading, but there is some influence understanding.

Here is a hint for you. I have gone through the Chinese version of Understanding Computer Systems, for example. You can look at the printing time at the beginning and compare it with the time when these errata were raised.

That is to say, for the use of this site, you can look back to the front.

conclusion

Above is just my understanding of the book is a vulgar, I haven’t read book, but I have the C language, assembly language learning program, in addition, zhihu on one of the computer system how to read easily understood a summary answer, www.zhihu.com/question/20… I think it’s very good.

This answer contains the answer to the exercises, as well as the pre-knowledge needed to learn this book, this answer gives me the feeling that the answer Lord has been brushed several times, as the experience is worth learning.

The most the most important thing is to do the experiment, you can be in csapp.cs.cmu.edu/3e/labs.htm… To find all of csApp’s experiments.

Finally, I would like to recommend my own Github github.com/crisxuan/be… , there are a lot of hardcore articles that will definitely help you.