正在加载图片...
1.4.HARDWARE BASICS Output Devices CPL Input Devices Main Memory Secondary Memory Figure 1.1:Functional View of a Computer. analysis.For most problems,the bottom-line is whether a working,reliable system can be built.Often we require empirical testing of the system to determine that this bottom-line has been met.As you begin writing your own programs,you will get plenty of opportunities to observe your solutions in action. 1.4 Hardware Basics You don't have to know all the details of how a computer works to be a successful programmer,but under- standing the underlying principles will help you master the steps we go through to put our programs into action.It's a bit like driving a car.Knowing a little about internal combustion engines helps to explain why you have to do things like fill the gas tank,start the engine,step on the accelerator,etc.You could learn to drive by just memorizing what to do,but a little more knowledge makes the whole process much more understandable.Let's take a moment to "look under the hood"of your computer. Although different computers can vary significantly in specific details,at a higher level all modern digital computers are remarkably similar.Figure 1.1 shows a functional view of a computer.The central processing unit(CPU)is the "brain"of the machine.This is where all the basic operations of the computer are carried out.The CPU can perform simple arithmetic operations like adding two numbers and can also do logical operations like testing to see if two numbers are equal. The memory stores programs and data.The CPU can only directly access information that is stored in main memory(called RAM for Random Access Memory).Main memory is fast,but it is also volatile.That is, when the power is turned off,the information in the memory is lost.Thus,there must also be some secondary memory that provides more permanent storage.In a modern personal computer,this is usually some sort of magnetic medium such as a hard disk(also called a hard drive)or floppy. Humans interact with the computer through input and output devices.You are probably familiar with common devices such as a keyboard,mouse,and monitor(video screen).Information from input devices is processed by the CPU and may be shuffled off to the main or secondary memory.Similarly,when information needs to be displayed,the CPU sends it to one or more output devices. So what happens when you fire up your favorite game or word processing program?First,the instructions that comprise the program are copied from the(more)permanent secondary memory into the main memory of the computer.Once the instructions are loaded,the CPU starts executing the program. Technically the CPU follows a process called the fetch execute cycle.The first instruction is retrieved from memory,decoded to figure out what it represents,and the appropriate action carried out.Then the next instruction is fetched,decoded and executed.The cycle continues,instruction after instruction.This is really all the computer does from the time that you turn it on until you turn it off again:fetch,decode,execute.It doesn't seem very exciting,does it?But the computer can execute this stream of simple instructions with blazing speed,zipping through millions of instructions each second.Put enough simple instructions together in just the right way,and the computer does amazing things.1.4. HARDWARE BASICS 3 Input Devices CPU Secondary Memory Main Memory Output Devices Figure 1.1: Functional View of a Computer. analysis. For most problems, the bottom-line is whether a working, reliable system can be built. Often we require empirical testing of the system to determine that this bottom-line has been met. As you begin writing your own programs, you will get plenty of opportunities to observe your solutions in action. 1.4 Hardware Basics You don’t have to know all the details of how a computer works to be a successful programmer, but under￾standing the underlying principles will help you master the steps we go through to put our programs into action. It’s a bit like driving a car. Knowing a little about internal combustion engines helps to explain why you have to do things like fill the gas tank, start the engine, step on the accelerator, etc. You could learn to drive by just memorizing what to do, but a little more knowledge makes the whole process much more understandable. Let’s take a moment to “look under the hood” of your computer. Although different computers can vary significantly in specific details, at a higher level all modern digital computers are remarkably similar. Figure 1.1 shows a functional view of a computer. The central processing unit (CPU) is the “brain” of the machine. This is where all the basic operations of the computer are carried out. The CPU can perform simple arithmetic operations like adding two numbers and can also do logical operations like testing to see if two numbers are equal. The memory stores programs and data. The CPU can only directly access information that is stored in main memory (called RAM for Random Access Memory). Main memory is fast, but it is also volatile. That is, when the power is turned off, the information in the memory is lost. Thus, there must also be some secondary memory that provides more permanent storage. In a modern personal computer, this is usually some sort of magnetic medium such as a hard disk (also called a hard drive) or floppy. Humans interact with the computer through input and output devices. You are probably familiar with common devices such as a keyboard, mouse, and monitor (video screen). Information from input devices is processed by the CPU and may be shuffled off to the main or secondary memory. Similarly, when information needs to be displayed, the CPU sends it to one or more output devices. So what happens when you fire up your favorite game or word processing program? First, the instructions that comprise the program are copied from the (more) permanent secondary memory into the main memory of the computer. Once the instructions are loaded, the CPU starts executing the program. Technically the CPU follows a process called the fetch execute cycle. The first instruction is retrieved from memory, decoded to figure out what it represents, and the appropriate action carried out. Then the next instruction is fetched, decoded and executed. The cycle continues, instruction after instruction. This is really all the computer does from the time that you turn it on until you turn it off again: fetch, decode, execute. It doesn’t seem very exciting, does it? But the computer can execute this stream of simple instructions with blazing speed, zipping through millions of instructions each second. Put enough simple instructions together in just the right way, and the computer does amazing things
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有