dma工作时cpu工不工作

CPU, also known as the microprocessor is the heart and/or brain of a computer. Lets Deep dive into the core of the computer to help us write computer programs efficiently.

CPU,也称为微处理器,是计算机的心脏和/或大脑。 让Deep深入研究计算机的核心,以帮助我们有效地编写计算机程序。

"A tool is usually more simple than a machine; it is generally used with the hand, whilst a machine is frequently moved by animal or steam power."

“工具通常比机器更简单;通常是用手操作,而机器通常是靠动物或蒸汽来移动的。”

Charles Babbage

查尔斯·巴贝奇

A computer is a machine powered mostly by electricity but its flexibility and programability has helped achieve the simplicity of a tool.

计算机是一主要由电力驱动的机器 ,但是其灵活性和可编程性有助于实现工具的简单性。

CPU is the heart and/or the brain of a computer. It executes the instructions that are provided to it. Its main job is to perform arithmetic and logical operations and orchestrate the instructions together. Before diving into the main parts let’s start by looking what are the main components of a CPU and what there roles are:

CPU是计算机的心脏和/或大脑。 它执行提供给它的指令。 它的主要工作是执行算术和逻辑运算并将指令编排在一起。 在深入探讨主要部分之前,我们先来看一下CPU的主要组件是什么以及角色是什么:

处理器的两个主要组件 (Two main components of a processor)

  • Control unit — CU

    控制单元— CU

  • Arithmetic and logical unit — ALU

    算术和逻辑单元— ALU

控制单元— CU (Control Unit — CU)

Control unit CU is the part of CPU that helps orchestrate the execution of instructions. It tells what to do. According to the instruction, it helps activate the wires connecting CPU to different other parts of computer including the ALU. Control unit is the first component of CPU to receive the instruction for processing.

控制单元CU是CPU的一部分,可帮助协调指令的执行。 它告诉该怎么办。 根据说明,它有助于激活将CPU连接到计算机其他不同部分(包括ALU)的电线。 控制单元是CPU接收处理指令的第一个组件。

There are two types of control unit:

有两种类型的控制单元:

  • hardwired control units.

    硬线控制单元

  • microprogrammable (microprogrammed) control units.

    程序控制 (微程序) 控制单元

Hardwired control units are the hardware and needs the change in hardware to add modify it’s working where as microprogrammable control unit can be programmed to change its behavior. Hardwired CU are faster in processing instruction whereas microprogrammable as more flexible.

硬连线控制单元是硬件,需要对硬件进行更改以添加修改以使其能够工作,因为可以对可编程控制单元进行编程以更改其行为。 硬接线CU处理指令的速度更快,而微编程则更为灵活。

算术和逻辑单元— ALU (Arithmetic and logical unit — ALU)

Arithmetic and logical unit ALU as name suggest does all the arithmetic and logical computations. ALU performs the operations like addition, subtraction. ALU consists of logic circuitry or logic gates which performs these operations.

顾名思义,算术和逻辑单元ALU执行所有算术和逻辑计算。 ALU执行加减运算。 ALU由执行这些操作的逻辑电路或逻辑门组成。

Most logic gates take in two input and produces one output

大多数逻辑门接受两个输入并产生一个输出

Bellow is an example of half adder circuit which takes in two inputs and outputs the result. Here A and B are the input, S is the output and C is the carry.

波纹管是半加法器电路的一个例子,它吸收两个输入并输出结果。 这里A和B是输入,S是输出,C是进位。

存储—寄存器和内存 (Storage — Registers and Memory)

Main job of CPU is to execute the instructions provided to it. To process these instructions most of the time, it needs data. Some data are intermediate data, some of them are inputs and other is the output. These data along with the instructions are stored in the following storage:

CPU的主要工作是执行提供给它的指令。 要在大多数时间处理这些指令,它需要数据。 一些数据是中间数据,其中一些是输入,其他是输出。 这些数据和说明一起存储在以下存储器中:

寄存器 (Registers)

Register is a small set of place where the data can be stored. A register is a combination of latches. Latches also known as flip-flops are combinations of logic gates which stores 1 bit of information.

寄存器是存储数据的一小部分空间。 寄存器是锁存器的组合。 锁存器也称为触发器,是存储1位信息的逻辑门的组合。

A latch has two input wire, write and input wire and one output wire. We can enable the write wire to make changes to the stored data. When the write wire is disabled the output always remains the same.

锁存器有两根输入线,写和输入线,以及一根输出线。 我们可以启用写入线来更改存储的数据。 禁用写线时,输出始终保持不变。

CPU has registers to store the data of output. Sending to main memory(RAM) would be slow as it is the intermediate data. This data is send to other register which is connected by a BUS. A register can store instruction, output data, storage address or any kind of data.

CPU具有用于存储输出数据的寄存器。 由于它是中间数据,因此发送到主存储器(RAM)会很慢。 该数据被发送到通过BUS连接的其他寄存器。 寄存器可以存储指令,输出数据,存储地址或任何类型的数据。

内存(RAM) (Memory(RAM))

Ram is a collection of register arranged and compact together in an optimized way so that it can store a higher number of data. RAM(Random Access Memory) are volatile and it’s data get’s lost when we turn off the power. As RAM is a collection of register to read/write data a RAM takes input of 8bit address, data input for the actual data to be stored and finally read and write enabler which works as it is for the latches.

Ram是寄存器的集合,这些寄存器以优化的方式排列并压缩在一起,以便可以存储更多数据。 RAM(随机存取存储器)易失,当我们关闭电源时,数据会丢失。 由于RAM是用于读取/写入数据的寄存器的集合,因此RAM接受8位地址的输入,输入要存储的实际数据的数据,最后读取和写入使能器,其对锁存器的作用相同。

什么是指示 (What are Instructions)

Instruction is the granular level computation a computer can perform. There are various types of instruction a CPU can process.

指令是计算机可执行的粒度计算。 CPU可以处理各种指令。

Instructions include:

说明包括:

  • Arithmetic such as add and subtract

    算术,例如加法减法

  • Logic instructions such as and, or, and not

    逻辑指令,例如 ,而不是

  • Data instructions such as move, input, output, load, and store

    数据指令,例如移动输入输出加载存储

  • Control Flow instructions such as goto, if … goto, call, and return

    控制流指令,例如goto如果... gotocallreturn

  • Notify CPU that the program has ended Halt

    通知CPU,该方案已经结束暂停

Instruction are provided to computer using assembly language or are generated by compiler or are interpreted in some high level languages.

指令使用汇编语言提供给计算机,或者由编译器生成,或者以某些高级语言进行解释。

These instruction are hardwired inside CPU. ALU contains the arithmetic and logical where as the control flow are managed by CU.

这些指令被硬连线到CPU内部。 ALU包含算术和逻辑,控制流由CU管理。

In one clock cycle computers can perform one instruction but modern computers can perform more than one.

在一个时钟周期内,计算机可以执行一条指令,但是现代计算机可以执行多条指令。

A group of instructions a computer can perform is called an instruction set.

计算机可以执行的一组指令称为指令集

CPU时钟 (CPU clock)

Clock cycle

时钟周期

The speed of a computer is determined by its clock cycle. It is the number of clock periods per second a computer works on. A single clock cycles are very small like around 250 * 10 *-12 sec. Higher the clock cycle faster the processor is.

计算机的速度取决于其时钟周期。 它是计算机每秒工作的时钟周期数。 一个时钟周期非常小,大约为250 * 10 * -12秒。 时钟周期越高,处理器越快。

CPU clock cycle is measure in gHz(Gigahertz). 1gHz is equal to 10 ⁹ Hz(hertz). A hertz means a second. So 1Gigahertz means 10 ⁹ cycles per second.

CPU时钟周期以GHz( 千兆赫 )的措施。 1gHz等于10⁹Hz( 赫兹 )。 赫兹表示一秒钟。 因此1 GHz意味着每秒10个周期。

The faster the clock cycle, the more instructions the CPU can execute.Clock cycle = 1/clock rateCPU Time = number of clock cycle / clock rate

时钟周期越快, CPU可执行的指令越多。时钟周期= 1 /时钟速率CPU时间=时钟周期数/时钟速率

This means to improve CPU time we can increase clock rate or decrease number of clock cycle by optimizing the instruction we provide to CPU. Some processor provide the ability to increase the clock cycle but since it is physical changes there might be over heating and even smokes/fires.

这意味着可以通过优化提供给CPU的指令来缩短CPU时间,从而提高时钟速率或减少时钟周期数。 某些处理器具有增加时钟周期的能力,但由于是物理变化,因此可能会过热,甚至冒烟/起火。

指令如何执行 (How does an instruction get executed)

Instructions are stored on the RAM in a sequential order. For a hypothetical CPU Instruction consists of OP code(operational code) and memory or register address.

指令按顺序存储在RAM中。 对于一个假设的CPU指令,它由OP代码(操作代码)和存储器或寄存器地址组成

There are two registers inside a Control Unit Instruction register(IR) which loads the OP code of the instruction and Instruction address register which loads the address of the current executing instruction. There are other registers inside a CPU which stores the value stored in the address of the last 4 bits of a instruction.

在控制单元指令寄存器(IR)中有两个寄存器,用于加载指令的OP代码;在指令地址寄存器中 ,用于加载当前执行指令的地址。 CPU内还有其他寄存器,用于存储存储在指令后4位地址中的值。

Let’s take an example of a set of instruction which adds two number. The following are the instructions along with there description:

让我们以一组指令加两个数字为例。 以下是说明以及说明:

STEP 1 — LOAD_A 8:

步骤1 — LOAD_A 8:

The instruction is saved in RAM initially as let’s say <1100 1000>. The first 4 bit is the op code. This determines the instruction. This instruction is fetched into the IR of the control unit. The instruction is decode to be load_A which means it needs to load the data in the address 1000 which is the last 4 bit of the instruction to register A.

最初将指令保存在RAM中,例如<1100 1000>。 前4位是操作码。 这确定了指令。 该指令被提取到控制单元的IR中。 该指令被解码为load_A,这意味着它需要将数据加载到地址1000中,该地址是指令A的最后4位。

STEP 2 — LOAD_B 2

步骤2 — LOAD_B 2

Similar to above this loads the the data in memory address 2 (0010) to CPU register B.

与上面类似,这会将内存地址2(0010)中的数据加载到CPU寄存器B。

STEP 3— ADD B A

第3 步-添加BA

Now the next instruction is to add these two numbers. Here the CU tells ALU to perform the add operation and save the result back to register A.

现在,下一条指令是将这两个数字相加。 此处,CU告诉ALU执行加法运算并将结果保存回寄存器A。

STEP 4 — STORE_A 23

步骤4 — STORE_A 23

This is a very simple set of instruction that helps add two numbers.

这是一组非常简单的指令,有助于将两个数字相加。

We have successfully added two numbers!

我们已经成功地添加了两个数字!

总线 (BUS)

All the data between CPU, register, memory and IO devise are transferred via bus. To load the data to memory that it has just added, the CPU puts the memory address to address bus and the result of the sum to data bus and enables the right signal in control bus. In this way the data is loaded to memory with the help of the bus.

CPU,寄存器,存储器和IO设备之间的所有数据都通过总线传输。 要将数据加载到刚刚添加的存储器中,CPU将存储器地址放入地址总线,并将总和结果放入数据总线,并在控制总线中启用正确的信号。 这样,数据将在总线的帮助下加载到内存中。

快取 (Cache)

CPU also has mechanism to prefetch the instruction to its cached. As we know there are millions of instruction a processor can complete within a second. This means that there will be more time spent in fetching the instruction from RAM than executing them. So the CPU cache prefetches some of the instruction and also data so that the execution gets fast.

CPU还具有将指令预取到其缓存的机制。 众所周知,处理器可以在一秒钟内完成数百万条指令。 这意味着从RAM提取指令要比执行指令花费更多的时间。 因此,CPU缓存会预取一些指令以及数据,以便快速执行。

If the data in cache and operating memory is different the data is marked as a dirty bit.

如果缓存和操作存储器中的数据不同,则将数据标记为脏位

指令流水线 (Instruction pipelining)

Modern CPU uses Instruction pipelining for parallelization in instruction execution. Fetch, Decode, Execute. When one instruction is in decode phase the CPU can process another instruction for fetch phase.

现代CPU将指令流水线用于 指令执行中的并行化。 提取,解码,执行。 当一条指令处于解码阶段时,CPU可以为提取阶段处理另一条指令。

This has one problem when one instruction is dependent on another. So processors execute the instruction that are not dependent and in different order.

当一条指令依赖于另一条指令时,这将产生一个问题。 因此,处理器以不相同的顺序执行不相关的指令。

多核计算机 (Multi core computer)

It is basically the different CPU but has some shared resource like the cache.

它基本上是不同的CPU,但是有一些共享资源,例如缓存。

性能 (Performance)

Performance of CPU is determined by it’s execution time.Performance = 1/execution time

CPU的性能取决于执行时间,性能= 1 /执行时间

let’s say it takes 20ms for a program to execute. The performance of CPU is 1/20 = 0.05msRelative performance = execution time 1/ execution time 2

假设一个程序执行需要20毫秒。 CPU的性能为1/20 = 0.05ms相对性能=执行时间1 /执行时间2

The factor that comes under consideration for a CPU performance is the instruction execution time and the CPU clock speed. So to increase the performance of a program we either need to to increase the clock speed or decrease the number of instruction in a program. The processor speed is limited and modern computer’s with multi core can support millions of instructions a second. But if the program we have written has a lot of instructions this will decrease the overall performance.

CPU性能要考虑的因素是指令执行时间和CPU时钟速度。 因此,要提高程序的性能,我们要么需要提高时钟速度,要么需要减少程序中的指令数量。 处理器速度有限,具有多核功能的现代计算机每秒可支持数百万条指令。 但是,如果我们编写的程序有很多指令,将会降低整体性能。

Big O notation determines with the given input how the performance will be affected.

大O表示法使用给定的输入确定如何影响性能。

There are a lot of optimization done in CPU to make it faster and perform as much as it can. While writing any program we need to consider how reducing the number of instruction we provide to CPU will increase the performance of computer program.

CPU中进行了大量优化,以使其更快并尽可能地发挥性能。 在编写任何程序时,我们需要考虑减少提供给CPU的指令数量将如何提高计算机程序的性能。



Also Posted on Milap Neupane Blog: How Does a CPU work

还发布在Milap Neupane博客上: CPU如何工作

翻译自: https://www.freecodecamp.org/news/how-does-a-cpu-work/

dma工作时cpu工不工作

dma工作时cpu工不工作_CPU如何工作?相关推荐

  1. 7.STM32中对DMA_Config()函数的理解(自定义)测试DMA传输数据时CPU还可继续工作其他的事

    STM32中对DMA_Config()函数的理解(自定义):

  2. 计算机硬盘正在工作时,让硬盘永远工作在最佳状态

    系统显示"TRACK 0 AD,DISK UNUSABLE",意思为"零磁道损坏,硬盘无法使用"或用磁盘扫描程序扫描其它硬盘时其0扇区出现红色"B&q ...

  3. 给软件测试人员找工作时的一些建议

    陆陆续续做了几年的软件测试人员招聘,筛选过上千份简历,面试(也有电话面试)过很多人,有一些感受,总结一下,给软件测试从业者们一些参考,也当是梳理一下自己的思路.总体感觉就是,软件测试这个行业里,合格的 ...

  4. 搜狗回应“统计加班时长裁员”:工作时长符合国家规定

    [TechWeb]近日,有搜狗员工爆料公司将要统计加班时长裁人,身边很多同事每天坚持够至少11个小时.搜狗官方与搜狗CEO王小川都进行了回应. 搜狗CEO王小川在脉脉回应公司没这样的要求.并表示,&q ...

  5. 若微型计算机在工作时突然断电,16秋《计算机基础》作业1

    16秋<计算机基础>作业1 一.单选题(共 25 道试题,共 100 分.) 1. 若微型计算机在工作时突然断电,则( )中的信息将会全部丢失. A. ROM B. RAM C. ROM和 ...

  6. 若微型计算机在工作时突然断电,北语网院20春《计算机基础》作业_1234

    20春<计算机基础>作业_1$ ?$ ]0 W6 W) g# s 奥鹏作业答案可以联系QQ 761296021' q6 F0 Z, D" r% r! n 1.[单选题] 可用Wo ...

  7. CPU降温软件测试自学,CPU降温软件真的有用吗工作原理是什么

    CPU温度是一个很重要参数,我们都会采取物理和软件等方法对CPU降温,不过也有网友怀疑了,这些软件真的能让CPU降温吗?具体情况一起看看! CPU降温软件真的有用吗 如果要让CPU在不需要使用的时候休 ...

  8. 若微型计算机在工作时突然断电,2014计算机软考程序员考前模拟试题

    无忧考网为大家收集整理了<2014计算机软考程序员考前模拟试题>供大家参考,希望对大家有所帮助!!! 1.与十六进制数值CD等值的十进制数是 A.204 B.205 C.206 D.203 ...

  9. 谷歌技术主管:当我们选择工作时,什么最重要?

    2019独角兽企业重金招聘Python工程师标准>>> 一位年轻的工程师最近问我如何从几个工作机会中选择.是应该接受更成熟的高科技公司,像谷歌或Facebook的软件工程师职位,还是 ...

最新文章

  1. 【机器学习】RNN循环神经网络
  2. Spring Boot 实现定时任务的 4 种方式
  3. pfSense DMZ配置
  4. 【算法基础】数据结构导论第二章-线性表.pptx
  5. jpa mysql查找_jpa查找数据库最新一条消息
  6. 403 forbidden nginx_5,Logstash正则提取Nginx日志 - pwcc
  7. ORACLE RAC心跳网络
  8. 过程FMEA(PFMEA)步骤一:策划与准备
  9. java PDF模板生成并导出(文字、表格、图片)
  10. 拆解下3个大厂(抖音,滴滴,拼多多)的数据分析案例
  11. 微信域名防封系统-微信域名预拦截预防封
  12. kettle优化之提高MySQL读写速度
  13. IO复用功能占用时,普通GPIO功能使用
  14. 开发android 输入法,Android输入法开发实例解析 Android开发技术
  15. PPT立方体三面同色
  16. java swf,SWF文件结构大解剖
  17. 单一修改高程值lisp_浅谈AutoCAD中修改高程的四种方法
  18. jdk中Calendar的使用
  19. cuda10.2安装失败方案汇总
  20. Senparc.Weixin.MP SDK 微信公众平台开发教程(六):了解MessageHandler

热门文章

  1. Js打印表格时部分边框不显示(table 标签)
  2. 【leetcode】589. N-ary Tree Preorder Traversal
  3. jmeter启动警告项解决方案
  4. Bzoj2780: [Spoj]8093 Sevenk Love Oimaster
  5. CentOS 7磁盘格式化
  6. python语言基础汇总
  7. iOS WebviewJavascriptBridge 源码研读笔记
  8. iOS更改AppIcon
  9. 积少成多 Flash(ActionScript 3.0 Flex 3.0) 系列文章索引
  10. Python统计字符串中的中英文字符、数字空格,特殊字符