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

📄 421-424.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!-- LEFT NAV SEARCH END -->

		</td>
		
<!-- PUB PARTNERS END -->
<!-- END LEFT NAV -->

<td rowspan="8" align="right" valign="top"><img src="/images/iswbls.gif" width=1 height=400 alt="" border="0"></td>
<td><img src="/images/white.gif" width="5" height="1" alt="" border="0"></td>
<!-- end of ITK left NAV -->

<!-- begin main content -->
<td width="100%" valign="top" align="left">


<!-- END SUB HEADER -->

<!--Begin Content Column -->

<FONT FACE="Arial,Helvetica" SIZE="-1">
To access the contents, click the chapter and section titles.
</FONT>
<P>
<B>Essential Windows CE Application Programming</B>
<FONT SIZE="-1">
<BR>
<I>(Publisher: John Wiley & Sons, Inc.)</I>
<BR>
Author(s): Robert Burdick
<BR>
ISBN: 0471327476
<BR>
Publication Date: 03/01/99
</FONT>
<P>
<form name="Search" method="GET" action="http://search.earthweb.com/search97/search_redir.cgi">

<INPUT TYPE="hidden" NAME="Action" VALUE="Search">
<INPUT TYPE="hidden" NAME="SearchPage" VALUE="http://search.earthweb.com/search97/samples/forms/srchdemo.htm">
<INPUT TYPE="hidden" NAME="Collection" VALUE="ITK">
<INPUT TYPE="hidden" NAME="ResultTemplate" VALUE="itk-simple-intrabook.hts">
<INPUT TYPE="hidden" NAME="ViewTemplate" VALUE="view.hts">

<font face="arial, helvetica" size=2><b>Search this book:</b></font><br>
<INPUT NAME="queryText" size=50 VALUE="">&nbsp;<input type="submit" name="submitbutton" value="Go!">
<INPUT type=hidden NAME="section_on" VALUE="on">
<INPUT type=hidden NAME="section" VALUE="http://www.itknowledge.com/reference/standard/0471327476/">

</form>


<!-- Empty Reference Subhead -->

<!--ISBN=0471327476//-->
<!--TITLE=Essential Windows CE Application Programming//-->
<!--AUTHOR=Robert Burdick//-->
<!--PUBLISHER=John Wiley & Sons, Inc.//-->
<!--IMPRINT=Wiley Computer Publishing//-->
<!--CHAPTER=16//-->
<!--PAGES=421-424//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch15/419-420.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="424-428.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 16<BR>Memory and Power Management
</FONT></H2>
<P><BIG><BIG>A</BIG></BIG>s we have seen throughout this book, Windows CE provides many powerful features that allow product designers and application developers to create highly complex devices based on this operating system. However, the Windows CE operating system was designed primarily for small platforms, to encourage its use in the mobile computing arena.</P>
<P>Windows CE is particularly suited to the needs of small desktop PC companion products such as the Handheld PC and the Palm-size PC. The design emphasis on most <I>successful</I> handheld computing products on the market today has been small and convenient size and low price. Also, even though many Windows CE devices can be powered with an AC adapter, a key feature of successful products is long battery life.</P>
<P>Maintaining low competitive prices for mobile computing devices means reducing the cost of the hardware used in a given product. This generally means that mobile devices have much less memory than a desktop computer. Smaller and cheaper batteries are also commonly used to reduce the overall bill of materials.</P>
<P>Reduced memory budgets translate into devices that are very often run in low memory conditions. Relying on battery power means that devices must be designed with power efficiency in mind. In this chapter we discuss the memory and power management features of Windows CE. The memory and power APIs are explored, as well as ways in which applications can be written to handle low memory states.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>AFTER COMPLETING THIS CHAPTER YOU WILL KNOW HOW TO &#133;</B>
<DL>
<DD><B>Use the Windows CE memory management APIs to use available memory efficiently</B>
<DD><B>Use Windows CE memory mapped files</B>
<DD><B>Programmatically get power status diagnostics about a Windows CE device</B>
<DD><B>Write applications capable of handling low memory conditions</B>
</DL>
<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">The Sample Application</FONT></H3>
<P>A simple application demonstrating the concepts covered in this chapter is included on the companion CD. The directory \Samples\memory contains the project files necessary to build MEMORY.EXE. The screen shots in this chapter all show various features implemented by this application.
</P>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Windows CE Memory Basics</FONT></H3>
<P>Memory on Windows CE devices is divided into read-only memory (ROM) and random access memory (RAM).
</P>
<P>Windows CE device RAM is divided into two sections. The first is <I>program memory</I>. Applications that you write and download to a Windows CE device get stored in program memory. Program memory also provides the memory for application heaps and stacks. For example, whenever you allocate memory using the function <I>LocalAlloc</I>, the memory allocated comes from the device program memory.</P>
<P>The second section of RAM is devoted to the <I>object store</I>. This is the memory that is used for the Windows CE file system, the registry, and Windows CE databases. These subjects are covered in detail in Part II of this book, &#147;Windows CE Persistent Storage.&#148; We therefore will not discuss the object store further in this chapter.</P>
<P>The amount of RAM devoted to each of these memory sections can be changed by the user. The Memory tab in the System Control Panel provides an interface for adjusting the memory boundary between program memory and object store memory.</P>
<P>ROM typically stores the entire operating system as well as any applications that are included with the device. For example, when you buy a Handheld PC, Microsoft Pocket Word is included as part of the software that comes pre-installed on the device. This application, and all other software that comes pre-installed on the product, is in ROM.</P>
<P>Applications stored in ROM are run in-place by Windows CE. This means that the application code is run directly from ROM and does not need to be paged into program memory. ROM-based applications therefore run much faster than applications in program memory.</P>
<P><FONT SIZE="+1"><B>The Windows CE Address Space</B></FONT></P>
<P>As a 32-bit operating system, Windows CE defines a 4 GB address space. Two gigabytes of this space are reserved by Windows CE for hardware access. The other 2 GB block is the virtual memory space shared by all applications.
</P>
<P>Windows CE divides 1.056 GB of this virtual address space into 33 process slots. Each of these slots occupies 32 MB of the 2 GB application virtual address space. Except for a small amount reserved by Windows CE, the rest of the virtual address space is used for memory mapped files.</P>
<P>The Windows CE API provides a number of functions for determining the global state of a Windows CE device. These functions can be used to determine the current physical and virtual memory usage, as well as current object store memory status.</P>
<P><FONT SIZE="+1"><B><I>The</I> GlobalMemoryStatus <I>Function
</I></B></FONT></P>
<P>The Windows CE API provides a number of functions for determining the global state of a Windows CE device. These functions can be used to determine the current physical and virtual memory usage, as well as current object store memory status.
</P>
<P>The function <I>GlobalMemoryStatus</I> gives information about physical and virtual memory:</P>
<!-- CODE SNIP //-->
<PRE>
  GlobalMemoryStatus(lpmst);
</PRE>
<!-- END CODE SNIP //-->
<P>The parameter <I>lpmst</I> is a pointer to a MEMORYSTATUS structure. <I>GlobalMemoryStatus</I> fills this structure with information about the current device memory status. The structure is defined as:</P>
<!-- CODE //-->
<PRE>
  typedef struct _MEMORYSTATUS &#123;
    DWORD dwLength;
    DWORD dwMemoryLoad;
    DWORD dwTotalPhys;
    DWORD dwAvailPhys;
    DWORD dwTotalPageFile;
    DWORD dwAvailPageFile;
    DWORD dwTotalVirtual;
    DWORD dwAvailVirtual;
  &#125; MEMORYSTATUS, *LPMEMORYSTATUS;
</PRE>
<!-- END CODE //-->
<P>The caller of <I>GlobalMemoryStatus</I> must set the <I>dwLength</I> member to the size, in bytes, of the structure.</P>
<P>When the function returns, <I>dwLoad</I> contains the percentage of total memory in use. <I>dwTotalPhys</I> and <I>dwAvailPhys</I> give the total amount of physical memory on the device and the amount of that memory not in use, respectively. <I>dwTotalVirtual</I> and <I>dwAvailVirtual</I> give similar diagnostics for the virtual memory status.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch15/419-420.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="424-428.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- BEGIN SUB FOOTER -->
		<br><br>
		</TD>
    </TR>
	</TABLE>

		
	<table width="640" border=0 cellpadding=0 cellspacing=0>
		<tr>
		<td align="left" width=135><img src="/images/white.gif" width=100 height="1" alt="" border="0"></td>
		
		
<!-- END SUB FOOTER -->

<!-- all of the books have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- FOOTER -->
			
		<td width="515" align="left" bgcolor="#FFFFFF">
<font face="arial, helvetica" size="1"><b><a href="/products.html"><font color="#006666">Products</font></a>&nbsp;|&nbsp; <a href="/contactus.html"><font color="#006666">Contact Us</font></a>&nbsp;|&nbsp; <a href="/aboutus.html"><font color="#006666">About Us</font></a>&nbsp;|&nbsp; <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> &nbsp;|&nbsp; <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> &nbsp;|&nbsp; <a href="/"><font color="#006666">Home</font></a></b>
		<br><br>
		
		Use of this site is subject to certain <a href="/agreement.html">Terms &amp; Conditions</a>, <a href="/copyright.html">Copyright &copy; 1996-1999 EarthWeb Inc.</a><br> 
All rights reserved.  Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.</font><p>
</td>
		</tr>
</table>
</BODY>
</HTML>

<!-- END FOOTER -->

⌨️ 快捷键说明

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