CS:APP第一章知识总结

一、历史知识
C was designed to implement the Unix operating system.

The GNU project has developed an environment with all the major
components of a Unix operating system, except for the kernel, which was developed separately by the Linux project. (互补、相辅相成)

P46还有一段Unix, Posix, and the Standard Unix Specification,太臭太长了,要看再去查吧。

二、以helloworld程序为例
编译过程
硬件组织结构
Buses are typically designed to transfer fixed-size chunks of bytes known as words.
Each I/O device is connected to the I/O bus by either a controller or an adapter.(将来自CPU的逻辑指令转换为设备可以识别和执行的控制信号)
Controllers are chip sets in the device itself or on the system’s main printed circuit board (often called the motherboard). An adapter is a card that plugs into a slot on the motherboard.
从键入./hello到屏幕显示hello world,可以用箭头在图1.4中标出数据流向。

三、operation system’s abstraction(process, virtual memory and files)
不同等级的抽象

The operating system(the process) provides the illusion that the program is the only one running on the system.

A single CPU can appear to execute multiple processes concurrently by having the processor switch among them, namely context switching.
context switch
The kernel is the portion of the operating system code that is always resident in memory.Note that the kernel is not a separate process. Instead, it is a collection of code and data structures that the system uses to manage all the processes(for example, the transition from one process to another).

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.It is easier to share data between multiple threads than between multiple processes, and threads are typically more efficient than processes.

linux虚拟内存空间

四、Amdahl’s Law
To significantly speed up the entire system, we must improve the speed of a very large fraction of the overall system.

五、concurrency and parallelism

5.1 Thread-level parallelism
Multiprocessors are becoming prevalent with the advent of multicore processors and hyper-threading.
在这里插入图片描述
(注意L1、L2、L3的差异)

Hyperthreading, sometimes called simultaneous multi-threading, is a technique that allows a single CPU to execute multiple flows of control. It involves having multiple copies of some of the CPU hardware, such as program counters and register files, while having only single copies of other parts of the hardware, such as the units that perform floating-point arithmetic.(平时说的四核八线程,指的就是超线程)
https://blog.csdn.net/cheng__lu/article/details/98884263(超线程、多核、多线程)
在任何时刻,一个核里的执行单元都是不可能完全占满的,占不满的情况下,就有能力让另外一个线程执行了,但如果两个线程都需要同样的执行单元(比如都需要进行浮点计算),那么有一个线程就需要等待,此时线程的实际执行时间就是不可控的。(https://www.zhihu.com/question/59721493/answer/168339157)
个人理解:核内有不同种类的执行单元,它们的繁忙程度不同(上面csdn链接提到的服务生和大厨),如果能增加较繁忙执行单元的数量,那么就能以较小的成本(相较直接加物理核)达到类似的效果。

5.2 instruction-level parallelism
流水线和超标量,详情见后续。

5.3 single instruction, multiple data parallelism
These SIMD instructions are provided mostly to speed up applications that
process image, sound, and video data.
详情见后续。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值