dma工作时cpu工不工作_CPU如何工作?
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 , 如果... goto , call和return
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工不工作
相关文章:

pymsql学习笔记
pymsql学习笔记 1. 执行SQL #!/usr/bin/env python # -*- coding:utf-8 -*- import pymysql# 创建连接 conn pymysql.connect(host127.0.0.1, port3306, userroot, passwd123, dbt1) # 创建游标 cursor conn.cursor()# 执行update,并返回收影响行数, print(effect…

UITextView高度根据内容变化
1. 添加内容变化的通知响应事件:[[NSNotificationCenter defaultCenter] addObserver:self selector:selector(textChanged:) name: UITextViewTextDidChangeNotification object:nil]; 2 实现方法 - (void)textChanged:(NSNotification *)notification{ …

一:搭建一套免费的serverless网站
因为公司需求,需要快速搭建一个公司内部能够访问的资源查看管理的 PC网站,因为没有服务器,没有后端开发,又要快速上线使用,那么 serverless 就成了我的首选方案,下面从零开始搭建。 步骤一. 准备工作 1. …

monorepo_Monorepo开发的要点
monorepoThe word monorepo is a combination between “mono”, as in the Greek word mnos (in translation, alone) and an abbreviation of the word repository. A simple concept if taken verbatim: one lonely repository. The domain is software engineering so we’…

记一次 HTTP信息头管理器使用 的重要性
今天在测试中遇到了一个问题 使用JMeter时请求相关地址参数及方法都填写正确,但是相应数据返回始终不对,例如 查看取样器结果显示 200 正常,但响应数据不符合正常的结果。 经反复检查发现问题如下: 1)没有添加HTTP信息…

手把手,教你怎样用命令行给apk签名
最近因为项目上线,要配合运营的童鞋们上传各渠道apk,其中,搜狗的渠道因为迁移问题,需要给一个他们提供的空的apk签名,然后用公司的签名文件进行签名 没办法,只能手动给apk签名,网上搜索一片均不太完善&…

uniapp富文本复制文字内容
设置样式即可 text,span,p {user-select: text;-webkit-user-select: text;}

创建react应用程序_通过创建食谱应用程序来学习在React中使用API
创建react应用程序Learn how to use external APIs with React and React Router in a full tutorial from Hamza Mirza. This tutorial shows how to create a recipe finder application in React.在Hamza Mirza的完整教程中,了解如何将外部API与React和React Rou…

dogse入门指南
dogse入门指南 Dogse作为游戏服务端引擎,目前只包含游戏服务端的核心部分,但这也是最核心的部分。它全部使用.net c#开发,充分兼顾了程序性能与代码编写的准确性与易用性,再加上以vs作为开发工具,极大的提升代码的编写…

Python maketrans() 方法
描述 Python maketrans() 方法用于给 translate() 方法创建字符映射转换表。 可以只接受一个参数,此时这个参数是个字典类型(暂不研究这种情况)。 对于接受两个参数的最简单的调用方式,第一个参数是字符串,表示需要转换…

二:serverless网站数据库操作
操作数据库API文档 第一篇,搭建一套免费的serverless网站 一,创建集合,进入控制台 登录腾讯云后台 打开云开发控制台 可以新建集合,新建集合后点击集合名称即可批量导入导出数据库集合的数据,还可以设置数据库访问的…

我希望支持JavaScript GraphQL实现的API
The GraphQL schema language is great! It is certainly the best way to communicate anything about a GraphQL service. No wonder all documentations now use it!GraphQL 模式语言很棒! 当然,这是传达与GraphQL服务有关的任何东西的最佳方法。 难怪…

2_Selenium对象识别
1 准备工作 firebug和firepath我们使用xpath进行元素定位,所以需要安装firefox的两个插件,帮助编写xpath html知识在编写xpath的时候,需要查看html代码,所以需要理解html知识,可以到http://www.w3school.com.cn/去自学…

Mac OS Terminal Commands
转自 : http://www.renfei.org/blog/mac-os-x-terminal-101.html Mac OS X Terminal 101:终端使用初级教程 July 29, 2012 / 编程指南最近学习苹果认证的《Mac OS X Support Essentials》教程,看到 Command Line 一节有很多实用的知识&#x…

封装一个计时器,记录页面的停留时间
在页面加载时初始化计时器,页面结束时取值。 效果如图: 下面是uniapp的代码示例: <template><view class"aaaacc"><view class"aaa">{{time}}</view></view> </template><scri…

ess用户名和密码_陈ess洁如何从摄影系学生转变为成功的自由职业者和内容创作者(播客)...
ess用户名和密码This week, for our last podcast episode of 2019, I got to chat with freelancer and content creator Jessica Chan - known as CoderCoder on social media - about how she got into tech and started her educational website and YouTube channel.本周&…

安装wxpython——python程序GUI图形界面使用
一、本机使用python版本 1、本机使用python版本为3.6.2,windows系统。 二、安装步骤 1、开始-运行-cmd 2、python3.x 需要进入python安装位置下是pip目录,再执行pip 命令 其中:python F:\Users\Administrator\AppData\Local\Programs\Python\…

ASP.NET全球化与本地化 c#多国语言的支持 (项目支持多国语言的开发)
ASP.NET 2.0及以上的开发平台,为全球化本地化应用程序提供了工具,而且实现起来非常简单。以下内容是使用c#,按照帮助一步步做的,将为初学者提供详细的实现步骤。 一 几个必要概念 (一) 支持全球化 由于…

promise 和 async await区别
什么是Async/Await? async/await是写异步代码的新方式,以前的方法有回调函数和Promise。 async/await是基于Promise实现的,它不能用于普通的回调函数。 async/await与Promise一样,是非阻塞的。 async/await使得异步代码看起来像…

mac 制作usb启动盘_如何使用Mac制作Windows 10 USB-从Mac终端构建可启动的ISO
mac 制作usb启动盘Most new PCs dont come with DVD drives anymore. So it can be a pain to install Windows on a new computer.大多数新PC不再附带DVD驱动器。 因此,在新计算机上安装Windows可能会很痛苦。 Luckily, Microsoft makes a tool that you can use …

作业05-继承、多态、抽象类与接口
1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 接口,Comparable,Comparator 1.2 尝试使用思维导图将这些关键词组织起来。 1.3 可选:使用常规方法总结其他上课内容。 1.接口特点:一个公开的界面 有统一定义的规…

炫彩流光按钮 html+css
话不多,先上效果: 简介: 用基础css做一个有一点炫酷的流光按钮,不止按钮,只要是盒子就行。 具体步骤: 1.先定义一个盒子当做按钮,如我就用a标签: <body><a href"#…

SQL取上一条, 下一条记录方法
如果我们需要取id为3的前后的1条记录. 就可以用以下方法 取上一条记录: select * from 表名 where id<3 order by id desc limit 1取下一条记录: select * from 表名 where id>3 order by id asc limit 1大小于比较 order limit 转载于:https://www.cnblogs.com/…

react中使用构建缓存_通过构建海滩度假胜地网站,了解如何使用React,Contentful和Netlify...
react中使用构建缓存In this full course from John Smilga you will learn React by building a beach resort website project. The project uses React router for routing, React context API for state management, Contentful headless CMS for data management, and Net…

R语言实战 - 基本统计分析(2)- 频数表和列联表
数据: > library(vcd) > head(Arthritis)ID Treatment Sex Age Improved 1 57 Treated Male 27 Some 2 46 Treated Male 29 None 3 77 Treated Male 30 None 4 17 Treated Male 32 Marked 5 36 Treated Male 46 Marked 6 23 …

随机位置显示图片不重叠前端实现详细讲解附效果图,代码可直接使用
目录先看看效果图所要实现的功能看看代码js代码讲解:下面看看完整代码吧小程序版本完整代码VUE版本的代码:先看看效果图 所要实现的功能 在页面上随机的位置显示随机大小的图片,并且每个图片不能重叠,完整实现代码。 看看代码 …

MVC缓存OutPutCache学习笔记 (一) 参数配置
OutPutCache 参数详解 Duration : 缓存时间,以秒为单位,这个除非你的LocationNone,可以不添加此属性,其余时候都是必须的。 Location : 缓存放置的位置; 该值为枚举值: None: 当被设置为None时,其余的任何设置将不起作…

在Mac上控制Alt Delete-如何在Macbook上打开任务管理器
It happens to the best of us: were working away on some important project, and our trusty computer freezes. Or rather, a program were in just stops responding. So what do you do?这对我们最好的人来说是偶然的:我们正在做一些重要的项目,而…

HEW MAP文件使用
参考资料转载于:https://www.cnblogs.com/iluzhiyong/p/5145396.html

算法导论九章 答案
http://blog.csdn.net/z84616995z/article/details/18840823?reload 9.3-8题: http://blog.csdn.net/z84616995z/article/details/18938181 9.3-9题: http://blog.csdn.net/z84616995z/article/details/18889535转载于:https://www.cnblogs.com/sa51718…