Your computer probably uses both static RAM and dynamic RAM at the same time, but it uses them for different reasons because of the cost difference between the two types. If you understand how dynamic RAM and static RAM chips work inside, it is easy to see why the cost difference is there, and you can also understand the names. Dynamic RAM is the most common type of memory in use today. Inside a dynamic RAM chip, each memory cell holds one bit of information and is made up of two parts a transistor and a capacitor. !hese are, of course, e"tremely small transistors and capacitors so that millions of them can fit on a sin#le memory chip. !he capacitor holds the bit of information $$ a % or a & 'see (ow )its and )ytes Work for information on bits*. !he transistor acts as a switch that lets the control circuitry on the memory chip read the capacitor or chan#e its state. A capacitor is like a small bucket that is able to store electrons. !o store a & in the memory cell, the bucket is filled with electrons. !o store a %, it is emptied. !he problem with the capacitor+s bucket is that it has a leak. In a matter of a few milliseconds a full bucket becomes empty. !herefore, for dynamic memory to work, either the ,-. or the memory controller has to come alon# and rechar#e all of the capacitors holdin# a & before they dischar#e. !o do this, the memory controller reads the memory and then writes it ri#ht back. !his refresh operation happens automatically thousands of times per second. !his refresh operation is where dynamic RAM #ets its name. Dynamic RAM has to be dynamically refreshed all of the time or it for#ets what it is holdin#. !he downside of all of this refreshin# is that it takes time and slows down the memory. /tatic RAM uses a completely different technolo#y. In static RAM, a form of flip$flop holds each bit of memory 'see (ow )oolean 0ates Work for detail on flip$flops*. A flip$flop for a memory cell takes 1 or 2 transistors alon# with some wirin#, but ne3er has to be refreshed. !his makes static RAM si#nificantly faster than dynamic RAM. (owe3er, because it has more parts, a static memory cell takes a lot more space on a chip than a dynamic memory cell. !herefore you #et less memory per chip, and that makes static RAM a lot more e"pensi3e. /o static RAM is fast and e"pensi3e, and dynamic RAM is less e"pensi3e and slower. !herefore static RAM is used to create the ,-.+s speed$sensiti3e cache, while dynamic RAM forms the lar#er system RAM space Inside This Article &. Introduction to How Caching Works 4. A /imple 5"ample )efore ,ache 6. A /imple 5"ample After ,ache 1. ,omputer ,aches 7. ,achin# /ubsystems 2. ,ache !echnolo#y 8. 9ocality of Reference :. 9ots More Information If you ha3e been shoppin# for a computer, then you ha3e heard the word ;cache.; Modern computers ha3e both 9& and 94 caches, and many now also ha3e 96 cache. You may also ha3e #otten ad3ice on the topic from well$meanin# friends, perhaps somethin# like ;Don+t buy that ,eleron chip, it doesn+t ha3e any cache in it<; It turns out that cachin# is an important computer$science process that appears on e3ery computer in a 3ariety of forms. !here are memory caches, hardware and software disk caches, pa#e caches and more. =irtual memory is e3en a form of cachin#. In this article, we will e"plore cachin# so you can understand why it is so important. A Simple Example: Beore Cache Caching is a technolo#y based on the memory subsystem of your computer. !he main purpose of a cache is to accelerate your computer while keepin# the price of the computer low. ,achin# allows you to do your computer tasks more rapidly. !o understand the basic idea behind a cache system, let+s start with a super$simple e"ample that uses a librarian to demonstrate cachin# concepts. 9et+s ima#ine a librarian behind his desk. (e is there to #i3e you the books you ask for. >or the sake of simplicity, let+s say you can+t #et the books yourself $$ you ha3e to ask the librarian for any book you want to read, and he fetches it for you from a set of stacks in a storeroom 'the library of con#ress in Washin#ton, D.,., is set up this way*. >irst, let+s start with a librarian without cache. !he first customer arri3es. (e asks for the book Moby Dick. !he librarian #oes into the storeroom, #ets the book, returns to the counter and #i3es the book to the customer. 9ater, the client comes back to return the book. !he librarian takes the book and returns it to the storeroom. (e then returns to his counter waitin# for another customer. 9et+s say the ne"t customer asks for Moby Dick 'you saw it comin#...*. !he librarian then has to return to the storeroom to #et the book he recently handled and #i3e it to the client. .nder this model, the librarian has to make a complete round trip to fetch e3ery book $$ e3en 3ery popular ones that are re?uested fre?uently. Is there a way to impro3e the performance of the librarian? Yes, there+s a way $$ we can put a cache on the librarian. In the ne"t section, we+ll look at this same e"ample but this time, the librarian will use a cachin# system. A Simple Example: Ater Cache 9et+s #i3e the librarian a backpack into which he will be able to store &% books 'in computer terms, the librarian now has a &%$book cache*. In this backpack, he will put the books the clients return to him, up to a ma"imum of &%. 9et+s use the prior e"ample, but now with our new$ and$impro3ed cachin# librarian. !he day starts. !he backpack of the librarian is empty. @ur first client arri3es and asks for Moby Dick. Ao ma#ic here $$ the librarian has to #o to the storeroom to #et the book. (e #i3es it to the client. 9ater, the client returns and #i3es the book back to the librarian. Instead of returnin# to the storeroom to return the book, the librarian puts the book in his backpack and stands there 'he checks first to see if the ba# is full $$ more on that later*. Another client arri3es and asks for Moby Dick. )efore #oin# to the storeroom, the librarian checks to see if this title is in his backpack. (e finds it< All he has to do is take the book from the backpack and #i3e it to the client. !here+s no Bourney into the storeroom, so the client is ser3ed more efficiently. What if the client asked for a title not in the cache 'the backpack*? In this case, the librarian is less efficient with a cache than without one, because the librarian takes the time to look for the book in his backpack first. @ne of the challen#es of cache desi#n is to minimiCe the impact of cache searches, and modern hardware has reduced this time delay to practically Cero. 53en in our simple librarian e"ample, the latency time 'the waitin# time* of searchin# the cache is so small compared to the time to walk back to the storeroom that it is irrele3ant. !he cache is small '&% books*, and the time it takes to notice a miss is only a tiny fraction of the time that a Bourney to the storeroom takes. >rom this e"ample you can see se3eral important facts about cachin# ,ache technolo#y is the use of a faster but smaller memory type to accelerate a slower but lar#er memory type. When usin# a cache, you must check the cache to see if an item is in there. If it is there, it+s called a cache hit. If not, it is called a cache miss and the computer must wait for a round trip from the lar#er, slower memory area. A cache has some ma"imum siCe that is much Computer Caches A computer is a machine in which we measure time in 3ery small increments. When the microprocessor accesses the main memory 'RAM*, it does it in about 2% nanoseconds '2% billionths of a second*. !hat+s pretty fast, but it is much slower than the typical microprocessor. Microprocessors can ha3e cycle times as short as 4 nanoseconds, so to a microprocessor 2% nanoseconds seems like an eternity. What if we build a special memory bank in the motherboard, small but 3ery fast 'around 6% nanoseconds*? !hat+s already two times faster than the main memory access. !hat+s called a le3el 4 cache or an !" cache. What if we build an e3en smaller but faster memory system directly into the microprocessor+s chip? !hat way, this memory will be accessed at the speed of the microprocessor and not the speed of the memory bus. !hat+s an !# cache, which on a 466$me#ahertC 'M(C* -entium is 6.7 times faster than the 94 cache, which is two times faster than the access to main memory. /ome microprocessors ha3e two le3els of cache built ri#ht into the chip. In this case, the motherboard cache $$ the cache that e"ists between the microprocessor and main system memory $$ becomes le3el 6, or !$ cache. !here are a lot of subsystems in a computerD you can put cache between many of them to impro3e performance. (ere+s an e"ample. We ha3e the microprocessor 'the fastest thin# in the computer*. !hen there+s the 9& cache that caches the 94 cache that caches the main memory which can be used 'and is often used* as a cache for e3en slower peripherals like hard disks and ,D$R@Ms. !he hard disks are also used to cache an e3en slower medium $$ your Internet connection !he computer you are usin# to read this pa#e uses a microprocessor to do its work. !he microprocessor is the heart of any normal computer, whether it is a desktop machine, a ser3er or a laptop. !he microprocessor you are usin# mi#ht be a -entium, a E2, a -ower-,, a /parc or any of the many other brands and types of microprocessors, but they all do appro"imately the same thin# in appro"imately the same way. If you ha3e e3er wondered what the microprocessor in your computer is doin#, or if you ha3e e3er wondered about the differences between types of microprocessors, then read on. In this article, you will learn how fairly simple di#ital lo#ic techni?ues allow a computer to do its Bob, whether its playin# a #ame or spell checkin# a document< A microprocessor $$ also known as a C%& or central processin# unit $$ is a complete computation en#ine that is fabricated on a sin#le chip. !he first microprocessor was the Intel 1%%1, introduced in &F8&. !he 1%%1 was not 3ery powerful $$ all it could do was add and subtract, and it could only do that 1 bits at a time. )ut it was amaCin# that e3erythin# was on one chip. -rior to the 1%%1, en#ineers built computers either from collections of chips or from discrete components 'transistors wired one at a time*. !he 1%%1 powered one of the first portable electronic calculators. !he first microprocessor to make it into a home computer was the Intel :%:%, a complete :$bit computer on one chip, introduced in &F81. !he first microprocessor to make a real splash in the market was the Intel :%::, introduced in &F8F and incorporated into the I)M -, 'which first appeared around &F:4*. If you are familiar with the -, market and its history, you know that the -, market mo3ed from the :%:: to the :%4:2 to the :%6:2 to the :%1:2 to the -entium to the -entium II to the -entium III to the -entium 1. All of these microprocessors are made by Intel and all of them are impro3ements on the basic desi#n of the :%::. !he -entium 1 can e"ecute any piece of code that ran on the ori#inal :%::, but it does it about 7,%%% times faster< Intel '('( )icroprocessor %rogression: Intel !he followin# table helps you to understand the differences between the different processors that Intel has introduced o3er the years. *ame +ate Transistors )icrons Clock speed +ata )icroprocessor %rogression: Intel !he followin# table helps you to understand the differences between the different processors that Intel has introduced o3er the years. *ame +ate Transistors )icrons Clock speed +ata width )I%S :%:% &F81 2,%%% 2 4 M(C : bits %.21 :%:: &F8F 4F,%%% 6 7 M(C &2 bits :$bit bus %.66 :%4:2 &F:4 &61,%%% &.7 2 M(C &2 bits & :%6:2 &F:7 487,%%% &.7 &2 M(C 64 bits 7 :%1:2 &F:F &,4%%,%%% & 47 M(C 64 bits 4% -entium &FF6 6,&%%,%%% %.: 2% M(C 64 bits 21$bit bus &%% -entium II &FF8 8,7%%,%%% %.67 466 M(C 64 bits 21$bit bus G6%% -entium III &FFF F,7%%,%%% %.47 17% M(C 64 bits 21$bit bus G7&% -entium 1 4%%% 14,%%%,%%% %.&: &.7 0(C 64 bits 21$bit bus G&,8%% -entium 1 ;-rescott; 4%%1 &47,%%%,%%% %.%F 6.2 0(C 64 bits 21$bit bus G8,%%% ,ompiled from !he Intel Microprocessor Huick Reference 0uide and !/,- )enchmark /cores Information about this table . rises. Clock speed is the ma"imum rate that the chip can be clocked at. ,lock speed will make more sense in the ne"t section. +ata Width is the width of the A9.. An :$bit A9. can addIsubtractImultiplyIetc. two :$bit numbers, while a 64$ bit A9. can manipulate 64$bit numbers. An :$bit A9. would ha3e to e"ecute four instructions to add two 64$bit numbers, while a 64$bit A9. can do it in one instruction. In many cases, the e"ternal data bus is the same width as the A9., but not always. !he :%:: had a &2$bit A9. and an :$bit bus, while the modern -entiums fetch data 21 bits at a time for their 64$bit A9.s. )I%S stands for ;millions of instructions per second; and is a rou#h measure of the performance of a ,-.. Modern ,-.s can do so many different thin#s that MI-/ ratin#s lose a lot of their meanin#, but you can #et a #eneral sense of the relati3e power of the ,-.s from this column. >rom this table you can see that, in #eneral, there is a relationship between clock speed and MI-/. !he ma"imum clock speed is a function of the manufacturin# process and delays within the chip. !here is also a relationship between the number of transistors and MI-/. >or e"ample, the :%:: clocked at 7 M(C but only e"ecuted at %.66 MI-/ 'about one instruction per &7 clock cycles*. Modern processors can often e"ecute at a rate of two instructions per clock cycle. !hat impro3ement is directly related to the number of transistors on the chip and will make more sense in the ne"t section.