ALevel-CS Chapter 18
Hardware and virtual machines
18.01 The control unit
The Control Unit
There are two methods by which a control unit can be designed to allow it to perform its function.
One method is for the control unit to be constructed as a logic circuit. This is called the hardwired solution. The machine-code instructions are handled directly by hardware.
The alternative method is for the control unit to use microprogramming. In this approach, the control unit contains a ROM component that stores the microinstructions or microcode for microprogramming, often referred to as firmware. In the next section we will see what might influence the choice of design of the control unit.
18.02 CISC and RISC processors
Key Terms
- Complex Instruction Set Computer (CISC) - a single instruction can be more complex and involve more loading of data from memory
- Reduced Instruction Set Computer (RISC) - a single instruction is simpler, requiring minimal loading of data from memory
- Pipelining - instruction-level parallelism
CISC and RISC processors
CISC(复杂指令集计算机) - 早期的CPU全部是CISC架构,它的设计目的是要用最少的机器语言指令来完成所需的计算任务。比如对于复杂的指令乘法运算,在CISC架构上可以直接使用MUL ADDRA, ADDRB
,将ADDRA,ADDRB中的数据读入寄存器,想乘和将结果写回内存的操作全部依赖于CPU中设计的逻辑来实现。这种架构会增加CPU的复杂性和对CPU工艺的要求,但对于编译器的开发十分有利。
RISC(精简指令集计算机) - RISC架构要求软件来指定各个操作步骤。上面的例子如果要在RISC架构上实现,将ADDRA, ADDRB中的数据读入寄存器,相乘和将结果写回内存的操作都必须由软件来实现,比如:MOV A, ADDRA; MOV B, ADDRB; MUL A, B; STR ADDRA, A。这种架构可以降低CPU的复杂性以及允许在同样的工艺水平下生产出功能更强大的CPU,但对于编译器的设计有更高的要求。
长期以来,计算机的性能提高往往是通过增加硬件的复杂度来获得,为了软件编程方便和提高程序的运行速度,硬件工程师采用的办法是不断增加可实现复杂功能的指令和多种灵活的编址方式。所以导致硬件越来越复杂,造假越来越高。一般CISC计算机所含的指令数至少300条,有的甚至超过500条。
随着CISC的逐渐发展,有的人开始怀疑这种传统的做法,认为日趋庞杂的指令系统不但不易实现。而且还可能降低系统性能。研究结果表明CISC存在许多缺点,首先,各种指令的使用率相差悬殊:一个典型程序的运算过程所使用的80%指令.只占一个处理器指令系统的20%。同时,复杂的指令系统必然带来结构的复杂性.这不但增加了设计的时间与成本还容易造成设计失误。通过这些原因设计并逐步发展形成了RISC。
CISC and RISC processors
instruction set architecture::
- the instruction set
- the instruction format
- the addressing modes
- the registers accessible by instructions.
In the early days of computing a significant factor in choosing the instruction set architecture for a computer was that it should make the writing of a compiler for a high-level language easier. At that time the term did not exist, but we would now refer to this as being the architecture for a Complex Instruction Set Computer (CISC) .
This philosophy began to be challenged in the late 1970s. It was argued that using a Reduced Instruction Set Computer (RISC) would be a better approach. Table 18.01 contains a number of features that distinguish RISC from CISC.
CISC and RISC processors
The following are some points to note.
- For RISC the term ‘reduced’ affects more than just the number of instructions.
- A reduction in the number of instructions is not the major driving force for the use of RISC. (目的不是减少指令)
- The reduction in the complexity of the instructions is a key feature of RISC. (目的是降低指令复杂度)
- The typical CISC architecture contains many specialised instructions.
- The specialised instructions are designed to match the requirement of a high-level programming language. (专用指令用于匹配HL编程要求)
- The specialised instructions require multiple memory accesses which are very slow compared with register accesses. (专用指令速度较慢)
- The simplicity of the instructions for a RISC processor allows data to be stored in registers and manipulated in them with no resource to memory access other than that necessary for initial loading and possible final storing.
- The simplicity of RISC instructions makes it easier to use hard-wiring inside the control unit.
- The complexity of many of the CISC instructions makes hard-wiring much more difficult so microprogramming is the norm.
Pipelining
流水线将处理五个单独指令的五个阶段。特别地,在每个时钟周期,一条指令的完整处理已经完成。如果没有管道,处理时间将延长五倍。
- IF - 取指
- ID - 译码
- EX - 执行
- MA - 访存
- WB - 写回
Pipeline 的基本思路是,“因为每个指令的每个阶段,用到的结构可能都是不一样的,所以我们和流水线加工一样,每个阶段都在处理不同的指令”。但是这个实现起来相对 Single-Cycle 就有各种各样的新问题了。
Pipelining
One of the major driving forces for creating RISC processors was the opportunity they would provide for efficient pipelining. Pipelining is a form of parallelism applied specifically to instruction execution.
Once under way, the pipeline is handling five stages of five individual instructions. In particular, at each clock cycle the complete processing of one instruction has finished. Without the pipeline the processing time would be five times longer.
18.03 The basic computer architectures
Key Terms
- SISD - Single Instruction Stream Single Data stream; a single processor accessing one memory
- SIMD - Single Instruction Stream Multiple Data stream; processing of parallel data input requiring one control unit instructing multiple processing units
- MISD - Multiple Instruction Stream Single Data stream; does not exist in a single architecture
- MIMD - Multiple Instruction Stream Multiple Data stream; multiple processors asynchronously processing parallel data input
SISD & SIMD & MISD & MIMD
单指令流单数据流机器(SISD)
SISD机器是一种传统的串行计算机,它的硬件不支持任何形式的并行计算,所有的指令都是串行执行。并且在某个时钟周期内,CPU只能处理一个数据流。因此这种机器被称作单指令流单数据流机器。早期的计算机都是SISD机器,如冯诺.依曼架构,如IBM PC机,早期的巨型机和许多8位的家用机等。
单指令流多数据流机器(SIMD)
SIMD是采用一个指令流处理多个数据流。这类机器在数字信号处理、图像处理、以及多媒体信息处理等领域非常有效。 Intel处理器实现的MMXTM、SSE(Streaming SIMD Extensions)、SSE2及SSE3扩展指令集,都能在单个时钟周期内处理多个数据单元。也就是说我们现在用的单核计算机基本上都属于SIMD机器。
SISD & SIMD & MISD & MIMD
多指令流单数据流机器(MISD)
MISD是采用多个指令流来处理单个数据流。由于实际情况中,采用多指令流处理多数据流才是更有效的方法,因此MISD只是作为理论模型出现,没有投入到实际应用之中。
多指令流多数据流机器(MIMD)
MIMD机器可以同时执行多个指令流,这些指令流分别对不同数据流进行操作。最新的多核计算平台就属于MIMD的范畴,例如Intel和AMD的双核处理器等都属于MIMD。
Single Instruction Stream Single Data Stream (SISD)
SISD is the typical arrangement found in early computers which was also adopted for the earliest microprocessors. The functioning is purely sequential with no parallelism.
Single Instruction Stream Multiple Data Stream (SIMD)
SIMD can be considered as parallelism applied to the data stream.
the structure shows four data streams entering four individual components which are simultaneously supplied with the same instruction.
Multiple Instruction Stream Single Data Stream (MISD)
MISD is not evidenced in any individual computer architecture design.
One example where the approach could be implemented would be in a fault-tolerant system. The same data stream could be fed into two or more processors. The output would only be accepted if the same output was produced by all of the processors.
Multiple Instruction Stream Multiple Data Stream (MIMD)
The MIMD architecture is similar to that for the type of SIMD architecture with more than one processing unit receiving the parallel data streams. The difference is that each Processing unit does not execute the same instruction. The multiple data stream can be provided by a suitably partitioned single memory. Each Processing Unit might have a dedicated cache memory.
Massively parallel computer systems
The MIMD architecture can be implemented in multicomputer systems known as massively parallel computers. These are the systems used by large organisations for computations involving highly complex mathematical processing. They are the latest type of ‘supercomputer’.
18.04 Virtual machines
Key Terms
- System virtual machine - the emulation of computer system hardware using software
Virtual machine
Virtual Machine 虚拟机指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统。在实体计算机中能够完成的工作在虚拟机中都能够实现。在计算机中创建虚拟机时,需要将实体机的部分硬盘和内存容量作为虚拟机的硬盘和内存容量。每个虚拟机都有独立的CMOS(BIOS设置程序)、硬盘和操作系统,可以像使用实体机一样对虚拟机进行操作。
优点:
- 集中化管理:管理员不用再跑上跑下的处理每个工位上的主机,所有日常操作远程完成。复制、快照等功能更为管理员的日常维护提供了给力的工具。
- 提高硬件利用率:一般来说,企业IT的物理资源利用率都是非常低的,因为所有的物理资源必须满足当前甚至几年以后的“峰值”计算需求。
- 动态调整机器/资源配置:虚拟化把操作系统和应用程序与服务器硬件分离开来,提供了大大增强的灵活性。不用关闭及拆卸物理服务器,就可以为虚拟机增加或减少资源。
- 高可靠性:通过部署额外的功能和方案,带来具有透明负载均衡、动态迁移、快速复制等高可靠服务器应用环境,减少服务器或应用系统的停机时间,提高可靠性。
- 可以使用不同的操作系统
- 新电脑使用老版本软件
劣势:
- 降低性能
- 实施配置复杂,管理复杂
Virtual machines
- The application programs are installed with the assistance of a guest OS. This guest OS will support the running application by interacting with the virtual machine as though it were the hardware that the guest OS would normally run on.
- The virtual machine implementation software can be considered to be a utility program which, when running, is supported by the particular host OS which is specific to the host hardware.
- There can be application programs running at the same time directly on the host hardware under the control of the host OS.
Advantage:
- more than one different operating system can be made available on one computer system
- an organisation has legacy systems and wishes to continue to use the old software but does not wish to keep the old hardware.
- the same operating system can be made available many times by companies with large mainframe computers that offer server consolidation facilities.
Disadvantage:
- the time and effort required for implementation.
- low performance