Sei sulla pagina 1di 24

Swapfile Vs.

Paging File
We have all been using the terms swapfile and paging file interchangeably. Even
Microsoft invariably refers to the paging file as the swapfile and vice versa. However,
the swapfile and paging file are two different entities. Although both are used to
create virtual memory, there are subtle differences between the two.

The main difference lies in their names. Swapfiles operate by swapping entire
processes from system memory into the swapfile. This immediately frees up memory
for other applications to use.

In contrast, paging files function by moving "pages" of a program from system


memory into the paging file. These pages are 4KB in size. The entire program does
not get swapped wholesale into the paging file.

While swapping occurs when there is heavy demand on the system memory, paging
can occur preemptively. This means that the operating system can page out parts of a
program when it is minimized or left idle for some time. The memory used by the
paged-out portions are not immediately released for use by other applications. Instead,
they are kept on standby.

If the paged-out application is reactivated, it can instantly access the paged-out parts
(which are still stored in system memory). But if another application requests for the
memory space, then the system memory held by the paged-out data is released for its
use. As you can see, this is really quite different from the way a swapfile works.

Swapfiles were used in old iterations of Microsoft Windows, prior to Windows 95.
From Windows 95 onwards, all Windows versions use only paging files. Therefore,
the correct term for the file used to create virtual memory in current operating systems
is paging file, not swapfile.

Because both swapfiles and paging files do the same thing - create virtual memory,
people will always refer to swapfiles and paging files interchangeably. Let's just keep
in mind their innate differences.

Most computers today have something like 32 or 64 megabytes of RAM available for
the CPU to use (see How RAM Works for details on RAM). Unfortunately, that
amount of RAM is not enough to run all of the programs that most users expect to run
at once.

For example, if you load the operating system, an e-mail program, a Web browser and
word processor into RAM simultaneously, 32 megabytes is not enough to hold it all.
If there were no such thing as virtual memory, then once you filled up the available
RAM your computer would have to say, "Sorry, you can not load any more
applications. Please close another application to load a new one." With virtual
memory, what the computer can do is look at RAM for areas that have not been used
recently and copy them onto the hard disk. This frees up space in RAM to load the
new application.

Because this copying happens automatically, you don't even know it is happening,
and it makes your computer feel like is has unlimited RAM space even though it only
has 32 megabytes installed. Because hard disk space is so much cheaper than RAM
chips, it also has a nice economic benefit.

The read/write speed of a hard drive is much slower than RAM, and the technology of
a hard drive is not geared toward accessing small pieces of data at a time. If your
system has to rely too heavily on virtual memory, you will notice a significant
performance drop. The key is to have enough RAM to handle everything you tend to
work on simultaneously -- then, the only time you "feel" the slowness of virtual
memory is is when there's a slight pause when you're changing tasks. When that's the
case, virtual memory is perfect.

When it is not the case, the operating system has to constantly swap information back
and forth between RAM and the hard disk. This is called thrashing, and it can make
your computer feel incredibly slow.
Your browser
does not support JavaScript or it is disabled.

The area of the hard disk that stores the RAM image is called a page file. It holds
pages of RAM on the hard disk, and the operating system moves data back and forth
between the page file and RAM. On a Windows machine, page files have a .SWP
extension.

Next, we'll look at how to configure virtual memory on a computer.

Virtual Memory
Back in the 'good old days' of command prompts and 1.2MB floppy disks, programs
needed very little RAM to run because the main (and almost universal) operating
system was Microsoft DOS and its memory footprint was small. That was truly
fortunate because RAM at that time was horrendously expensive. Although it may
seem ludicrous, 4MB of RAM was considered then to be an incredible amount of
memory.

However when Windows became more and more popular, 4MB was just not enough.
Due to its GUI (Graphical User Interface), it had a larger memory footprint than
DOS. Thus, more RAM was needed.

Unfortunately, RAM prices did not decrease as fast as RAM requirement had
increased. This meant that Windows users had to either fork out a fortune for more
RAM or run only simple programs. Neither were attractive options. An alternative
method was needed to alleviate this problem.

The solution they came up with was to use some space on the hard disk as extra
RAM. Although the hard disk is much slower than RAM, it is also much cheaper and
users always have a lot more hard disk space than RAM. So, Windows was designed
to create this pseudo-RAM or in Microsoft's terms - Virtual Memory, to make up for
the shortfall in RAM when running memory-intensive programs.

How Does It Work?


Virtual memory is created using a special file called a swapfile or paging file.
Whenever the operating system has enough memory, it doesn't usually use virtual
memory. But if it runs out of memory, the operating system will page out the least
recently used data in the memory to the swapfile in the hard disk. This frees up some
memory for your applications. The operating system will continuously do this as more
and more data is loaded into the RAM.

However, when any data stored in the swapfile is needed, it is swapped with the least
recently used data in the memory. This allows the swapfile to behave like RAM
although programs cannot run directly off it. You will also note that because the
operating system cannot directly run programs off the swapfile, some programs may
not run even with a large swapfile if you have too
little RAM.

Introduction to How BIOS


Works
One of the most common uses of Flash memory is
for the basic input/output system of your computer,
commonly known as the BIOS (pronounced "bye-
ose"). On virtually every computer available, the
BIOS makes sure all the other chips, hard drives,
ports and CPU function together.

Every desktop and laptop computer in common use today contains a microprocessor
as its central processing unit. The microprocessor is the hardware component. To get
its work done, the microprocessor executes a set of instructions known as software
(see How Microprocessors Work for details). You are probably very familiar with two
different types of software:

• The operating system - The operating system provides a set of services for
the applications running on your computer, and it also provides the
fundamental user interface for your computer. Windows 98 and Linux are
examples of operating systems. (See How Operating Systems Work for lots of
details.)
• The applications - Applications are pieces of software that are programmed to
perform specific tasks. On your computer right now you probably have a
browser application, a word processing application, an e-mail application and
so on. You can also buy new applications and install them.

It turns out that the BIOS is the third type of software your computer needs to operate
successfully. In this article, you'll learn all about BIOS -- what it does, how to
configure it and what to do if your BIOS needs updating.

What BIOS Does


The BIOS software has a number of different roles, but its most important role is to
load the operating system. When you turn on your computer and the microprocessor
tries to execute its first instruction, it has to get that instruction from somewhere. It
cannot get it from the operating system because the operating system is located on a
hard disk, and the microprocessor cannot get to it without some instructions that tell it
how. The BIOS provides those instructions. Some of the other common tasks that the
BIOS performs include:

• A power-on self-test (POST) for all of the different hardware components in


the system to make sure everything is working properly
• Activating other BIOS chips on different cards installed in the computer - For
example, SCSI and graphics cards often have their own BIOS chips.
• Providing a set of low-level routines that the operating system uses to interface
to different hardware devices - It is these routines that give the BIOS its name.
They manage things like the keyboard, the screen, and the serial and parallel
ports, especially when the computer is booting.
• Managing a collection of settings for the hard disks, clock, etc.

The BIOS is special software that interfaces the major hardware components of your
computer with the operating system. It is usually stored on a Flash memory chip on
the motherboard, but sometimes the chip is another type of ROM.

BIOS uses Flash memory, a type of ROM.

When you turn on your computer, the BIOS does several things. This is its usual
sequence:

1. Check the CMOS Setup for custom settings


2. Load the interrupt handlers and device drivers
3. Initialize registers and power management
4. Perform the power-on self-test (POST)
5. Display system settings
6. Determine which devices are bootable
7. Initiate the bootstrap sequence

The first thing the BIOS does is check the information stored in a tiny (64 bytes)
amount of RAM located on a complementary metal oxide semiconductor (CMOS)
chip. The CMOS Setup provides detailed information particular to your system and
can be altered as your system changes. The BIOS uses this information to modify or
supplement its default programming as needed. We will talk more about these settings
later.

Interrupt handlers are small pieces of software that act as translators between the
hardware components and the operating system. For example, when you press a key
on your keyboard, the signal is sent to the keyboard interrupt handler, which tells the
CPU what it is and passes it on to the operating system. The device drivers are other
pieces of software that identify the base hardware components such as keyboard,
mouse, hard drive and floppy drive. Since the BIOS is constantly intercepting signals
to and from the hardware, it is usually copied, or shadowed, into RAM to run faster.

Booting the Computer


Whenever you turn on your computer, the first thing you see is the BIOS software
doing its thing. On many machines, the BIOS displays text describing things like the
amount of memory installed in your computer, the type of hard disk and so on. It turns
out that, during this boot sequence, the BIOS is doing a remarkable amount of work to
get your computer ready to run. This section briefly describes some of those activities
for a typical PC.

After checking the CMOS Setup and loading the interrupt handlers, the BIOS
determines whether the video card is operational. Most video cards have a miniature
BIOS of their own that initializes the memory and graphics processor on the card. If
they do not, there is usually video driver information on another ROM on the
motherboard that the BIOS can load.

Next, the BIOS checks to see if this is a cold boot or a reboot. It does this by
checking the value at memory address 0000:0472. A value of 1234h indicates a
reboot, and the BIOS skips the rest of POST. Anything else is considered a cold boot.

If it is a cold boot, the BIOS verifies RAM by performing a read/write test of each
memory address. It checks the PS/2 ports or USB ports for a keyboard and a mouse. It
looks for a peripheral component interconnect (PCI) bus and, if it finds one, checks
all the PCI cards. If the BIOS finds any errors during the POST, it will notify you by a
series of beeps or a text message displayed on the screen. An error at this point is
almost always a hardware problem.

The BIOS then displays some details about your system. This typically includes
information about:

• The processor
• The floppy drive and hard drive
• Memory
• BIOS revision and date
• Display

Any special drivers, such as the ones for small computer system interface (SCSI)
adapters, are loaded from the adapter, and the BIOS displays the information. The
BIOS then looks at the sequence of storage devices identified as boot devices in the
CMOS Setup. "Boot" is short for "bootstrap," as in the old phrase, "Lift yourself up
by your bootstraps." Boot refers to the process of launching the operating system. The
BIOS will try to initiate the boot sequence from the first device. If the BIOS does not
find a device, it will try the next device in the list. If it does not find the proper files
on a device, the startup process will halt. If you have ever left a floppy disk in the
drive when you restarted your computer, you have probably seen this message.

This is the message you get if a floppy disk is in the drive when you
restart your computer.

The BIOS has tried to boot the computer off of the floppy disk left in the drive. Since
it did not find the correct system files, it could not continue. Of course, this is an easy
fix. Simply pop out the disk and press a key to continue.

Configuring BIOS
In the previous list, you saw that the BIOS checks the CMOS Setup for custom
settings. Here's what you do to change those settings.

To enter the CMOS Setup, you must press a certain key or combination of keys during
the initial startup sequence. Most systems use "Esc," "Del," "F1," "F2," "Ctrl-Esc"
or "Ctrl-Alt-Esc" to enter setup. There is usually a line of text at the bottom of the
display that tells you "Press ___ to Enter Setup."

Once you have entered setup, you will see a set of text screens with a number of
options. Some of these are standard, while others vary according to the BIOS
manufacturer. Common options include:

• System Time/Date - Set the system time and date


• Boot Sequence - The order that BIOS will try to load the operating system
• Plug and Play - A standard for auto-detecting connected devices; should be
set to "Yes" if your computer and operating system both support it
• Mouse/Keyboard - "Enable Num Lock," "Enable the Keyboard," "Auto-
Detect Mouse"...
• Drive Configuration - Configure hard drives, CD-ROM and floppy drives
• Memory - Direct the BIOS to shadow to a specific memory address
• Security - Set a password for accessing the computer
• Power Management - Select whether to use power management, as well as
set the amount of time for standby and suspend
• Exit - Save your changes, discard your changes or restore default settings
CMOS Setup

Be very careful when making changes to setup. Incorrect settings may keep your
computer from booting. When you are finished with your changes, you should choose
"Save Changes" and exit. The BIOS will then restart your computer so that the new
settings take effect.

The BIOS uses CMOS technology to save any changes made to the computer's
settings. With this technology, a small lithium or Ni-Cad battery can supply enough
power to keep the data for years. In fact, some of the newer chips have a 10-year, tiny
lithium battery built right into the CMOS chip!

Updating Your BIOS


Occasionally, a computer will need to have its BIOS updated. This is especially true
of older machines. As new devices and standards arise, the BIOS needs to change in
order to understand the new hardware. Since the BIOS is stored in some form of
ROM, changing it is a bit harder than upgrading most other types of software.

To change the BIOS itself, you'll probably need a special program from the computer
or BIOS manufacturer. Look at the BIOS revision and date information displayed on
system startup or check with your computer manufacturer to find out what type of
BIOS you have. Then go to the BIOS manufacturer's Web site to see if an upgrade is
available. Download the upgrade and the utility program needed to install it.
Sometimes the utility and update are combined in a single file to download. Copy the
program, along with the BIOS update, onto a floppy disk. Restart your computer with
the floppy disk in the drive, and the program erases the old BIOS and writes the new
one. You can find a BIOS Wizard that will check your BIOS at BIOS Upgrades.

Major BIOS manufacturers include:

• American Megatrends Inc. (AMI)


• Phoenix Technologies
• ALi
• Winbond

As with changes to the CMOS Setup, be careful when upgrading your BIOS. Make
sure you are upgrading to a version that is compatible with your computer system.
Otherwise, you could corrupt the BIOS, which means you won't be able to boot your
computer. If in doubt, check with your computer manufacturer to be sure you need to
upgrade.

Microprocessor Progression:
Intel
The first microprocessor to make it into a home computer
was the Intel 8080, a complete 8-bit computer on one chip,
introduced in 1974. The first microprocessor to make a real
splash in the market was the Intel 8088, introduced in 1979
and incorporated into the IBM PC (which first appeared The Intel 8080 was the
first microprocessor in
around 1982). If you are familiar with the PC market and its a home computer. See
history, you know that the PC market moved from the 8088 more microprocessor
to the 80286 to the 80386 to the 80486 to the Pentium to the pictures.
Pentium II to the Pentium III to the Pentium 4. All of these
microprocessors are made by Intel and all of them are improvements on the basic
design of the 8088. The Pentium 4 can execute any piece of code that ran on the
original 8088, but it does it about 5,000 times faster!

The following table helps you to understand the differences between the different
processors that Intel has introduced over the years.

Clock Data
Name Date Transistors Microns MIPS
speed width
8080 1974 6,000 6 2 MHz 8 bits 0.64
16 bits
8088 1979 29,000 3 5 MHz 8-bit 0.33
bus
80286 1982 134,000 1.5 6 MHz 16 bits 1
80386 1985 275,000 1.5 16 MHz 32 bits 5
80486 1989 1,200,000 1 25 MHz 32 bits 20
32 bits
Pentium 1993 3,100,000 0.8 60 MHz 64-bit 100
bus
32 bits
Pentium II 1997 7,500,000 0.35 233 MHz 64-bit ~300
bus
32 bits
Pentium III 1999 9,500,000 0.25 450 MHz 64-bit ~510
bus
32 bits
Pentium 4 2000 42,000,000 0.18 1.5 GHz 64-bit ~1,700
bus
32 bits
Pentium 4
2004 125,000,000 0.09 3.6 GHz 64-bit ~7,000
"Prescott"
bus

Compiled from The Intel Microprocessor Quick Reference Guide and TSCP Benchmark Scores

Information about this table:

What's a Chip?
A chip is also called an integrated circuit. Generally it is a small,
thin piece of silicon onto which the transistors making up the
microprocessor have been etched. A chip might be as large as an
inch on a side and can contain tens of millions of transistors.
Simpler processors might consist of a few thousand transistors
etched onto a chip just a few millimeters square.

• The date is the year that the processor was first introduced. Many processors
are re-introduced at higher clock speeds for many years after the original
release date.
• Transistors is the number of transistors on the chip. You can see that the
number of transistors on a single chip has risen steadily over the years.
• Microns is the width, in microns, of the smallest wire on the chip. For
comparison, a human hair is 100 microns thick. As the feature size on the chip
goes down, the number of transistors rises.
• Clock speed is the maximum rate that the chip can be clocked at. Clock speed
will make more sense in the next section.
• Data Width is the width of the ALU. An 8-bit ALU can
add/subtract/multiply/etc. two 8-bit numbers, while a 32-bit ALU can
manipulate 32-bit numbers. An 8-bit ALU would have to execute four
instructions to add two 32-bit numbers, while a 32-bit ALU can do it in one
instruction. In many cases, the external data bus is the same width as the ALU,
but not always. The 8088 had a 16-bit ALU and an 8-bit bus, while the modern
Pentiums fetch data 64 bits at a time for their 32-bit ALUs.
• MIPS stands for "millions of instructions per second" and is a rough measure
of the performance of a CPU. Modern CPUs can do so many different things
that MIPS ratings lose a lot of their meaning, but you can get a general sense
of the relative power of the CPUs from this column.

From this table you can see that, in general, there is a relationship between clock
speed and MIPS. The maximum clock speed is a function of the manufacturing
process and delays within the chip. There is also a relationship between the number of
transistors and MIPS. For example, the 8088 clocked at 5 MHz but only executed at
0.33 MIPS (about one instruction per 15 clock cycles). Modern processors can often
execute at a rate of two instructions per clock cycle. That improvement is directly
related to the number of transistors on the chip and will make more sense in the next
section
. Microprocessor
Logic
To understand how a microprocessor works,
it is helpful to look inside and learn about the
logic used to create one. In the process you
can also learn about assembly language --
the native language of a microprocessor -- Photo courtesy Intel Corporation
and many of the things that engineers can do Intel Pentium 4 processor
to boost the speed of a processor.

A microprocessor executes a collection of machine instructions that tell the processor


what to do. Based on the instructions, a microprocessor does three basic things:

• Using its ALU (Arithmetic/Logic Unit), a microprocessor can perform


mathematical operations like addition, subtraction, multiplication and division.
Modern microprocessors contain complete floating point processors that can
perform extremely sophisticated operations on large floating point numbers.
• A microprocessor can move data from one memory location to another.
• A microprocessor can make decisions and jump to a new set of instructions
based on those decisions.

There may be very sophisticated things that a microprocessor does, but those are its
three basic activities. The following diagram shows an extremely simple
microprocessor capable of doing those three things:
This is about as simple as a microprocessor gets. This microprocessor has:

• An address bus (that may be 8, 16 or 32 bits wide) that sends an address to


memory
• A data bus (that may be 8, 16 or 32 bits wide) that can send data to memory
or receive data from memory
• An RD (read) and WR (write) line to tell the memory whether it wants to set
or get the addressed location
• A clock line that lets a clock pulse sequence the processor
• A reset line that resets the program counter to zero (or whatever) and restarts
execution

Let's assume that both the address and data buses are 8 bits wide in this example.

Here are the components of this simple microprocessor:

• Registers A, B and C are simply latches made out of flip-flops. (See the
section on "edge-triggered latches" in How Boolean Logic Works for details.)
• The address latch is just like registers A, B and C.
• The program counter is a latch with the extra ability to increment by 1 when
told to do so, and also to reset to zero when told to do so.
• The ALU could be as simple as an 8-bit adder (see the section on adders in
How Boolean Logic Works for details), or it might be able to add, subtract,
multiply and divide 8-bit values. Let's assume the latter here.
• The test register is a special latch that can hold values from comparisons
performed in the ALU. An ALU can normally compare two numbers and
determine if they are equal, if one is greater than the other, etc. The test
register can also normally hold a carry bit from the last stage of the adder. It
stores these values in flip-flops and then the instruction decoder can use the
values to make decisions.
• There are six boxes marked "3-State" in the diagram. These are tri-state
buffers. A tri-state buffer can pass a 1, a 0 or it can essentially disconnect its
output (imagine a switch that totally disconnects the output line from the wire
that the output is heading toward). A tri-state buffer allows multiple outputs to
connect to a wire, but only one of them to actually drive a 1 or a 0 onto the
line.
• The instruction register and instruction decoder are responsible for controlling
all of the other components.

Although they are not shown in this diagram, there would be control lines from the
instruction decoder that would:

• Tell the A register to latch the value currently on the data bus
• Tell the B register to latch the value currently on the data bus
• Tell the C register to latch the value currently output by the ALU
• Tell the program counter register to latch the value currently on the data bus
• Tell the address register to latch the value currently on the data bus
• Tell the instruction register to latch the value currently on the data bus
• Tell the program counter to increment
• Tell the program counter to reset to zero
• Activate any of the six tri-state buffers (six separate lines)
• Tell the ALU what operation to perform
• Tell the test register to latch the ALU's test bits
• Activate the RD line
• Activate the WR line

Coming into the instruction decoder are the bits from the test register and the clock
line, as well as the bits from the instruction register

Microprocessor Memory
The previous section talked about the address and data buses, as well as the RD and
WR lines. These buses and lines connect either to RAM or ROM -- generally both. In
our sample microprocessor, we have an address bus 8 bits wide and a data bus 8 bits
wide. That means that the microprocessor can address (2 ) 256 bytes of memory, and
8

it can read or write 8 bits of the memory at a time. Let's assume that this simple
microprocessor has 128 bytes of ROM starting at address 0 and 128 bytes of RAM
starting at address 128.

ROM chip

ROM stands for read-only memory. A ROM chip is programmed with a permanent
collection of pre-set bytes. The address bus tells the ROM chip which byte to get and
place on the data bus. When the RD line changes state,
the ROM chip presents the selected byte onto the data
bus.

RAM stands for random-access memory. RAM


contains bytes of information, and the microprocessor
can read or write to those bytes depending on whether
the RD or WR line is signaled. One problem with
today's RAM chips is that they forget everything once
RAM chip
the power goes off. That is why the computer needs
ROM.
By the way, nearly all computers contain some amount of ROM (it is possible to
create a simple computer that contains no RAM -- many microcontrollers do this by
placing a handful of RAM bytes on the processor chip itself -- but generally
impossible to create one that contains no ROM). On a PC, the ROM is called the
BIOS (Basic Input/Output System). When the microprocessor starts, it begins
executing instructions it finds in the BIOS. The BIOS instructions do things like test
the hardware in the machine, and then it goes to the hard disk to fetch the boot sector
(see How Hard Disks Work for details). This boot sector is another small program,
and the BIOS stores it in RAM after reading it off the disk. The microprocessor then
begins executing the boot sector's instructions from RAM. The boot sector program
will tell the microprocessor to fetch something else from the hard disk into RAM,
which the microprocessor then executes, and so on. This is how the microprocessor
loads and executes the entire operating system.

Microprocessor Instructions
Even the incredibly simple microprocessor shown in the previous example will have a
fairly large set of instructions that it can perform. The collection of instructions is
implemented as bit patterns, each one of which has a different meaning when loaded
into the instruction register. Humans are not particularly good at remembering bit
patterns, so a set of short words are defined to represent the different bit patterns. This
collection of words is called the assembly language of the processor. An assembler
can translate the words into their bit patterns very easily, and then the output of the
assembler is placed in memory for the microprocessor to execute.

Here's the set of assembly language instructions that the designer might create for the
simple microprocessor in our example:

• LOADA mem - Load register A from memory address


• LOADB mem - Load register B from memory address
• CONB con - Load a constant value into register B
• SAVEB mem - Save register B to memory address
• SAVEC mem - Save register C to memory address
• ADD - Add A and B and store the result in C
• SUB - Subtract A and B and store the result in C
• MUL - Multiply A and B and store the result in C
• DIV - Divide A and B and store the result in C
• COM - Compare A and B and store the result in test
• JUMP addr - Jump to an address
• JEQ addr - Jump, if equal, to address
• JNEQ addr - Jump, if not equal, to address
• JG addr - Jump, if greater than, to address
• JGE addr - Jump, if greater than or equal, to address
• JL addr - Jump, if less than, to address
• JLE addr - Jump, if less than or equal, to address
• STOP - Stop execution
If you have read How C Programming Works, then you know that this simple piece of
C code will calculate the factorial of 5 (where the factorial of 5 = 5! = 5 * 4 * 3 * 2 *
1 = 120):
a=1;
f=1;
while (a <= 5)
{
f = f * a;
a = a + 1;
}

At the end of the program's execution, the variable f contains the factorial of 5.

Assembly Language
A C compiler translates this C code into assembly language. Assuming that RAM
starts at address 128 in this processor, and ROM (which contains the assembly
language program) starts at address 0, then for our simple microprocessor the
assembly language might look like this:

// Assume a is at address 128


// Assume F is at address 129
0 CONB 1 // a=1;
1 SAVEB 128
2 CONB 1 // f=1;
3 SAVEB 129
4 LOADA 128 // if a > 5 the jump to 17
5 CONB 5
6 COM
7 JG 17
8 LOADA 129 // f=f*a;
9 LOADB 128
10 MUL
11 SAVEC 129
12 LOADA 128 // a=a+1;
13 CONB 1
14 ADD
15 SAVEC 128
16 JUMP 4 // loop back to if
17 STOP

ROM
So now the question is, "How do all of these instructions look in ROM?" Each of
these assembly language instructions must be represented by a binary number. For the
sake of simplicity, let's assume each assembly language instruction is given a unique
number, like this:

• LOADA - 1
• LOADB - 2
• CONB - 3
• SAVEB - 4
• SAVEC mem - 5
• ADD - 6
• SUB - 7
• MUL - 8
• DIV - 9
• COM - 10
• JUMP addr - 11
• JEQ addr - 12
• JNEQ addr - 13
• JG addr - 14
• JGE addr - 15
• JL addr - 16
• JLE addr - 17
• STOP - 18

The numbers are known as opcodes. In ROM, our little program would look like this:
// Assume a is at address 128
// Assume F is at address 129
Addr opcode/value
0 3 // CONB 1
1 1
2 4 // SAVEB 128
3 128
4 3 // CONB 1
5 1
6 4 // SAVEB 129
7 129
8 1 // LOADA 128
9 128
10 3 // CONB 5
11 5
12 10 // COM
13 14 // JG 17
14 31
15 1 // LOADA 129
16 129
17 2 // LOADB 128
18 128
19 8 // MUL
20 5 // SAVEC 129
21 129
22 1 // LOADA 128
23 128
24 3 // CONB 1
25 1
26 6 // ADD
27 5 // SAVEC 128
28 128
29 11 // JUMP 4
30 8
31 18 // STOP

You can see that seven lines of C code became 18 lines of assembly language, and
that became 32 bytes in ROM.

Decoding
The instruction decoder needs to turn each of the opcodes into a set of signals that
drive the different components inside the microprocessor. Let's take the ADD
instruction as an example and look at what it needs to do:
1. During the first clock cycle, we need to actually load the instruction. Therefore
the instruction decoder needs to:
• activate the tri-state buffer for the program counter
• activate the RD line
• activate the data-in tri-state buffer
• latch the instruction into the instruction register
2. During the second clock cycle, the ADD instruction is decoded. It needs to do
very little:
• set the operation of the ALU to addition
• latch the output of the ALU into the C register
3. During the third clock cycle, the program counter is incremented (in theory
this could be overlapped into the second clock cycle).

Every instruction can be broken down as a set of sequenced operations like these that
manipulate the components of the microprocessor in the proper order. Some
instructions, like this ADD instruction, might take two or three clock cycles. Others
might take five or six clock cycles

Microprocessor Performance and


Trends
The number of transistors available has a huge effect on the performance of a
processor. As seen earlier, a typical instruction in a processor like an 8088 took 15
clock cycles to execute. Because of the design of the multiplier, it took approximately
80 cycles just to do one 16-bit multiplication on the 8088. With more transistors,
much more powerful multipliers capable of single-cycle speeds become possible.

More transistors also allow for a technology called pipelining. In a pipelined


architecture, instruction execution overlaps. So even though it might take five clock
cycles to execute each instruction, there can be five instructions in various stages of
execution simultaneously. That way it looks like one instruction completes every
clock cycle.

Many modern processors have multiple instruction decoders, each with its own
pipeline. This allows for multiple instruction streams, which means that more than
one instruction can complete during each clock cycle. This technique can be quite
complex to implement, so it takes lots of transistors.

Trends
The trend in processor design has primarily been toward full 32-bit ALUs with fast
floating point processors built in and pipelined execution with multiple instruction
streams. The newest thing in processor design is 64-bit ALUs, and people are
expected to have these processors in their home PCs in the next decade. There has
also been a tendency toward special instructions (like the MMX instructions) that
make certain operations particularly efficient, and the addition of hardware virtual
memory support and L1 caching on the processor chip. All of these trends push up the
transistor count, leading to the multi-million transistor powerhouses available today.
These processors can execute about one billion instructions per second!
64-bit Microprocessors
Sixty-four-bit processors have been with us since 1992, and in the 21st century they
have started to become mainstream. Both Intel and AMD have introduced 64-bit
chips, and the Mac G5 sports a 64-bit processor. Sixty-four-bit processors have 64-bit
ALUs, 64-bit registers, 64-bit buses and so on.

Photo courtesy AMD

One reason why the world needs 64-bit processors is because of their enlarged
address spaces. Thirty-two-bit chips are often constrained to a maximum of 2 GB or
4 GB of RAM access. That sounds like a lot, given that most home computers
currently use only 256 MB to 512 MB of RAM. However, a 4-GB limit can be a
severe problem for server machines and machines running large databases. And even
home machines will start bumping up against the 2 GB or 4 GB limit pretty soon if
current trends continue. A 64-bit chip has none of these constraints because a 64-bit
RAM address space is essentially infinite for the foreseeable future -- 2^64 bytes of
RAM is something on the order of a billion gigabytes of RAM.

With a 64-bit address bus and wide, high-speed data buses on the motherboard, 64-bit
machines also offer faster I/O (input/output) speeds to things like hard disk drives and
video cards. These features can greatly increase system performance.

Servers can definitely benefit from 64 bits, but what about normal users? Beyond the
RAM solution, it is not clear that a 64-bit chip offers "normal users" any real, tangible
benefits at the moment. They can process data (very complex data features lots of real
numbers) faster. People doing video editing and people doing photographic editing on
very large images benefit from this kind of computing power. High-end games will
also benefit, once they are re-coded to take advantage of 64-bit features. But the
average user who is reading e-mail, browsing the Web and editing Word documents is
not really using the processor in that way.

How Flash Memory Works


by Jeff Tyson
Inside This Article
1.
Introduction to How Flash Memory Works
2.
Flash Memory: Tunneling and Erasing
3.
Removable Flash Memory Cards
4.
Memory Standards
5.
Lots More Information
6.
See all Solid State Electronics articles
Electronic memory comes in a variety of forms to
serve a variety of purposes. Flash memory is used for
easy and fast information storage in such devices as
digital cameras and home video game consoles. It is
used more as a hard drive than as RAM. In fact,
Flash memory is considered a solid state storage
device. Solid state means that there are no moving
parts -- everything is electronic instead of A Sony memory stick. See
mechanical. more flash memory pictures.

Here are a few examples of Flash memory:

• Your computer's BIOS chip


• CompactFlash (most often found in digital cameras)
• SmartMedia (most often found in digital cameras)
• Memory Stick (most often found in digital cameras)
• PCMCIA Type I and Type II memory cards (used as solid-state disks in
laptops)
• Memory cards for video game consoles

In this article, we'll find out how Flash memory works and look at some of the forms
it takes and types of devices that use it.

Flash Memory Basics


We discussed the underlying technology of Flash memory in How ROM Works, but
here's a quick review:

Flash memory is a type of EEPROM chip. It has a grid of columns and rows with a
cell that has two transistors at each intersection (see image below).
Your browser
does not support JavaScript or it is disabled.

The two transistors are separated from each other by a thin oxide layer. One of the
transistors is known as a floating gate, and the other one is the control gate. The
floating gate's only link to the row, or wordline, is through the control gate. As long
as this link is in place, the cell has a value of 1. To change the value to a 0 requires a
curious process called Fowler-Nordheim tunneling. Next, we'll talk about tunneling.

Flash Memory: Tunneling and Erasing


Tunneling is used to alter the placement of electrons in the floating gate. An electrical
charge, usually 10 to 13 volts, is applied to the floating gate. The charge comes from
the column, or bitline, enters the floating gate and drains to a ground.

This charge causes the floating-gate transistor to act like an electron gun. The excited
electrons are pushed through and trapped on other side of the thin oxide layer, giving
it a negative charge. These negatively charged electrons act as a barrier between the
control gate and the floating gate. A special device called a cell sensor monitors the
level of the charge passing through the floating gate. If the flow through the gate is
greater than 50 percent of the charge, it has a value of 1. When the charge passing
through drops below the 50-percent threshold, the value changes to 0. A blank
EEPROM has all of the gates fully open, giving each cell a value of 1.
Your browser
does not support JavaScript or it is disabled.

The electrons in the cells of a Flash-memory chip can be returned to normal ("1") by
the application of an electric field, a higher-voltage charge. Flash memory uses in-
circuit wiring to apply the electric field either to the entire chip or to predetermined
sections known as blocks. This erases the targeted area of the chip, which can then be
rewritten. Flash memory works much faster than traditional EEPROMs because
instead of erasing one byte at a time, it erases a block or the entire chip, and then
rewrites it.

You may think that your car radio has Flash memory, since you are able to program
the presets and the radio remembers them. But it is actually using Flash RAM. The
difference is that Flash RAM has to have some power to maintain its contents, while
Flash memory will maintain its data without any external source of power. Even
though you have turned the power off, the car radio is pulling a tiny amount of current
to preserve the data in the Flash RAM. That is why the radio will lose its presets if
your car battery dies or the wires are disconnected.

Removable Flash Memory Cards


While your computer's BIOS chip is the most common form of Flash memory,
removable solid-state storage devices are becoming increasingly popular.
SmartMedia and CompactFlash cards are both well-known, especially as
"electronic film" for digital cameras. Other removable Flash memory products include
Sony's Memory Stick, PCMCIA memory cards, and memory cards for video game
systems such as Nintendo's N64, Sega's Dreamcast and Sony's PlayStation. We will
focus on SmartMedia and CompactFlash, but the essential idea is the same for all of
these products. Every one of them is simply a form of Flash memory.
There are several reasons to use Flash memory instead of a hard disk:

• Flash memory is noiseless.


• It allows faster access.
• It is smaller in size.
• It is lighter.
• It has no moving parts.

So why don't we just use Flash memory for everything?


Because the cost per megabyte for a hard disk is drastically
cheaper, and the capacity is substantially more.

SmartMedia

The solid-state floppy-disk card (SSFDC), better known as


SmartMedia, was originally developed by Toshiba.

SmartMedia cards are available in capacities ranging from 2


MB to 128 MB. The card itself is quite small, approximately
45 mm long, 37 mm wide and less than 1 mm thick. This is SmartMedia card
amazing when you consider what is packed into such a tiny
package!

As shown below, SmartMedia cards are elegant in their simplicity. A plane electrode
is connected to the Flash-memory chip by bonding wires. The Flash-memory chip,
plane electrode and bonding wires are embedded in a resin using a technique called
over-molded thin package (OMTP). This allows everything to be integrated into a
single package without the need for soldering.

The OMTP module is glued to a base card to create the actual card. Power and data is
carried by the electrode to the Flash-memory chip when the card is inserted into a
device. A notched corner indicates the power requirements of the SmartMedia card.
Looking at the card with the electrode facing up, if the notch is on the left side, the
card needs 5 volts. If the notch is on the right side, it requires 3.3 volts.
SmartMedia cards erase, write and read memory in small blocks (256- or 512-byte
increments). This approach means that they are capable of fast, reliable performance
while allowing you to specify which data you wish to keep. They are small,
lightweight and easy to use. They are less rugged than other forms of removable
solid-state storage, so you should be very careful when handling and storing them.

CompactFlash
CompactFlash cards were developed by Sandisk in 1994, and they are different from
SmartMedia cards in two important ways:

• They are thicker.


• They utilize a controller chip.

CompactFlash consists of a small circuit board with Flash-memory chips and a


dedicated controller chip, all encased in a rugged shell that is several times thicker
than a SmartMedia card.

As shown below, CompactFlash cards are 43 mm wide and 36 mm long, and come in
two thicknesses: Type I cards are 3.3 mm thick, and Type II cards are 5.5 mm thick.

CompactFlash card

CompactFlash cards support dual voltage and will operate at either 3.3 volts or 5
volts.

The increased thickness of the card allows for greater storage capacity than
SmartMedia cards. CompactFlash sizes range from 8 MB to 6GB. The onboard
controller can increase performance, particularly on devices that have slow
processors. The case and controller chip add size, weight and complexity to the
CompactFlash card when compared to the SmartMedia card.

Memory Standards
Both SmartMedia and CompactFlash, as well as PCMCIA Type I and Type II memory
cards, adhere to standards developed by the Personal Computer Memory Card
International Association (PCMCIA). Because of these standards, it is easy to use
CompactFlash and SmartMedia products in a variety of devices. You can also buy
adapters that allow you to access these cards through a standard floppy drive, USB
port or PCMCIA card slot (like the one you find on a laptop computer). Sony's
Memory Stick is available in a large array of products offered by Sony, and is now
showing up in products from other manufacturers as well.

Although standards are flourishing, there are many Flash-memory products that are
completely proprietary in nature, such as the memory cards in video game systems.
But it is good to know that as electronic components become increasingly
interchangeable and learn to communicate with each other (by way of technologies
such as Bluetooth), standardized removable memory will allow you to keep your
world close at hand.

In September 2006, Samsung announced the development of PRAM -- Phase-change


Random Access Memory. This new type of memory is supposed to combine the fast
processing speed of RAM with the non-volatile features of Flash memory, leading
some to nickname it "Perfect RAM." PRAM is supposed to have be 30 times faster
than conventional Flash memory and have 10 times the lifespan. Samsung plans to
make the first PRAM chips commercially available in 2010, with a capacity of 512
Mb. They will probably be used in cell phones and other mobile devices.

Potrebbero piacerti anche