Chapter 1 Flashcards
Central Processing Unit (CPU)
The “brain” of the computer is a single component that does the actual computing. The job of the CPU is to
execute programs.
program
is simply a list of unambiguous instructions meant to be followed mechanically by a computer.
machine language
A computer is built to carry out instructions that are written in a very simple type of language called machine language. Each type of computer has its own machine language, and the computer can directly execute a program only if the program is expressed in
that language. (It can execute programs written in other languages if they are first translated
into machine language.)
main memory (also called the RAM or random access memory)
When the CPU executes a program, that program is stored in the computer’s main memory
Main memory consists of a
sequence of _____.
locations
These locations are numbered, and the sequence number of a location
is called its ______.
address
address
provides a way of picking out one particular piece of information from among the millions stored in memory. When the CPU needs to access the program
instruction or data in a particular location, it sends the address of that information as a signal to the memory; the memory responds by sending back the value contained in the specified location.
How does the CPU execute a program?
The CPU executes a program that is stored as a
sequence of machine language instructions in main memory. It does this by repeatedly reading, or fetching, an instruction from memory and then carrying out, or executing, that instruction. This process—fetch an instruction, execute it, fetch another instruction, execute it, and so on forever—is called the fetch-and-execute cycle.
fetching
reading an instruction from memory, via the CPU.
executing
carrying out an instruction that was fetched (read) from memory, via the CPU.
Arithmetic Logic Unit (ALU)
which is the part of the processor
that carries out operations such as addition and subtraction. It contains a small # of registers
registers
which are small memory units capable of holding a single number. A typical CPU might have 16 or 32 “general purpose” registers, which hold data values that are immediately accessible for processing, and many machine language instructions refer to these registers. For example, there might be an instruction that takes two numbers from two specified registers,
adds those numbers (using the ALU), and stores the result back into a register. And there might be instructions for copying a data value from main memory into a register, or from a register into main memory.
program counter (PC)
The CPU uses the PC to keep track of where it is in the program it is executing. The PC is a special purpose register for the CPU. The PC simply stores the memory address of the next instruction that the CPU should execute. At the beginning of each fetch-and-execute cycle, the CPU checks the PC to see which instruction it should fetch. During the course of the fetch-and-execute cycle, the number in the PC is updated to indicate the instruction that is to be executed in the next cycle. Usually, but not always, this is just the instruction that sequentially follows the current
instruction in the program. Some machine language instructions modify the value that is stored in the PC. This makes it possible for the computer to “jump” from one point in the program to another point, which is essential for implementing the program features known as loops and branches that are discussed in Section 1.4.
Significance of transistors
A computer is built with millions of tiny switches called transistors that are linked together in such a way as a computer computes, these switches turn each other on or off in a pattern determined both by the way they are wired together and by the program that the computer is executing
binary number
A binary number is made up of just two possible digits, zero and one. Each zero or one is called a bit.
byte
The data that the computer manipulates is also encoded as binary numbers. In modern computers, each memory location holds a byte, which is a sequence of 8 bits.
hard disk or solid state drive
used for storing programs and data files. (Note that main memory holds only a comparatively small amount of information, and holds it only as long as the power is turned on. A hard disk or solid state drive is used for permanent storage of larger amounts of information, but programs have to be loaded from there into
main memory before they can actually be executed.
How does a CPU communicate to other control devices (keyboards, mouses, scanners, printers, network interfaces) when all it can do is execute machine language instructions?
Through a device driver, which consists of software that the CPU executes when it has to deal with a device.
How do computer systems connect devices (keyboards, mouses, etc.)?
through busses, which are sets of wires that carry data, address, and control signals. An address directs the data to a particular device and perhaps to a particular register or location within that device. Control signals can be used, for example, by one device to alert another that data is available for it on the data bus.
polling
An inefficient method of the CPU to keep checking for incoming data, over and over again. Why would we do this? The CPU doesn’t know if data is waiting for it to process from other devices, so this method is a way for the CPU to check to see if a task is pending for it to process data. Interrupts are typically used over polling because they avoid this inefficiency.
interrupts
An interrupt is a signal sent by another device to the CPU. The CPU responds to an interrupt signal by
putting aside whatever it is doing in order to respond to the interrupt. Once it has handled the interrupt, it returns to what it was doing before the interrupt occurred. For example, when you press a key on your computer keyboard, a keyboard interrupt is sent to the CPU. The CPU responds to this signal by interrupting what it is doing, reading the key that you pressed,
processing it, and then returning to the task it was performing before you pressed the key.
interrupt handler
The CPU is built so that when that wire is turned on,
the CPU saves enough information about what it is currently doing so that it can return to the same state later. This information consists of the contents of important internal registers such as the program counter. Then the CPU jumps to some predetermined memory location and begins executing the instructions stored there. Those instructions make up an interrupt
handler that does the processing necessary to respond to the interrupt. (This interrupt handler
is part of the device driver software for the device that signaled the interrupt.) At the end of
the interrupt handler is an instruction that tells the CPU to jump back to what it was doing;
it does that by restoring its previously saved state.
asynchronous events
Events that happen at unpredictable times. Interrupts make it possible for CPU’s to deal with asynchronous events. As another example of how interrupts are used, consider what happens when the CPU needs
to access data that is stored on a hard disk. The CPU can access data directly only if it is
in main memory. Data on the disk has to be copied into memory before it can be accessed.
Unfortunately, on the scale of speed at which the CPU operates, the disk drive is extremely
slow. When the CPU needs data from the disk, it sends a signal to the disk drive telling it
to locate the data and get it ready. (This signal is sent synchronously, under the control of
a regular program.) Then, instead of just waiting the long and unpredictable amount of time
that the disk drive will take to do this, the CPU goes on with some other task. When the disk
drive has the data ready, it sends an interrupt signal to the CPU. The interrupt handler can
then read the requested data.
multitasking
Modern computers use this to perform several tasks at once.
timesharing
A form of multi-tasking, that involves the CPU switching its attention from one user to another , devoting a fraction of a second to each user.
thread
Each of the individual tasks that the CPU is working on is called a thread. (Or a process; there are technical differences between threads and processes, but they are not important here, since it is threads that are used in Java.) Many CPUs can literally execute more than one thread simultaneously—such CPUs contain multiple “cores,” each of which can run a thread— but there is always a limit on the number of threads that can be executed at the same time. Since there are often more threads than can be executed simultaneously, the computer has to be able switch its attention from one thread to another, just as a timesharing computer switches its attention from one user to another.
yield
Some threads might voluntarily “yield” control, or give other threads a chance to run.
blocked
threads that have to wait for a asynchronous event to occur, which allows any other threads that need to run to occur. For example, the
thread might request some data from the disk drive, or it might wait for the user to press
a key. While it is waiting, the thread is said to be blocked, and other threads, if any, have
a chance to run. When the event occurs, an interrupt will “wake up” the thread so that
it can continue running.
operating systems
the software that does all the interrupt handling, handles communication with the user and with hardware devices, and controls which thread is allowed to run is called the operating system. The operating system is the basic, essential software without which
a computer would not be able to function. Other programs, such as word processors and Web browsers, are dependent upon the operating system. Common desktop operating systems include Linux, various versions of Windows, and Mac OS. Operating systems for smartphones and tablets include Android and iOS.
high-level programming
languages
such as Java, Python, or C++. A program written in a high-level language cannot be run directly on any computer. First, it has to be translated into machine language. This translation can be done by a program called a compiler.