《CS:APP》 chapter 1 A Tour of Computer Systems 笔记_JasonLeaster的博客-程序员宅基地

技术标签: Days_with_CS:APP  operating system  CSAPP  

A Tour of Computer Systems


          If you dedicate yourself to learning the concepts in this book, then you will be on your way to becoming a rare “power pro-grammer”

 就冲这句话,就已经很“霸气”了。


一切从这里开始:
#include <stdio.h>

int main()
{
        printf("hello world!\n");

        return 0;
}




1.1 Information Is Bits + Context


Everthing is file。 多么漂亮的极简主义啊!

[email protected]:/CSAPP/chapter_1$ od -t oCc ./pro_1_1.c 
0000000 043 151 156 143 154 165 144 145 040 074 163 164 144 151 157 056
          #   i   n   c   l   u   d   e       <   s   t   d   i   o   .
0000020 150 076 012 012 151 156 164 040 155 141 151 156 050 051 012 173
          h   >  \n  \n   i   n   t       m   a   i   n   (   )  \n   {
0000040 012 011 160 162 151 156 164 146 050 042 150 145 154 154 157 040
         \n  \t   p   r   i   n   t   f   (   "   h   e   l   l   o    
0000060 167 157 162 154 144 041 134 156 042 051 073 012 012 011 162 145
          w   o   r   l   d   !   \   n   "   )   ;  \n  \n  \t   r   e
0000100 164 165 162 156 040 060 073 012 175 012
          t   u   r   n       0   ;  \n   }  \n
0000112



      咳咳、、、C是系统级别的编程语言,同样也可以做应用,但是不是很方便。像C++和java之类的就做了很多抽象,面向对象相对容易。所以我特别不喜欢那种黑我大C的人,动不动就把C踢出窗外,你可知道C经历了几十年的风雨,依然在TIOBE上面的排名第一。


      C is the language of choice for system-level programming, and there is a huge installed base of application-level programs as well. However, it is not perfect for all programmers and all situations.C pointers are a common source of confusion and programming errors. C also lacks explicit support for useful abstractions such as classes, objects, and exceptions. Newer languages such as C++ and Java address these issues for application-level programs。






1.2 Programs Are Translated by Other Programs into Different Forms



         In order to run hello.c  on the system, the individual C statements must be translated by other programs  into a sequence of low-level machine-language instructions. These instructions are  then packaged in a form called an executable object programand stored as a binary  disk file. Object programs are also referred to as executable object files.







1.3 It Pays to Understand How Compilation Systems Work




         For simple programs such as hello.c , we can rely on the compilation system produce correct and efficient machine code. However, there are some important reasons why programmers need to understand how compilation systems work:


       Optimizing program performance.  

       Understanding link-time errors.In our experience, some of the most perplexing programming errors are related to the operation of the linker, especially when you are trying to build large software systems.


       Avoiding security holes.For many years, buffer overflow vulnerabilities have accounted for the majority of security holes in network and Internet servers.




1.4 Processors Read and Interpret Instructions Stored in Memory



           If the first word of the command line does not correspond to a built-in shell command, then the shell assumes that it is the name of an executable file that it should load and run. 


1.4.1 Hardware Organization of a System


o(︶︿︶)o  虽然系统的硬件大体构架我在不同的书上面看了N次了,但是。。但是还是记不全。。。

再来一次




Buses

          Most machines today have word sizes of either 4 bytes (32 bits) or 8 bytes (64 bits). For the sake of our discussion here, we will assume a word size of 4 bytes, and we will assume that buses transfer only one word at a time.


I/O Devices

           Input/output (I/O) devices are the system’s connection to the external world. Our example system has four I/O devices: a keyboard and mouse for user input, a display for user output, and a disk drive (or simply disk) for long-term storage of data and programs. 


Main Memory

          The main memoryis a temporary storage device that holds both a program and the data it manipulates while the processor is executing the program. Physically, main memory consists of a collection ofdynamic random access memory (DRAM)。




Processor


        The central processing unit (CPU), or simply processor, is the engine that inter-prets (or executes ) instructions stored in main memory. 


       Load: Copy a byte or a word from main memory into a register, overwritingthe previous contents of the register.

       Store: Copy a byte or a word from a register to a location in main memory,overwriting the previous contents of that location.

       Operate: Copy the contents of two registers to the ALU, perform an arithmetic operation on the two words, and store the result in a register, overwriting the previous contents of that register.

       Jump: Extract a word from the instruction itself and copy that word into the program counter (PC), overwriting the previous value of the PC。







1.4.2 Running the hello Program



 










1.5 Caches Matter



        Because of physical laws, larger storage devices are slower than smaller storage devices.

        Even more troublesome, as semiconductor technology progresses over the years, this processor-memory gap continues to increase.



        The L1 and L2 caches are implemented with a hardware technology known as static random access memory (SRAM).


1.6 Storage Devices Form a Hierarchy










1.7 The Operating System Manages the Hardware








1.7.1 Processes


         A process is the operating system’s abstraction for a running program.  

         Traditional systems could only execute one program at a time, while newer multi-core processors can execute several programs simultaneously. In either case, a single CPU can appear to execute multiple processes concurrently by having the processor switch among them



1.7.2 Threads


         Although we normally think of a process as having a single control flow, in modern systems a process can actually consist of multiple execution units, called threads, each running in the context of the process and sharing the same code and global data.





1.7.3 Virtual Memory

        Virtual memory is an abstraction that provides each process with the illusion that it has exclusive use of the main memory. Each process has the same uniform view of memory, which is known as its virtual address space .







1.7.4 Files


       A file is a sequence of bytes, nothing more and nothing less.
简洁啊!!


1.8 Systems Communicate with Other Systems Using Networks









1.9 Important Themes


重头戏了。。。

1.9.1 Concurrency and Parallelism


        we want them to run faster. Both of these factors improve when the processor does more things at once. We use the term concurrency to refer to the general concept of a system with multiple, simultaneous activities, and the term parallelism to refer to the use of concurrency to make a system run faster。






Thread-Level Concurrency







Instruction-Level Parallelism

            modern processors can execute multiple instructions at one time, a property known as instruction-level parallelism。




Single-Instruction, Multiple-Data (SIMD) Parallelism


1.9.2 The Importance of Abstractions in Computer Systems






         On the operating system side, we have introduced three abstractions: files as an abstraction of I/O, virtual memory as an abstraction of program memory, and processes as an abstraction of a running program. 




大笑第一章积累词汇:待更新























版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u011368821/article/details/24377967

智能推荐

bootstrap 圆形按钮_张高伟的博客-程序员宅基地_bootstrap圆形按钮

&amp;lt;button type=&quot;button&quot; class=&quot;btn btn-default btn-circle&quot;&amp;gt;&amp;lt;i class=&quot;glyphicon glyphicon-ok&quot;&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;button type=&quot;button&quot; class=&quot;btn btn-primary

关系型数据库设计:三大范式的通俗理解_爱吃榴莲的兔兔的博客-程序员宅基地

目前关系数据库有六种范式:第一范式(1NF)、第二范式(2NF)、第三范式(3NF)、巴斯-科德范式(BCNF)、第四范式(4NF)和第五范式(5NF,又称完美范式)。而通常我们用的最多的就是第一范式(1NF)、第二范式(2NF)、第三范式(3NF),也就是本文要讲的“三大范式”。第一范式(1NF):要求数据库表的每一列都是不可分割的原子数据项。举例说明:在上面的表中,“家庭信息”和“学校信息”列均不满足原子性的要求,故不满足第一范式,调整如下:可见,调整后的每一列都是不可再分的,因...

wamp mysql5.6_wamp中mysqld占用内存大mysql5.6 | 学步园_Alvis-lby的博客-程序员宅基地

网上常用方法,但不适用。innodb_buffer_pool_size=576M -&gt;256M InnoDB引擎缓冲区占了大头,首要就是拿它开刀query_cache_size=100M-&gt;16M查询缓存tmp_table_size=102M-&gt;64M临时表大小key_buffer_size=256m...

【程序源代码】轻量级的在线团队协作工具_程序源代码的博客-程序员宅基地

关键字:工具正文|内容01—【正文】WookTeam(全开源)是一款轻量级的在线团队协作工具,提供各类文档工具、在线思维导图、在线流程图、项目管理、任务分发、即时IM,知识库管理等工...

angular部分报错处理_要我怎么办的博客-程序员宅基地

一,报错:Could not find module &quot;@angular-devkit/build-angular&quot; from。。。解决方式: npm i --save-dev @angular-devkit/build-angular二,报错:You seem to not be depending on &quot;@angular/core&quot; and/or &quot;rxjs&quot;. This is an...

使用PHP 开发基于Web 服务的应用程序_Youngerchen的博客-程序员宅基地

<br />PHP SOAP 扩展<br />SOAP 的全称为简单对象访问协议 (Simple Object Access Protocol)。它是一种基于 XML 的,可扩展的通信协议。SOAP 提供了一种标准,使得运行在不同平台上并使用不同的编程语言编写的可以互相进行通信。SOAP 的可扩展性和平台无关性使得它被广泛用作 Web服务的通信协议。应用程序<br />由于 Java 语言提供了对 SOAP 的良好支持,通常基于 Web 服务的应用程序使用 Java 语言编写。对于广大的 PHP 程序员来说

随便推点

Django 定义属性总结_louis_bupt的博客-程序员宅基地

本文从网上搜集了一些 Django 定义属性的知识并进行整理,大家可以及时收藏方便随时查看。内容包括概述、库、逻辑删除、字段类型、字段选项、关系

oracle指定列为主键,【ORACLE】组合主键的某一列可以为NULL吗?_勤婧知浩的博客-程序员宅基地

(一)主键的定义可以唯一标识一行数据,主键由一列或多列组成。这些列要求非空且唯一。(二)测试--创建一个表,并设置一个组合主键drop table TEST_CON;create table TEST_CON(id int,name varchar2(20),description varchar2(100));alter table TEST_CON add constraint TEST_CO...

Post-PC世界就在我们的正前方_yuanmeng001的博客-程序员宅基地

<[email protected] {margin:2cm}p {margin-bottom:0.21cm}a:link {}-->一般而言,所谓“Post-PC“就是“PC后”(或”后PC“)的意思,大致的意思是,在个人计算机全球大流行之后的世界。那么,这个后PC世界是个什么样子呢?近期以来,IT业界出现一些奇怪现象:Mini-PC盛行起来了,比如:英国的山莓“馅

z832.cn tz.php,kernel.php_weixin_30273263的博客-程序员宅基地

/*!* ATTENTION: THIS FREE LICENSE IS ONLY FOR PERSONAL NON-COMMERCIAL USER. FOR COMMERCIAL PURPOSES, PLEASE PURCHASE A COMMERCIAL LICENSE! ** module: Centcount Analyticsb Free Kernel PHP Code ** versi...

前端性能优化_小XiaXia的博客-程序员宅基地

一、地址栏输入URL发生了什么大致分为:DNS域名解析、TCP连接、HTTP请求、处理请求返回HTTP响应、页面渲染、关闭连接首先会进行 url 解析,根据 dns 系统进行 ip 查找根据 ip 就可以找到服务器,然后浏览器和服务器会进行 TCP 三次握手建立连接,如果此时是 https 的话,还会建立 TLS 连接以及协商加密算法(注意的问题"https 和 http 的区别")连接建立之后浏览器开始发送请求获取文件,此时这里还会出现一种情况就是缓存,建立连接后是走缓存还是直接重新获取,需要看

php 捕获warning,php错误及异常捕捉_八位数花园的博客-程序员宅基地

1、php 错误常量及含义:值常量描述1E_ERRORFatal run-time errors. Errors that can not be recovered from.Execution of the script is halted 致命错误2E_WARNINGNon-fatal run-time errors. Execution of the script is nothalted警...

推荐文章

热门文章

相关标签