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

📄 chap12_5.htm

📁 MFC开发基础教程
💻 HTM
字号:
<html>

<head>
<title>小 结</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>

<body link="#3973DE" alink="#3973DE">
<font SIZE="5"><b><div align="center"><center>

<table border="0" width="615" cellspacing="0" cellpadding="0">
  <tr>
    </b><td><div align="center"><center><table border="0" width="615" cellpadding="0" cellspacing="0" height="20">
      <tr>
        <td width="377" bgcolor="#15397D" height="20"></td>
        <td width="238" bgcolor="#000000" height="20"><p align="right"></font><span style="text-decoration: none"><a href="../../index.htm"><font color="#FFFFFF">电脑报Visual 
        C++网络教程</font></a></span></td>
      </tr>
    </table>
    </center></div><font SIZE="3"><b><p ALIGN="CENTER"></b></font><font color="#3973DE" size="4">小 结</font><font FACE="Times New Roman" size="4"></p>
    <p ALIGN="CENTER"></font><font SIZE="3"> </font><font FACE="Times New Roman" SIZE="3"></p>
    <p ALIGN="JUSTIFY"></font><font SIZE="3">本章重点介绍了</font><font FACE="Times New Roman" SIZE="3">Win 32</font><font SIZE="3">环境下的多线程和串行通信编程。本章的要点如下:</p>
    <blockquote>
      <font FACE="Times New Roman" SIZE="3"><p ALIGN="JUSTIFY">Windows 3.x</font>实行的是协同式多任务,应用程序必须“自觉”地放弃<font FACE="Times New Roman" SIZE="3">CPU</font>控制权,否则系统会被挂起。</p>
      <font FACE="Times New Roman" SIZE="3"><p ALIGN="JUSTIFY">Windows 95/NT</font>实现了抢先式多任务,应用程序对<font FACE="Times New Roman" SIZE="3">CPU</font>的控制时间由系统分配,系统可以在任何时候中断应用程序,并把控制权转交给别的程序。</p>
      <p ALIGN="JUSTIFY">在<font FACE="Times New Roman" SIZE="3">Win 32</font>环境下,每个进程可以同时执行多个线程。线程是系统分配<font FACE="Times New Roman" SIZE="3">CPU</font>时间片的基本实体,系统在所有线程之间快速切换以实现多任务。</p>
      <p ALIGN="JUSTIFY">由于同一进程的所有线程共享进程的虚拟地址空间、<font FACE="Times New Roman" SIZE="3">Windows 95</font>的重入问题、<font FACE="Times New Roman" SIZE="3">MFC</font>在对象级的线程不安全性以及线程之间的协调等原因,多个线程必须同步执行。同步机制是由同步对象和等待函数共同实现的。同步对象主要包括事件、<font FACE="Times New Roman" SIZE="3">mutex</font>和信号灯,进程和线程句柄、文件和通信设备也可以用作同步对象。</p>
      <p ALIGN="JUSTIFY">在<font FACE="Times New Roman" SIZE="3">Win 32</font>中,传统的<font FACE="Times New Roman" SIZE="3">OpenComm</font>、<font FACE="Times New Roman" SIZE="3">ReadComm</font>、<font FACE="Times New Roman" SIZE="3">WriteComm</font>、<font FACE="Times New Roman" SIZE="3">CloseComm</font>等串行通信函数已经过时,<font FACE="Times New Roman" SIZE="3">WM_COMMNOTIFY</font>消息也消失了。程序应该调用<font FACE="Times New Roman" SIZE="3">CreateFile</font>打开一个串行通信设备,用<font FACE="Times New Roman" SIZE="3">ReadFile</font>和<font FACE="Times New Roman" SIZE="3">WriteFile</font>来进行<font FACE="Times New Roman" SIZE="3">I/O</font>操作,用<font FACE="Times New Roman" SIZE="3">WaitCommEvent</font>来监视通信事件。<font FACE="Times New Roman" SIZE="3">ReadFile</font>、<font FACE="Times New Roman" SIZE="3">WriteFile</font>和<font FACE="Times New Roman" SIZE="3">WaitCommEvent</font>既可以同步操作,也可以重叠操作。</p>
      <p ALIGN="JUSTIFY">利用<font FACE="Times New Roman" SIZE="3">Win 32</font>的重叠<font FACE="Times New Roman" SIZE="3">I/O</font>操作和多线程特性,程序员可以编写出高效的通信程序。</p>
      </font>
    </blockquote>
    <div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="615">
      <tr>
        <td><a href="chap12_4.htm">上一页</a></td>
        <td><p align="right"></td>
      </tr>
    </table>
    </center></div><font SIZE="5"><hr noshade color="#3973DE" size="1">
    <p align="center"></font><font size="2" color="#000000">本教程由<a href="http://vcdynasty.yeah.net">Visual C++王朝(Where programmers come together)</a>协助制作<br>
    未经许可,请勿以任何形式复制</font></td>
    <b>
  </tr>
</table>
</center></div>

<p ALIGN="CENTER"></b><font SIZE="5"> </font><font FACE="Times New Roman" SIZE="5"></p>
</font><font FACE="Times New Roman" SIZE="3">

<p></font><b><font SIZE="3"> </font><font FACE="Times New Roman" SIZE="3"></p>
</font></b>

<p><font SIZE="3"> </font><font FACE="Times New Roman" SIZE="3"></p>

<p></font> </p>
</body>
</html>

⌨️ 快捷键说明

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