How to learn "In-depth understanding of computer systems"?

Original link: abused by CSAPP

In the past two weekends, I went to the library to brush CSAPP, and I couldn't stop. This feeling of not understanding but forcing myself to read it despite the pain really fascinated me.

image-20211025202910686

This book really made me realize what it means to read for five minutes and rest for two hours.

But don't imitate me. I believe that everyone sitting here is definitely better than me. Why? Because I recommend an artifact to you later, so first let's introduce this book.

image-20211025203724031

This book is divided into twelve chapters in total. I have drawn a mind map for you, which is relatively simple and clear.

image-20211025225218317

The first chapter is a chapter with an outline and nature. From a hello world program, it leads to C, leads to UNIX, Linux, leads to the compilation process of C language programs, leads to cache, system hardware composition, storage structure, virtual memory, network programming, Concurrent programming, very cool. Although the content of the first chapter is not difficult to understand, it is a chapter that can make people self-confidence . This chapter can make you feel excited because the content is not difficult, but it can open up your ideas and make you feel better. knowledge systems are linked together.

first part

The content of the second chapter is relatively boring, I personally think that a certain C language foundation is required, although the introduction of this book says that if you have Java foundation. . . . . .

image-20211025230317641

It is still a bit difficult, so it is recommended to learn a wave of C.

Don't block me, I'm here for C language. Here are two books on C language. The first book is "C Primer Plus". This book is to smash C language and teach you by hand. In addition, "C Programming Language" Not bad.

The second chapter mainly talks about the storage method of data in the computer, the basic data types and the representation of various complement and inverse codes. In short, if you don't know C, this chapter is a bit sleepy (the reason may be that you don't understand it very well), but the second chapter is actually very well written. When you read the second chapter of this book, you may It is found that what you call (understanding) is just your wishful thinking, and the numerical system is far from being as simple as you think.

The third chapter is the machine-level representation of the program. If you have learned C almost well (in fact, if you only read the second chapter, you can make up for the bad data types and operations of the C language), then congratulations, the next step You have to study it 汇编, otherwise you won't understand what the third chapter is talking about (don't ask me why I know it, because I can't understand it either). You might be wondering what things like pushq, movq, call, popq, ret , %rbx, %rdx , etc. do, and how assembly is written. And you also need to know the C language.

In this way, this book is not a book for beginners at all, and it can also be said to be a book for beginners to quit.

Chapter 4 is another chapter that opens the door to a new world. This chapter will start directly with various circuits, and this TM will go directly to the hardware! It mainly talks about the design of the Y86-64 system, various gate circuits, and leading computer pipelines. After all , modern microprocessors are arguably one of the most complex systems ever created by humans . It will also explain the difference between the various instruction sets.

For books related to this chapter, check out Computer Composition and Design: Software/Hardware Interface and Coding, both of which are very good and thorough.

This chapter will also talk to you about the instruction set architecture. These architectures are different from the application layer architecture in the macro sense and are very complex. For example, the following ARM architecture

image-20211026083152130

This book is a book worth reading N times.

Chapter 5: Optimizing program performance, the various optimizations mentioned in the general sense now, whether it is architecture layer optimization, instruction set optimization and other cores, are inseparable from the content introduced in this chapter. The difficulty of optimization is that you need to have a full understanding of the system, of course, before you do optimization, you must first ensure that the original program functions correctly (and has regression tests) , otherwise everything will be in vain. For example, you need to understand the performance bottlenecks existing in the system, in order to systematically optimize, and then you can write efficient programs.

Writing efficient programs requires the following:

  • Choose appropriate data structures and algorithms.
  • Write source code that the compiler can efficiently optimize to convert into executable code.
  • The task is split, and the method of parallel computing is adopted.

Chapter 6: Memory Hierarchy This chapter will introduce you to the development of storage technology, how big the performance gap between disk, main memory, and cache is, and then introduce the principle of locality, a very powerful caching technology. How cache reads and writes are mapped, the performance impact of different parameters of the cache, how to write good code for caches, what a memory mountain is, and the illustrations you'll see on the cover.

When reading this chapter, I highly recommend reading the 114-page classic paper What Every Programmer Should Know About Memory by Ulrich Drepper .

The above is the first part of CSAPP. The first part mainly introduces the interaction between the program and the hardware.

While the second part focuses on the interaction between programs and operating systems, you will learn how to use the services provided by the operating system to build system-level programs.

the second part

Chapter 7: Linking, when we use Linux, there are many incomprehensible errors in many cases, many of which are link errors. Linking is divided into static linking and dynamic linking. The C program we write will go through the linking stage during the execution process.

image-20211026162805480

In addition to the content of this chapter, you can also read a book that talks about links very thoroughly: "Programmer's Self-Cultivation - Linking, Loading and Libraries", which mainly teaches how code instructions are saved and libraries. How files are statically linked with application code, how applications are loaded into memory and start running, how dynamic linking is implemented, how C/C++ runtime libraries work, and how system services provided by the operating system are invoked. A very good domestic book.

Chapter 8: Exception Control Flow, there is no perfect program in the world, and any program will make mistakes. These errors may be errors during thread execution, system call exceptions, page mapping errors, and so on. This chapter will show you how the operating system handles various exceptions when they occur.

Chapter 9: Virtual memory, virtual memory is actually a derivation of the memory hierarchy. As for why it is a separate chapter, because virtual memory is too important. This chapter will show you why our computer has only 8G (or whatever) of memory but can run many times more programs than itself. Virtual memory is sometimes a point that interviewers like to ask: how is virtual memory mapped, what is page frame, page table 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 part introduces the I/O reading and writing under the Unix-like system, and mainly introduces the I/O interface at the system level.

Today, the vast world in the Internet is based on the TCP/IP protocol, and Socket has even become a synonym for network programming. This part mainly introduces you to the changes of the network, what is the client-server programming model, Web server, and finally takes you to write a Web server.

This part of the network is far more complicated than what this chapter introduces. I recommend several books for this part of the network: "Computer Networks: Top-Down Method", "TCP/IP Detailed Explanation", "UNIX Network Programming".

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

This chapter on concurrency mainly introduces how to write concurrent programs in C, how to drain the CPU, and let it play its peak performance.

recommend a website

Reading the csapp book still requires a certain foundation, and it is not so easy to read (at least for me).

However, there are some good resources in the industry to get you deeper into this book faster .

Recommend a website to everyone, https://fengmuzi2003.gitbook.io/csapp3e/

This website can be understood as a guide website for CSAPP, which introduces each chapter and recommends some good resources.

For example, he shared the B station course of in-depth understanding of computer systems.

image-20211026170441694

Seeing this, are there any excited people who want to learn it right away?

There are also some download channels for e-books:

image-20211026170730582

Both Chinese and English versions of CSAPP have some errata, some have been corrected, some have not been corrected, you can feedback the errata you see at http://www.yiligong.org/csapp3e/, some are affecting reading Yes, but some are comprehensible.

Here is a little hint for you. I have gone through it roughly. Take the Chinese version of "In-depth Understanding of Computer Systems" as an example. You can look at the printing time at the very beginning, and then compare the time when these errata were proposed. Many previous errata have been corrected.

In other words, for the use of this website, you can look from the back to the front.

image-20211026171149888

Summarize

The above is just my vulgar understanding of this book. I haven't read the book yet, but I already have a study plan for C language and assembly language. In addition, there is an article on "How to Read In-depth Computer Systems" on Zhihu. A summary answer, https://www.zhihu.com/question/20402534/answer/1670374116 I think it is still very good.

This answer contains the answers to the practice questions, as well as the prerequisite knowledge needed to learn this book. This answer gives me the feeling that the answerer has read it several times, and the experience as a past person is worth learning.

The most important thing is to do experiments, you can find all the experiments of csapp at http://csapp.cs.cmu.edu/3e/labs.html.

Finally, I recommend my own Github https://github.com/crisxuan/bestJavaer, there are a lot of hard-core articles in it, which will definitely help you.

Guess you like

Origin blog.csdn.net/qq_36894974/article/details/120986582