
















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to computer systems, focusing on computer processing, memory, input and output devices, and networks. It explains how programs and data are stored and executed, the role of the operating system, and the importance of networks in increasing productivity and sharing information. It also introduces the concept of Java programming and its relationship with the Web.
What you will learn
Typology: Study notes
1 / 56
This page cannot be seen from the preview
Don't miss anything!
2 CHAPTER 1 computer systems
We begin our exploration of computer systems with an overview of computer processing, defining some fundamental terminology and showing how the key pieces of a computer system interact.
A computer system is made up of hardware and software. The hardware compo- nents of a computer system are the physical, tangible pieces that support the com- puting effort. They include chips, boxes, wires, keyboards, speakers, disks, cables, plugs, printers, mice, monitors, and so on. If you can physically touch it and it can be considered part of a computer system, then it is computer hardware. The hardware components of a computer are essentially useless without instructions to tell them what to do. A program is a series of instructions that the hardware executes one after another. Software consists of programs and the data those programs use. Software is the intangible counterpart to the physical hardware components. Together they form a tool that we can use to solve problems. The key hardware components in a computer system are: ◗ central processing unit (CPU) ◗ input/output (I/O) devices ◗ main memory ◗ secondary memory devices
Each of these hardware components is described in detail in the next section. For now, let’s simply examine their basic roles. The central processing unit (CPU) is the device that executes the individual commands of a program. Input/output (I/O) devices, such as the keyboard, mouse, and monitor, allow a human being to interact with the computer. Programs and data are held in storage devices called memory, which fall into two categories: main memory and secondary memory. Main memory is the stor- age device that holds the software while it is being processed by the CPU. Secondary memory devices store software in a relatively permanent manner. The most important secondary memory device of a typical computer system is the hard disk that resides inside the main computer box. A floppy disk is similar to a hard disk, but it cannot store nearly as much information as a hard disk. Floppy
A computer system consists of hardware and software that work in concert to help us solve problems.
disks have the advantage of portability; they can be removed temporarily or moved from computer to computer as needed. Other portable secondary memory devices include zip disks and compact discs (CDs).
Figure 1.1 shows how information moves among the basic hardware compo- nents of a computer. Suppose you have an executable program you wish to run. The program is stored on some secondary memory device, such as a hard disk.When you instruct the computer to execute your program, a copy of the program is brought in from secondary memory and stored in main memory. The CPU reads the individual program instructions from main memory. The CPU then executes the instructions one at a time until the program ends. The data that the instructions use, such as two numbers that will be added together, are also stored in main memory. They are either brought in from secondary memory or read from an input device such as the keyboard. During execution, the pro- gram may display information to an output device such as a monitor.
The process of executing a program is fundamental to the operation of a com- puter. All computer systems basically work in the same way.
software categories
Software can be classified into many categories using various criteria. At this point we will simply differentiate between system programs and application programs.
The operating system is the core software of a computer. It performs two important functions. First, it provides a user interface that allows the user to
1.0 introduction 3
figure 1.1 A simplified view of a computer system
Hard disk
Keyboard
Main memory
Floppy disk Monitor
CPU
To execute a program, the computer first copies the pro- gram from secondary memory to main memory. The CPU then reads the program instructions from main mem- ory, executing them one at a time until the program ends.
1.0 introduction 5
The focus of this book is the development of high-quality applica- tion programs. We explore how to design and write software that will perform calculations, make decisions, and control graphics. We use the Java programming language throughout the text to demonstrate vari- ous computing concepts.
digital computers
Two fundamental techniques are used to store and manage information: analog and digital. Analog information is continuous, in direct proportion to the source of the information. For example, a mercury thermometer is an analog device for measuring temperature. The mercury rises in a tube in direct proportion to the temperature outside the tube. Another example of analog information is an elec- tronic signal used to represent the vibrations of a sound wave. The signal’s volt- age varies in direct proportion to the original sound wave. A stereo amplifier sends this kind of electronic signal to its speakers, which vibrate to reproduce the sound. We use the term analog because the signal is directly analogous to the information it represents. Figure 1.3 graphically depicts a sound wave captured by a microphone and represented as an electronic signal.
figure 1.2 An example of a graphical user interface (GUI) (Palm Desktop™ courtesy of 3COM Corporation)
As far as the user is con- cerned, the interface is the program.
6 CHAPTER 1 computer systems
Digital technology breaks information into discrete pieces and represents those pieces as numbers. The music on a compact disc is stored digitally, as a series of numbers. Each number represents the voltage level of one specific instance of the recording. Many of these measurements are taken in a short period of time, per- haps 40,000 measurements every second. The number of measurements per sec- ond is called the sampling rate. If samples are taken often enough, the discrete voltage measurements can be used to generate a continuous analog signal that is “close enough” to the original. In most cases, the goal is to create a reproduction of the original signal that is good enough to satisfy the human ear. Figure 1.4 shows the sampling of an analog signal. When analog information is converted to a digital format by breaking it into pieces, we say it has been digitized. Because the changes that occur in a signal between samples are lost, the sampling rate must be sufficiently fast. Sampling is only one way to digitize information. For example, a sentence of text is stored on a computer as a series of numbers, where each num- ber represents a single character in the sentence. Every letter, digit, and punctua- tion symbol has been assigned a number. Even the space character is assigned a number. Consider the following sentence:
Hi, Heather.
figure 1.3 A sound wave and an electronic analog signal that represents the wave
Sound wave Analog signal of the sound wave
Digital computers store infor- mation by breaking it into pieces and representing each piece as a number.
8 CHAPTER 1 computer systems
binary numbers A digital computer stores information as numbers, but those numbers are not stored as decimal values. All information in a computer is stored and managed as binary values. Unlike the decimal system, which has 10 digits (0 through 9), the binary number system has only two digits (0 and 1). A single binary digit is called a bit. All number systems work according to the same rules. The base value of a number system dictates how many digits we have to work with and indicates the place value of each digit in a number. The decimal number system is base 10, whereas the binary number system is base 2. Appendix B contains a detailed dis- cussion of number systems. Modern computers use binary numbers because the devices that store and move information are less expensive and more reliable if they have to represent only one of two possible values. Other than this char- acteristic, there is nothing special about the binary number system. Computers have been created that use other number systems to store information, but they aren’t as convenient. Some computer memory devices, such as hard drives, are magnetic in nature. Magnetic material can be polarized easily to one extreme or the other, but intermediate levels are difficult to distinguish. Therefore magnetic devices can be used to represent binary values quite efficiently—a magnetized area represents a binary 1 and a demagnetized area represents a binary 0. Other computer mem- ory devices are made up of tiny electrical circuits. These devices are easier to cre- ate and are less likely to fail if they have to switch between only two states. We’re better off reproducing millions of these simple devices than creating fewer, more complicated ones. Binary values and digital electronic signals go hand in hand. They improve our ability to transmit information reliably along a wire. As we’ve seen, analog signal has continuously varying voltage, but a digital signal is discrete, which means the voltage changes dramatically between one extreme (such as +5 volts) and the other (such as –5 volts). At any point, the voltage of a digital signal is considered to be either “high,” which represents a binary 1, or “low,” which represents a binary 0. Figure 1.6 compares these two types of signals. As a signal moves down a wire, it gets weaker and degrades due to environ- mental conditions. That is, the voltage levels of the original signal change slightly. The trouble with an analog signal is that as it fluctuates, it loses its original infor- mation. Since the information is directly analogous to the signal, any change in the signal changes the information. The changes in an analog signal cannot be
Binary values are used to store all information in a computer because the devices that store and manipulate binary infor- mation are inexpensive and reliable.
1.0 introduction 9
recovered because the degraded signal is just as valid as the original. A digital sig- nal degrades just as an analog signal does, but because the digital signal is origi- nally at one of two extremes, it can be reinforced before any information is lost. The voltage may change slightly from its original value, but it still can be inter- preted as either high or low.
The number of bits we use in any given situation determines the number of unique items we can represent. A single bit has two possible values, 0 and 1, and therefore can represent two possible items or situations. If we want to represent the state of a light bulb (off or on), one bit will suffice, because we can interpret 0 as the light bulb being off and 1 as the light bulb being on. If we want to rep- resent more than two things, we need more than one bit.
Two bits, taken together, can represent four possible items because there are exactly four permutations of two bits: 00, 01, 10, and 11. Suppose we want to represent the gear that a car is in (park, drive, reverse, or neutral). We would need only two bits, and could set up a mapping between the bit permuta- tions and the gears. For instance, we could say that 00 represents park, 01 represents drive, 10 represents reverse, and 11 represents neutral. In this case, it wouldn’t matter if we switched that mapping around, though in some cases the relationships between the bit permutations and what they represent is important.
Three bits can represent eight unique items, because there are eight permuta- tions of three bits. Similarly, four bits can represent 16 items, five bits can repre- sent 32 items, and so on. Figure 1.7 shows the relationship between the number of bits used and the number of items they can represent. In general, N bits can represent 2 N^ unique items. For every bit added, the number of items that can be represented doubles.
figure 1.6 An analog signal vs. a digital signal
Analog signal Digital signal
There are exactly 2N^ permuta- tions of N bits. Therefore N bits can represent up to 2N unique items.
computer architecture
The architecture of a house defines its structure. Similarly, we use the term com- puter architecture to describe how the hardware components of a computer are put together. Figure 1.9 illustrates the basic architecture of a generic computer system. Information travels between components across a group of wires called a bus.
The CPU and the main memory make up the core of a computer. As we men- tioned earlier, main memory stores programs and data that are in active use, and the CPU methodically executes program instructions one at a time.
Suppose we have a program that computes the average of a list of numbers. The program and the numbers must reside in main memory while the program runs. The CPU reads one program instruction from main memory and executes it. If an instruction needs data, such as a number in the list, to perform its task, the CPU reads that information as well. This process repeats until the program ends. The average, when computed, is stored in main memory to await further processing or long-term storage in secondary memory.
■ (^) 950 MHz Intel Pentium 4 processor
■ (^) 512 MB RAM ■ (^) 30 GB Hard Disk ■ (^) CD-RW 24x/10x/40x ■ (^) 17" Video Display with 1280 x 1024 resolution
■ (^) 56 Kb/s modem
1.1 hardware components 11
figure 1.8 The hardware specification of a particular computer
The core of a computer is made up of the CPU and the main memory. Main memory is used to store programs and data. The CPU executes a pro- gram’s instructions one at a time.
12 CHAPTER 1 computer systems
Almost all devices in a computer system other than the CPU and main mem- ory are called peripherals ; they operate at the periphery, or outer edges, of the sys- tem (although they may be in the same box). Users don’t interact directly with the CPU or main memory. Although they form the essence of the machine, the CPU and main memory would not be useful without peripheral devices. Controllers are devices that coordinate the activities of specific peripherals. Every device has its own particular way of formatting and communicating data, and part of the controller’s role is to handle these idiosyncrasies and isolate them from the rest of the computer hardware. Furthermore, the controller often han- dles much of the actual transmission of information, allowing the CPU to focus on other activities. Input/output (I/O) devices and secondary memory devices are considered peripherals. Another category of peripherals includes data transfer devices, which allow information to be sent and received between computers. The computer specified in Fig. 1.8 includes a data transfer device called a modem, which allows information to be sent across a telephone line. The modem in the example can transfer data at a maximum rate of 56 kilobits (Kb) per second, or approximately 56,000 bits per second (bps). In some ways, secondary memory devices and data transfer devices can be thought of as I/O devices because they represent a source of information (input)
figure 1.9 Basic computer architecture
Other peripheral devices
Main memory
Central processing unit
controllerDisk controllerVideo Controller Controller
Bus
14 CHAPTER 1 computer systems
When data is stored in a memory location, it overwrites and destroys any information that was previously stored at that location. However, data is read from a memory location without affecting it. On many computers, each memory location consists of eight bits, or one byte, of information. If we need to store a value that cannot be rep- resented in a single byte, such as a large number, then multiple, consecutive bytes are used to store the data. The storage capacity of a device such as main memory is the total number of bytes it can hold. Devices can store thousands or millions of bytes, so you should become familiar with larger units of measure. Because computer mem- ory is based on the binary number system, all units of storage are pow- ers of two. A kilobyte (KB) is 1,024, or 2 10 , bytes. Some larger units of storage are a megabyte (MB), a gigabyt e (GB), and a terabyte (TB), as listed in Fig. 1.11. It’s usually easier to think about these capacities by rounding them off. For example, most computer users think of a kilo- byte as approximately one thousand bytes, a megabyte as approxi- mately one million bytes, and so forth. Many personal computers have 128, 256, or 512 megabytes of main memory, or RAM, such as the system described in Fig. 1.8 (we discuss RAM in more detail later in the chapter). A large main memory allows large programs, or multiple programs, to run efficiently because they don’t have to retrieve information from secondary memory as often.
figure 1.10 Memory locations
Addresses
4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812
Data values are stored in memory locations.
Large values are stored in consecutive memory locations.
An address is a unique number associated with each memory location. It is used when stor- ing and retrieving data from memory.
Data written to a memory loca- tion overwrites and destroys any information that was pre- viously stored at that location. Data read from a memory location leaves the value in memory unaffected.
1.1 hardware components 15
Main memory is usually volatile, meaning that the information stored in it will be lost if its electric power supply is turned off. When you are working on a computer, you should often save your work onto a secondary memory device such as a disk in case the power is lost. Secondary memory devices are usually nonvolatile; the information is retained even if the power supply is turned off.
The most common secondary storage devices are hard disks and floppy disks. A high-density floppy disk can store 1.44 MB of information. The storage capac- ities of hard drives vary, but on personal computers, capacities typically range between 10 and 40 GB, such as in the system described in Fig. 1.8.
A disk is a magnetic medium on which bits are represented as magnetized par- ticles. A read/write head passes over the spinning disk, reading or writing information as appropriate. A hard disk drive might actually contain several disks in a vertical column with several read/write heads, such as the one shown in Fig. 1.12.
To get an intuitive feel for how much information these devices can store, con- sider that all the information in this book, including pictures and formatting, requires about 6 MB of storage.
Magnetic tapes are also used as secondary storage but are considerably slower than disks because of the way information is accessed. A disk is a direct access device since the read/write head can move, in general, directly to the information needed. The terms direct access and random access are often used interchange- ably. However, information on a tape can be accessed only after first getting past the intervening data. A tape must be rewound or fast-forwarded to get to the appropriate position. A tape is therefore considered a sequential access device.
figure 1.11 Units of binary storage
byte kilobyte megabyte gigabyte terabyte
KB MB GB TB
20 = 1 210 = 1024 220 = 1,048, 230 = 1,073,741, 240 = 1,099,511,627,
Unit Symbol Number of Bytes
Main memory is volatile, meaning the stored informa- tion is maintained only as long as electric power is sup- plied. Secondary memory devices are usually non- volatile.
1.1 hardware components 17
but weakly from a pitted area. A sensor receiving the reflection determines whether each bit is a 1 or a 0 accordingly. A typical CD-ROM’s storage capacity is approximately 650 MB.
Variations on basic CD technology have emerged quickly. It is now common for a home computer to be equipped with a CD-Recordable (CD-R) drive. A CD-R can be used to create a CD for music or for general computer storage. Once created, you can use a CD-R disc in a standard CD player, but you can’t change the information on a CD-R disc once it has been “burned.” Music CDs that you buy in a store are pressed from a mold, whereas CD-Rs are burned with a laser.
A CD-Rewritable (CD-RW) disc can be erased and reused. They can be reused because the pits and flat surfaces of a normal CD are simu- lated on a CD-RW by coating the surface of the disc with a material that, when heated to one temperature becomes amorphous (and there- fore non-reflective) and when heated to a different temperature becomes crystalline (and therefore reflective). The CD-RW media doesn’t work in all players, but CD-Rewritable drives can create both CD-R and CD-RW discs.
CDs were initially a popular format for music; they later evolved to be used as a general computer storage device. Similarly, the DVD format was originally cre- ated for video and is now making headway as a general format for computer data. DVD once stood for digital video disc or digital versatile disc, but now the acronym generally stands on its own. A DVD has a tighter format (more bits per square inch) than a CD and can therefore store much more information. It is likely that DVD-ROMs eventually will replace CD-ROMs completely because there is a compatible migration path, meaning that a DVD drive can read a CD- ROM. There are currently six different formats for recordable DVDs; some of these are essentially in competition with each other. The market will decide which formats will dominate.
The speed of a CD drive is expressed in multiples of x, which represents a data transfer speed of 153,600 bytes of data per second. The CD-RW drive described in Fig. 1.8 is characterized as having 24x/10x/40x maximum speed, which means it can write data onto CD-R discs at 24x, it can write data onto CD-RW discs at 10x, and it reads data from a disc at 40x.
The capacity of storage devices changes continually as technology improves. A general rule in the computer industry suggests that storage capacity approx- imately doubles every 18 months. However, this progress eventually will slow down as capacities approach absolute physical limits.
A rewritable CD simulates the pits and smooth areas of a regular CD using a coating that can be made amorphous or crystalline as needed.
18 CHAPTER 1 computer systems
the central processing unit The central processing unit (CPU) interacts with main memory to perform all fundamental processing in a computer. The CPU interprets and executes instruc- tions, one after another, in a continuous cycle. It is made up of three important components, as shown in Fig. 1.13. The control unit coordinates the processing steps, the registers provide a small amount of storage space in the CPU itself, and the arithmetic/logic unit performs calculations and makes decisions. The control unit coordinates the transfer of data and instructions between main memory and the registers in the CPU. It also coordinates the execution of the circuitry in the arithmetic/logic unit to perform operations on data stored in particular registers. In most CPUs, some registers are reserved for special purposes. For example, the instruction register holds the current instruction being executed. The program counter is a register that holds the address of the next instruction to be executed. In addition to these and other special-purpose registers, the CPU also contains a set of general-purpose registers that are used for temporary storage of values as needed. The concept of storing both program instructions and data together in main memory is the underlying principle of the von Neumann architecture of computer design, named after John von Neumann, who first advanced this programming concept in 1945. These computers continually follow the fetch-decode-execute cycle depicted in Fig. 1.14. An instruction is fetched from main memory at the address stored in the program counter and is put into the instruction register. The
figure 1.13 CPU components and main memory
Bus
CPU
Registers
Arithmetic/logic unit
Main memory Control unit
20 CHAPTER 1 computer systems
of commercial computer operation. New technologies are emerging every day to capitalize on the connected environments of modern computer systems. Figure 1.15 shows a simple computer network. One of the devices on the net- work is a printer, which allows any computer connected to the network to print a document on that printer. One of the computers on the network is designated as a file server, which is dedicated to storing programs and data that are needed by many network users. A file server usually has a large amount of secondary memory. When a network has a file server, each individual computer doesn’t need its own copy of a program.
network connections If two computers are directly connected, they can communicate in basically the same way that information moves across wires inside a single machine. When connecting two geographically close computers, this solution works well and is called a point-to-point connection. However, consider the task of connecting many computers together across large distances. If point-to-point connections are used, every computer is directly con- nected by a wire to every other computer in the network. A separate wire for each connection is not a workable solution because every time a new computer is added to the network, a new communication line will have to be installed for each computer already in the network. Furthermore, a single com- puter can handle only a small number of direct connections. Figure 1.16 shows multiple point-to-point connections. Consider the number of communication lines that would be needed if two or three additional comput- ers were added to the network. Contrast the diagrams in Fig. 1.15 and Fig. 1.16. All of the computers shown in Fig. 1.15 share a single communication line. Each computer on the network
figure 1.15 A simple computer network
Shared printer
File server
A network consists of two or more computers connected together so they can exchange information.
1.2 networks 21
has its own network address, which uniquely identifies it. These addresses are similar in concept to the addresses in main memory except that they identify indi- vidual computers on a network instead of individual memory locations inside a single computer. A message is sent across the line from one computer to another by specifying the network address of the computer for which it is intended.
Sharing a communication line is cost effective and makes adding new computers to the network relatively easy. However, a shared line introduces delays. The computers on the network cannot use the com- munication line at the same time. They have to take turns sending information, which means they have to wait when the line is busy.
One technique to improve network delays is to divide large mes- sages into segments, called packets, and then send the individual packets across the network intermixed with pieces of other messages sent by other users. The packets are collected at the destination and reassembled into the original message. This situation is similar to a group of people using a conveyor belt to move a set of boxes from one place to another. If only one person were allowed to use the conveyor belt at a time, and that person had a large number of boxes to move, the others would be waiting a long time before they could use it. By taking turns, each person can put one box on at a time, and they all can get their work done. It’s not as fast as having a conveyor belt of your own, but it’s not as slow as hav- ing to wait until everyone else is finished.
local-area networks and wide-area networks
A local-area network (LAN) is designed to span short distances and connect a rel- atively small number of computers. Usually a LAN connects the machines in only
figure 1.16 Point-to-point connections
Sharing a communication line creates delays, but it is cost effective and simplifies adding new computers to the network.