|Главная Случайная страница
Разделы: Автомобили Астрономия Биология География Дом и сад Другие языки Другое Информатика История Культура Литература Логика Математика Медицина Металлургия Механика Образование Охрана труда Педагогика Политика Право Психология Религия Риторика Социология Спорт Строительство Технология Туризм Физика Философия Финансы Химия Черчение Экология Экономика Электроника
Instruction Execution with the CPU
Instructions are stored in the computer's memory, RAM (random access memory), which will be covered in section 2.1.2 Types of Memory.
There are two main components of the CPU. One is the control unit, which accesses instructions stored in RAM, interprets what they mean, and then dispatches them. The other is the Arithmetic/Logic Unit (ALU) that performs arithmetic (i.e. addition, subtraction, multiplication, division) and logic (i.e. greater than, less than, equal to) operations needed to process the instructions.
There are four steps that the CPU performs when executing an instruction; they are called the fetch-execute cycle. The four steps are as follows:
1. Fetch - The control unit gets the instruction from memory.
2. Interpret - The control unit decodes what the instruction means and directs the necessary data to be moved from memory to the ALU.
3. Execute - The control unit directs the ALU to perform the necessary arithmetic or logic operations.
4. Store - The result of the computation is stored in memory.
The diagram below illustrates the steps taken by the CPU to execute an instruction that adds two numbers. The instruction is: Let R = X + Y.
Figure 2 Fetch-Execute cycle
Another component of the microprocessor is the cache, a special high-speed memory that stores most recently used data in order to speed up the process of instruction execution. A cache can speed up data retrieval because recently used data is likely to be used again by the computer.
Level 1 (L1) cache memory or primary cache memory is located on the CPU to provide the CPU with the fastest access to data. There is also a slower cache, the Level 2 (L2) cache memory or secondary cache, located between the RAM and the CPU (sometimes on the CPU). If data cannot be found on either cache, it will be retrieved from RAM. Relative to the physical distance between the CPU and storage areas for data and instructions, data is retrieved more quickly from the L1 cache, then the L2 cache, and then the RAM.
The figure below illustrates how parts of a microprocessor fit within the other components in a computer.
Figure 3 Microprocessor view
Performance: Factors and Measures
The rate at which instructions are processed is controlled by an internal clock, also known as the system clock. The internal clock sends pulses at a fixed rate to synchronize all computer operations. The unit of measure for cycles per second is the hertz (Hz). One Hz means one cycle per second, one kHz (kilohertz) means one thousand cycles per second, and one MHz means one million cycles per second. Computer clock cycles are closely related to the execution of instructions. So, a 3 GHz Pentium 4 machine can execute more instructions per second than a 2 GHz Pentium IV machine. The greater the hertz, the faster the execution speed.
As processors have become faster and storage capacity increased, it has become feasible to perform more tasks than before. For example, near-instantaneous spellchecking can be done as the user types out a word, whereas years ago, this was not practical. Due to limited processing resources, older processors could not enable a user to type while verifying spelling.
A fetch-execute cycle does not necessarily correspond rigidly to the execution of a fixed number of instructions. Sometimes it takes two or more cycles to execute an instruction. And, today's computers sometimes execute multiple instructions in a single cycle. Thus, the number of instructions completed is independent of the number of cycles used. Sometimes machines are compared on the number of instructions per second (IPS) rather than on raw clock speed; this measure depends on both the number of cycles per second and what kind of instruction mix (set of instructions) is executed. A machine that is fast at financial calculations may not perform as well on a graphics application, since the instruction mix is different.
Instructions can differ a great deal. Some complex instructions require a lot of cycles and take a comparatively long time to execute. Other instructions may be very simple and execute in very little time. For example, a division operation takes longer than an addition operation. Although the IPS rating is not the best method of comparison, it can be useful when comparing similar chips.
Another measure of computer performance is its bandwidth, the volume of data that can be transmitted within a fixed amount of time between components in a computer system (such as the transfer speed from the disk to the motherboard) or through connections to other computers. Bandwidth is expressed in bits per second (bps), or sometimes bytes per second (Bps) (recall that 8 bits equals 1 byte).
Different machines, however, should be compared by executing a standard suite of instructions with execution times carefully measured and recorded. This is a more careful way to measure machine performance, and it is known as benchmarking– comparing disparate systems or components via a standardized set of instructions or series of tasks. Benchmarking can test anything from just the processor to executing office applications. The comparison is measured by the time it takes to execute these instructions. For example, Intel benchmarks its Pentium III processors based on the processors' performance of a variety of tasks, and so does Advanced Micro Devices with its processors. You can view various benchmark results comparing AMD and Intel processors.
In general, it is good practice to ask which benchmarks are used in performance claims. For example, a benchmark that tests graphics speed may be irrelevant if the types of graphical applications you use are different from those used in the test. It is important to assure that comparisons or claims are based on the same benchmarks. Benchmarking results by unbiased, independent organizations are especially useful.