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

📄 mem3.htm

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 6.0.5">
<meta name="TEMPLATEBASE" content="book_html">
<meta name="LASTUPDATED" content="12/01/03 14:14:34">
<title>4.2 Allocation strategies</title>

<STYLE TYPE="text/css">
<!--
	span.Signal { text-transform: uppercase; font-family: Verdana }
-->
</STYLE>

</head>

<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">

<p><img src="images/stlogo.gif" width="106" height="83" align="left"
alt="logo here!"> </p>

<table width="331" border="0" align="right" cellpadding="0" cellspacing="0">
  <tr>
    <td><a href="os20toc.htm"><img src="images/navtoc.gif" width="84" height="23"
    border="0" alt="TOC"> </a></td>
    <td><a href="mem2.htm"><img src="images/navprev.gif" width="80" height="23"
    border="0" alt="PREV"> </a></td>
    <td><a href="mem4.htm"><img src="images/navnext.gif" width="83" height="23"
    border="0" alt="NEXT"> </a></td>
    <td><a href="os20ix.htm"><img src="images/navidx.gif" width="84" height="23"
    border="0" alt="INDEX"> </a></td>
  </tr>
</table>

<p><br clear="all">
</p>

<hr align="left">

<blockquote>
<h2>
  <a name="1204460"> </a><font color="#003366"  face="Verdana, Arial, Helvetica, sans-serif">4.2 	 Allocation strategies</font>
</h2><hr>


<p>
  <a name="1204464"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">OS20 supports three types of partition:</font>
</p>

<ul>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204465"> </a><strong>Heap</strong></font></p>
  <dl>
    <dt> <a name="1205545"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">Heap partitions use the same style of memory allocator as the traditional C runtime <font size=2 face=Courier><strong>malloc</strong></font> and <font size=2 face=Courier><strong>free</strong></font> functions. Variable sized blocks can be allocated, with the requested size of memory being allocated by <font size=2 face=Courier><strong>memory_allocate</strong></font>. The first available block of memory is returned to the user. Blocks of memory may be deallocated using <font size=2 face=Courier><strong>memory_deallocate</strong></font>, in which case they are returned to the partition for re-use. When blocks are freed, if there is a free block before or after it, it is combined with that block to allow larger allocations.</font>
    <dt> <a name="1204466"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">Although the heap style of allocator is very versatile, it does have some disadvantages. It is not deterministic, the time taken to allocate and free memory is variable because it depends upon the previous allocations/deallocations performed and lists have to be searched. Also the overhead (additional memory which the allocator consumes for its own use) is quite high, with several additional words being required for each allocation.</font>
  </dl>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205564"> </a><strong>Fixed</strong></font></p>
  <dl>
    <dt> <a name="1205565"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">The fixed partition overcomes some of these problems, by fixing the size of the block which can be allocated when the partition is created, using <font size=2 face=Courier><strong>partition_create_fixed</strong></font> or <font size=2 face=Courier><strong>partition_init_fixed</strong></font>. This means that allocating and freeing a block takes constant time (it is deterministic), and there is a very small memory overhead. Thus this partition ignores the <font size=2 face=Courier><strong>size</strong></font> argument when an allocation is preformed by <font size=2 face=Courier><strong>memory_allocate</strong></font> and uses instead the <font size=2 face=Courier><strong>size</strong></font> argument passed by either <font size=2 face=Courier><strong>partition_create_fixed</strong></font> or <font size=2 face=Courier><strong>partition_init_fixed</strong></font>.</font>
    <dt> <a name="1204468"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">Blocks of memory may be deallocated using <font size=2 face=Courier><strong>memory_deallocate</strong></font>, in which case they are returned to the partition for re-use.</font>
  </dl>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204469"> </a><strong>Simple</strong></font></p>
  <dl>
    <dt> <a name="1205573"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">The simple partition is a trivial allocator, which just increments a pointer to the next available block of memory. This means that it is impossible to free any memory back to the partition, but there is no wasted memory when performing memory allocations. Thus this partition is ideal for allocating internal memory. Variable sized blocks of memory can be allocated, with the size of block being defined by the argument to <font size=2 face=Courier><strong>memory_allocate</strong></font> and the time taken to allocate memory is constant.</font>
  </dl>
</ul>

<p>
  <a name="1204519"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">The properties of the three partition types are summarized in <a href="mem3.htm#1205430"><font  color="#0000ff" face="Verdana, Arial, Helvetica, sans-serif"><i>Table

⌨️ 快捷键说明

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