计算机找工作重视工作经验
Computers aren’t magic. They work because engineers of the 1900s exploited a basic physical property of the universe: electrons can move freely in metals, generating an electric current. They defined a simple alphabet with only two “letters” : 0 and 1. If no current was flowing, they would call that 0. If current was flowing, they would call that 1. This simple alphabet would become known as binary. To this day, every aspect of your computer is controlled using this alphabet, which simply indicates if trillions of tiny currents in your computer are flowing or not. These tiny currents flow through electronic devices called transistors (made from silicon-based metal-oxide-semiconductor material, often referred to as MOS technology, for all you chemists and physicists out there). The transistors are connected to each other on integrated circuits, or chips. Today, there are trillions of transistors on a single chip, and tens to hundreds of chips within a single computer.
电脑不是魔术。 它们之所以起作用,是因为1900年代的工程师利用了宇宙的基本物理特性:电子可以在金属中自由移动,从而产生电流。 他们定义了一个只有两个“字母”的简单字母:0和1。如果没有电流流动,则将其称为0。如果有电流流动,则将其称为1。这个简单的字母将被称为binary 。 时至今日,使用此字母控制计算机的各个方面,该字母仅表示计算机中是否有数万亿的微小电流在流动。 这些微小的电流流过称为晶体管的电子设备(晶体管是由硅基金属氧化物半导体材料制成的,通常用于其中的化学家和物理学家都称为MOS技术)。 晶体管在集成电路或芯片上彼此连接。 如今,单个芯片上有数万亿个晶体管,而单个计算机上则有数十到数百个芯片。
In addition to defining the binary alphabet, engineers were also tasked with using it in an intelligent way to solve problems. They split up the problem solving steps and created hardware to handle each step. (Hardware is any physical part of a computer.)
除了定义二进制字母,工程师还被要求以一种智能的方式使用它来解决问题。 他们拆分了解决问题的步骤,并创建了处理每个步骤的硬件。 (硬件是计算机的任何物理部分。)
Input Device (e.g. keyboard) : receives problem (instruction) from user
输入设备(例如键盘):接收用户的问题(指令)
Memory : stores data and instructions
内存:存储数据和指令
Arithmetic Logic Unit (ALU) : performs mathematical operations on data
算术逻辑单元( ALU ):对数据执行数学运算
Central Processing Unit (CPU) : tells ALU what mathematical operations to perform on data
中央处理器( CPU ):告诉ALU对数据执行哪些数学运算
Output Device (e.g. screen) : displays solution to user
输出设备(例如屏幕):向用户显示解决方案
Each piece of hardware both operates and communicates with other components using binary. We will examine the most relevant components to understanding computer functionality: the CPU and Main Memory.
每个硬件都使用二进制文件来运行并与其他组件通信。 我们将检查与理解计算机功能最相关的组件:CPU和主内存。
The most complex of these components is the CPU, also called the processor. The processor is the “brain” of the computer. It is an integrated circuit in charge of the following tasks.
这些组件中最复杂的是CPU ,也称为处理器。 处理器是计算机的“大脑”。 它是负责以下任务的集成电路。
Incrementing the program counter, which is a special register that keeps track of which location in memory the next instruction should be read from. Registers are small pieces of quickly accessible memory located within the CPU.
递增程序计数器,这是一个特殊的寄存器,用于跟踪应该从中读取下一条指令的存储器中的哪个位置。 寄存器是位于CPU内的可快速访问的小型存储器。
Reading the instruction from the memory location indicated by the program counter and reading the data from memory required by the instruction. 从程序计数器指示的存储器位置中读取指令,并从指令所需的存储器中读取数据。Decoding the instruction into a set of commands for other hardware components. To perform the decoding, the CPU uses an Instruction Set Architecture (ISA) which must be defined specifically for each CPU model.
将指令解码为用于其他硬件组件的一组命令。 为了执行解码,CPU使用了指令集体系结构( ISA ),必须为每个CPU模型专门定义。
Providing the ALU with the necessary data and commands, and writing its output to a register. 向ALU提供必要的数据和命令,并将其输出写入寄存器。Memory is also an integrated circuit. However, instead of using binary to facilitate tasking for other hardware components like the CPU, main memory uses binary to store data. It can be understood as an array of cells, each with a unique address, and each of which can hold one word. A word is a collection of a particular number of bits (0’s and 1’s). This number is known as the word width. Words widths on most systems are multiples of 8 bits, with modern word widths equal to either 32 or 64 bits. If the data or instruction that must be stored is larger than the word width, multiple adjacent memory cells can be used.
存储器也是集成电路。 但是,主存储器不是使用二进制文件来促进其他硬件组件(如CPU)的任务,而是使用二进制文件来存储数据。 可以理解为一个单元格数组,每个单元格都有一个唯一的地址,每个单元格可以容纳一个单词。 字是特定位数(0和1)的集合。 这个数字被称为单词宽度。 大多数系统上的字宽是8位的倍数,现代字宽等于32或64位。 如果必须存储的数据或指令大于字宽,则可以使用多个相邻的存储单元。
A computer’s main memory. 计算机的主内存。As an aside, it is important to understand that any information can be represented in binary. This is done by assigning each letter of the alphabet and character on the keyboard a corresponding binary number. That is exactly what ASCII is — a character encoding standard. Any character can be looked up in the ASCII table and is represented by a unique binary number. For example, capital F in binary is equal to 01000110.
顺便说一句,重要的是要了解任何信息都可以用二进制表示。 这是通过为键盘上的每个字母和字符分配一个相应的二进制数字来完成的。 正是ASCII是一种字符编码标准。 可以在ASCII表中查找任何字符,并用唯一的二进制数字表示。 例如,二进制的大写字母F等于01000110。
Memory can be either volatile or non-volatile. Volatile memory requires power to store information. This means that once a computer is powered off, any volatile memory is lost. Main memory (the memory we refer to when we say the CPU “reads data from memory”), also called Random Access Memory (RAM), is volatile.
内存可以是易失性的,也可以是非易失性的。 易失性存储器需要电源来存储信息。 这意味着,一旦计算机关闭电源,所有易失性内存都会丢失。 主内存(当我们说CPU“从内存中读取数据”时所指的内存),也称为随机存取内存( RAM ),是易失的。
The memory hierarchy. 内存层次结构。Computers also contain non-volatile memory, which does not require power to store information. A Hard Disk Drive (HDD) is the non-volatile data storage device that stores the files on your computer. It is often referred to as the disk. It takes more time for the CPU to access data from the disk than it does for the CPU to access data from RAM, or from the registers within the CPU. The disk is a magnetic storage device (unlike RAM, which uses MOS technology to store data).
计算机还包含非易失性内存,不需要电源来存储信息。 硬盘驱动器( HDD )是将文件存储在计算机上的非易失性数据存储设备。 它通常称为磁盘。 CPU从磁盘访问数据所花的时间要比CPU从RAM或CPU中的寄存器访问数据所花的时间更长。 磁盘是一个磁存储设备(与RAM不同,RAM使用MOS技术存储数据)。
Software is the collection of instructions and data (written in binary) that tell the computer (more specifically, the CPU) what to do. Software can be divided into two categories: system software and application software. System software is software designed to be a platform for application software. It is responsible for facilitating communication between device drivers and application software. Device drivers are software that allow a computer to give an external piece of hardware (printers, external hard drives, etc.) commands without needing to know precise details about it. Application software is software designed for humans. This includes Google Chrome, Microsoft Word, and even the terminal.
软件是指令和数据(以二进制形式编写)的集合,这些指令和数据告诉计算机(更具体地讲,CPU)该做什么。 软件可以分为两类:系统软件和应用程序软件。 系统软件是旨在用作应用程序软件平台的软件。 它负责促进设备驱动程序和应用程序软件之间的通信。 设备驱动程序是允许计算机在不需要知道硬件详细信息的情况下向其发出外部硬件(打印机,外部硬盘驱动器等)命令的软件。 应用软件是为人类设计的软件。 这包括Google Chrome,Microsoft Word甚至是终端。
The Operating System is system software. It is the key to our ability as humans to communicate with a machine. It is the final link between difficult-to-understand computer language and actual information and visual cues that make sense to average, non-genius humans.
操作系统是系统软件。 这是我们人类与机器通信的能力的关键。 这是难以理解的计算机语言与实际信息和视觉提示之间的最终链接,这些信息对于普通的非天才人来说是有意义的。
The kernel is the main computer program (a set of instructions for the CPU) in an operating system. It is the “brain” of the OS. The kernel is one of the first programs loaded into main memory when a computer boots, and it stays it memory for the duration of use, until the computer is powered down. It is in charge of the following tasks.
内核是操作系统中的主要计算机程序(用于CPU的一组指令)。 它是操作系统的“大脑”。 内核是计算机启动时加载到主内存中的第一批程序之一,在计算机使用完毕之前,它将一直保留在内存中,直到计算机掉电为止。 它负责以下任务。
Translating and forwarding commands from peripherals (Input/Output devices) to device drivers.
将命令从外围设备(输入/输出设备)转换并转发到设备驱动程序。
Creating processes. A process is an instance of a running computer program. The kernel ensures that processes have seemly exclusive use of the CPU and main memory via context switching and virtual memory. Context switching is the saving of the current state of the process (set of instructions, value of the program counter) in memory so that processes can take turns using the CPU (since CPUs are only capable of running one set of instructions at a time). It’s like pausing a TV show on one channel, switching channels to watch another show, then switching back to finish the original TV show (where you are the kernel and the channels are the processes).
创建流程。 进程是正在运行的计算机程序的实例。 内核确保过程具有经由上下文切换和虚拟内存得体独占使用CPU和主存储器的。 上下文切换是将进程的当前状态(指令集,程序计数器的值)保存在内存中,以便进程可以使用CPU轮流使用(因为CPU一次只能运行一组指令) 。 这就像在一个频道上暂停电视节目,切换频道以观看另一节目一样,然后切换回以完成原始的电视节目(您是内核,频道是进程)。
Virtual memory mapping to physical memory via the MMU. 虚拟内存通过MMU映射到物理内存。Virtual memory is the mapping of virtual memory addresses to physical memory addresses. Virtual addresses are a set of numbers, just like physical addresses, except that they do not refer to a specific physical cell. Rather, they refer to a physical address (the number). A piece of hardware called the Memory Mapping Unit (MMU) located in the CPU is responsible for translating virtual addresses into physical addresses.
虚拟内存是虚拟内存地址到物理内存地址的映射。 虚拟地址是一组数字,就像物理地址一样,只是虚拟地址不指向特定的物理单元。 相反,它们指的是物理地址(数字)。 位于CPU中的称为内存映射单元( MMU )的硬件负责将虚拟地址转换为物理地址。
This means that when the OS launches a process and prompts the CPU to retrieve data from a specific address in memory, that address is a virtual memory address. The MMU then translates that virtual address into a physical address so that the CPU knows what memory cell the data is physically located in. But why are virtual addresses and the MMU necessary? Aren’t they just adding an unnecessary middleman? Yes, if the MMU only mapped to physical addresses in RAM. However, the MMU also maps to physical addresses on the disk. This gives the CPU the illusion of having more RAM. The CPU is, in effect, using RAM as a cache, storing as much data there as possible, and storing any overflow data on the disk. This is because RAM is physically closer to the CPU than the disk, so data stored on it can be accessed more quickly. So why not just make RAM storage bigger? RAM is more expensive than disk storage. Building a computer is a balancing act, where both efficiency and affordability must be optimized.
这意味着,当OS启动进程并提示CPU从内存中的特定地址检索数据时,该地址就是虚拟内存地址。 然后,MMU将该虚拟地址转换为物理地址,以便CPU知道数据在物理上位于哪个存储单元。但是,为什么虚拟地址和MMU是必需的? 他们不是只是增加了不必要的中间人吗? 是的,如果MMU仅映射到RAM中的物理地址。 但是,MMU也映射到磁盘上的物理地址。 这给CPU带来了更多RAM的错觉。 实际上,CPU使用RAM作为缓存,在其中存储尽可能多的数据,并将任何溢出数据存储在磁盘上。 这是因为RAM在物理上比磁盘更接近CPU,因此可以更快地访问存储在其上的数据。 那么,为什么不增加RAM存储空间呢? RAM比磁盘存储更昂贵。 建造计算机是一种平衡,必须同时提高效率和负担能力。
Listen for system calls from processes. System calls are the interface between processes and the operating system. Processes can invoke them to request services from the kernel. The request is in machine code, instructions the CPU understands. Note: Although it is possible to write machine code, most engineers use assembly code to give instructions to an assembler, which is a program that translates instructions into machine code (also called “object code”). Even more engineers use the language higher level languages like C, which a compiler program can translate into assembly code.
侦听来自进程的系统调用。 系统调用是进程和操作系统之间的接口。 进程可以调用它们以从内核请求服务。 请求在机器代码中,CPU理解指令。 注:虽然有可能写入机器代码,大多数工程师使用汇编代码来给汇编,这是转换指令成机器代码(也称为“对象代码”)中的程序指令。 甚至更多的工程师使用诸如C之类的高级语言,编译器程序可以将其翻译成汇编代码。
Clearly, the kernel is an important component of the operating system, with lots of responsibilities. But there are more components with equally important responsibilities, albeit fewer. Other components include:
显然,内核是操作系统的重要组成部分,承担着很多责任。 但是,尽管职责更少,但有更多组件具有同等重要的职责。 其他组件包括:
Networking 联网 Security安全User Interface用户界面Networking is the transmission of information from one computer to another. This topic deserves it’s own article! For now, just know that the operating system handles communication with any hardware external to the computer.
网络是从一台计算机到另一台计算机的信息传输。 该主题值得拥有! 现在,只知道操作系统可以处理与计算机外部任何硬件的通信。
Security is the protection of the computer system from theft or damage. The operating system is capable of distinguishing between “privileged” and “non-privileged” users via authentication, where the user provides a username and password.
安全是保护计算机系统免遭盗窃或损坏的保护。 操作系统能够通过身份验证来区分“特权”用户和“非特权”用户,其中用户提供用户名和密码。
The User Interface (UI) (in the context of an operating system) is the terminal. The terminal allows humans to communicate directly with the kernel via commands. Every operating system has its own set of (bash) commands. The most common bash language is Linux bash, written for the Linux OS. The Mac OS is Linux-based, which is why Linux bash commands word on a Mac OS command line. The Windows OS has its own set of bash commands, which are less widely used.
用户界面( UI )(在操作系统的上下文中)是终端。 该终端允许人类通过命令直接与内核通信。 每个操作系统都有其自己的( bash )命令集。 最常见的bash语言是为Linux OS编写的Linux bash。 Mac OS是基于Linux的,这就是Linux bash在Mac OS命令行上使用命令字的原因。 Windows操作系统具有自己的bash命令集,使用范围较广。
There is a lot of information packed into this article. And yet, I actually left out a lot of the details! Computers are extremely complex, but it is possible to understand how they work. This article is an attempt to help you do that, on a high level.
本文包含很多信息。 但是,实际上我遗漏了很多细节! 计算机非常复杂,但是有可能了解它们的工作方式。 本文试图从较高的角度帮助您做到这一点。
翻译自: https://medium.com/simple-cs/how-a-computer-works-f3e966e10c36
计算机找工作重视工作经验