⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib0014.html

📁 Memory Management—Algorithms and implementation in C/C++ Introduction Chapter 1 - Memory Manag
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Memory Hierarchy</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.books24x7.css">
</head>
<body >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle"  alt="Team LiB"></a></div></td>
<td valign="top" class="v2" align="right"><div STYLE="MARGIN-RIGHT: 0.15in"><a href="LiB0013.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0015.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr>
</table>

<div class="chapter">
<a name="ch01"></a>
<div class="section">
<h2 class="first-section-title"><a name="56"></a><a name="ch01lev1sec2"></a>Memory Hierarchy</h2><p class="first-para">When someone uses the term "memory," they are typically referring to the data storage provided by dedicated chips located on the motherboard. The storage these chips provide is often referred to as <i class="emphasis">Random Access Memory</i> (RAM), <i class="emphasis">main memory</i>, and <i class="emphasis">primary storage</i>. Back in the iron age, when mainframes walked the earth, it was called the <i class="emphasis">core</i>. The storage provided by these chips is <i class="emphasis">volatile</i>, which is to say that data in the chips is lost when the power is switched off.</p>
<p class="para">There are various types of RAM:</p>
<ul class="itemizedlist">
<li class="first-listitem">
<p class="first-para">DRAM</p>
</li>
<li class="listitem">
<p class="first-para">SDRAM</p>
</li>
<li class="listitem">
<p class="first-para">SRAM</p>
<a name="57"></a><a name="IDX-4"></a>
</li>
<li class="listitem">
<p class="first-para">VRAM</p>
</li>
</ul>
<p class="para">
<i class="emphasis">Dynamic RAM</i> (DRAM) has to be recharged thousands of times each second. <i class="emphasis">Synchronous DRAM</i> (SDRAM) is refreshed at the clock speed at which the processor runs the most efficiently. <i class="emphasis">Static RAM</i> (SRAM) does not need to be refreshed like DRAM, and this makes it much faster. Unfortunately, SRAM is also much more expensive than DRAM and is used sparingly. SRAM tends to be used in processor caches and DRAM tends to be used for wholesale memory. Finally, there's Video RAM (VRAM), which is a region of memory used by video hardware. In the <a href="LiB0019.html#131" target="_parent" class="chapterjump">next chapter</a>, there is an example that demonstrates how to produce screen messages by manipulating VRAM.</p>
<p class="para">Recent advances in technology and special optimizations implemented by certain manufacturers have led to a number of additional acronyms. Here are a couple of them:</p>
<ul class="itemizedlist">
<li class="first-listitem">
<p class="first-para">DDR SDRAM</p>
</li>
<li class="listitem">
<p class="first-para">RDRAM</p>
</li>
<li class="listitem">
<p class="first-para">ESDRAM</p>
</li>
</ul>
<p class="para">DDR SDRAM stands for Double Data Rate Synchronous Dynamic Random Access Memory. With DDR SDRAM, data is read on both the rising and the falling of the system clock tick, basically doubling the bandwidth normally available. RDRAM is short for Rambus DRAM, a high-performance version of DRAM sold by Rambus that can transfer data at 800 MHz. Enhanced Synchronous DRAM (ESDRAM), manufactured by Enhanced Memory Systems, provides a way to replace SRAM with cheaper SDRAM.</p>
<p class="para">A <i class="emphasis">bit</i> is a single binary digit (i.e., a 1 or a 0). A bit in a RAM chip is basically a cell structure that is made up of, depending on the type of RAM, a certain configuration of transistors and capacitors. Each cell is a digital switch that can either be on or off (i.e., 1 or 0). These cells are grouped into 8-bit units call <i class="emphasis">bytes</i>. The byte is the fundamental unit for measuring the amount of memory provided by a storage device. In the early years, hardware vendors used to implement different byte sizes. One vendor would use a 6-bit byte and another would use a 16-bit byte. The de facto standard that everyone seems to abide by today, however, is the 8-bit byte.</p>
<p class="para">There is a whole set of byte-based metrics to specify the size of a memory region:</p>
<p class="para">1 byte = 8 bits</p>
<p class="para">1 word = 2 bytes</p>
<p class="para">1 double word = 4 bytes</p>
<a name="58"></a><a name="IDX-5"></a>
<p class="para">1 quad word = 8 bytes</p>
<p class="para">1 octal word = 8 bytes</p>
<p class="para">1 paragraph = 16 bytes</p>
<p class="para">1 kilobyte (KB) = 1,024 bytes</p>
<p class="para">1 megabyte (MB) = 1,024KB = 1,048,576 bytes</p>
<p class="para">1 gigabyte (GB) = 1,024MB = 1,073,741,824 bytes</p>
<p class="para">1 terabyte (TB) = 1,024GB = 1,099,511,627,776 bytes</p>
<p class="para">1 petabyte (PB) = 1,024TB = 1,125,899,906,842,624 bytes</p>
<table border="0" cellspacing="0" cellpadding="0" class="note">
<tr>
<td valign="top" class="admon-check"></td><td valign="top" class="admon-title">Note&nbsp;</td><td valign="top" class="admon-body">
<p class="first-para">In the 1980s, having a megabyte of DRAM was a big deal. Kids used to bug their parents for 16KB memory upgrades so their Atari 400s could play larger games. At the time, having only a megabyte wasn't a significant problem because engineers tended to program in assembly code and build very small programs. In fact, this 1981 quote is often attributed to Bill Gates: "640K ought to be enough for anybody."</p>
</td>
</tr>
</table>
<p class="para">Today, most development machines have at least 128MB of DRAM. In 2002, having 256MB seems to be the norm. Ten years from now, a gigabyte might be the standard amount of DRAM (if we are still using DRAM). Hopefully, someone will not quote me.</p>
<p class="para">RAM is not the only place to store data, and this is what leads us to the memory hierarchy. The range of different places that can be used to store information can be ordered according to their proximity to the processor. This ordering produces the following hierarchy:</p>
<ol class="orderedlist">
<li class="first-listitem">
<p class="first-para">Registers</p>
</li>
<li class="listitem">
<p class="first-para">Cache</p>
</li>
<li class="listitem">
<p class="first-para">RAM</p>
</li>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -