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

📄 posix 线程详解1.htm

📁 POSIX平台多线程编程指南 通用开放式操作系统的多线程应用指南。
💻 HTM
📖 第 1 页 / 共 5 页
字号:
            进行相对复杂的数学运算,而不是简单的加一,这种方法就会失效。但是为什么呢?</P>
            <P>要理解这个问题,必须记住线程是并发运行的。即使在单处理器系统上运行(内核利用时间分片模拟多任务)也是可以的,从程序员的角度,想像两个线程是同时执行的。thread2.c 
            出现问题是因为 thread_function() 依赖以下论据:在 myglobal 加一之前的大约一秒钟期间不会修改 
            myglobal。需要有些途径让一个线程在对 myglobal 
            做更改时通知其它线程“不要靠近”。我将在下一篇文章中讲解如何做到这一点。到时候见。</P><BR>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD><IMG height=1 alt="" src="POSIX 线程详解1.files/blue_rule.gif" 
                  width="100%"><BR><IMG height=6 alt="" 
                  src="POSIX 线程详解1.files/c.gif" width=8 
            border=0></TD></TR></TBODY></TABLE>
            <TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
              <TBODY>
              <TR align=right>
                <TD><IMG height=4 alt="" src="POSIX 线程详解1.files/c.gif" 
                  width="100%"><BR>
                  <TABLE cellSpacing=0 cellPadding=0 border=0>
                    <TBODY>
                    <TR>
                      <TD vAlign=center><IMG height=16 alt="" 
                        src="POSIX 线程详解1.files/u_bold.gif" width=16 
                      border=0><BR></TD>
                      <TD vAlign=top align=right><A class=fbox 
                        href="http://www-128.ibm.com/developerworks/cn/linux/thread/posix_thread1/index.html#main"><B>回页首</B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
            <P><A name=resources><SPAN class=atitle>参考资料 </SPAN></A></P>
            <UL>
              <LI>您可以参阅本文在 developerWorks 全球站点上的 <A 
              href="http://www.ibm.com/developerworks/library/l-deb.html">英文原文</A>. 
              <BR><BR>
              <LI>参阅 <A 
              href="http://metalab.unc.edu/pub/Linux/docs/faqs/Threads-FAQ/html/">Linux 
              threads</A>中的文档,Sean Walton, KB7rfa <BR><BR>
              <LI>在 <A href="http://hwaci.com/sw/pttcl/pttcl.html">An 
              Introduction to Pthreads-Tcl</A> 中,查看对 Tcl 的更改以使其能够使用 POSIX 线程 
              <BR><BR>
              <LI>使用友好的 Linux pthread 在线帮助 ("man -k pthread")<BR><BR>
              <LI>参考 <A href="http://members.aa.net/~mtp/PCthreads.html">POSIX 
              and DCE threads for Linux</A>主页 <BR><BR>
              <LI>查看 <A 
              href="http://pauillac.inria.fr/~xleroy/linuxthreads/">The 
              LinuxThreads Library</A> <BR><BR>
              <LI><A 
              href="http://www.users.itl.net.ua/~prool/proolix.html">Proolix</A> 
              ,一种简单遵从 POSIX 标准的操作系统,用于 i8086+,一直在开发中 <BR><BR>
              <LI>阅读 David R. Butenhof 的著作 <A 
              href="http://www.amazon.com/exec/obidos/ASIN/0201633922/o/qid=961544788/sr=8-1/ref=aps_sr_b_1_1/002-2882413-1227240">Programming 
              with POSIX Threads</A>,书中讨论了许多问题,其中谈到不使用互斥对象是可能出现的种种情况 <BR><BR>
              <LI>查阅 W. Richard Stevens 的著作 <A 
              href="http://search.borders.com/fcgi-bin/db2www/search/search.d2w/Details?&amp;mediaType=Book&amp;prodID=2362607">UNIX 
              Network Programming: Network APIs: Sockets and XTI, Volume 1</A> 
              <BR></LI></UL><BR>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD><IMG height=1 alt="" src="POSIX 线程详解1.files/blue_rule.gif" 
                  width="100%"><BR><IMG height=6 alt="" 
                  src="POSIX 线程详解1.files/c.gif" width=8 
            border=0></TD></TR></TBODY></TABLE>
            <TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
              <TBODY>
              <TR align=right>
                <TD><IMG height=4 alt="" src="POSIX 线程详解1.files/c.gif" 
                  width="100%"><BR>
                  <TABLE cellSpacing=0 cellPadding=0 border=0>
                    <TBODY>
                    <TR>
                      <TD vAlign=center><IMG height=16 alt="" 
                        src="POSIX 线程详解1.files/u_bold.gif" width=16 
                      border=0><BR></TD>
                      <TD vAlign=top align=right><A class=fbox 
                        href="http://www-128.ibm.com/developerworks/cn/linux/thread/posix_thread1/index.html#main"><B>回页首</B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
            <P><A name=author><SPAN class=atitle>关于作者</SPAN></A></P>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD colSpan=3><IMG height=5 alt="" 
                  src="POSIX 线程详解1.files/c.gif" width="100%"></TD></TR>
              <TR vAlign=top align=left>
                <TD>
                  <P></P></TD>
                <TD><IMG height=5 alt="" src="POSIX 线程详解1.files/c.gif" 
                width=4></TD>
                <TD width="100%">
                  <P>Daniel Robbins 居住在新墨西哥州的 Albuquerque。他是 Gentoo 
                  Technologies, Inc. 的总裁兼 CEO, Gentoo 项目的总设计师,多本 MacMillan 
                  出版书籍的作者,包括: <I>Caldera OpenLinux Unleashed</I>、 <I>SuSE Linux 
                  Unleashed</I>和 <I>Samba Unleashed</I> 。Daniel 
                  自小学二年级起就与计算机结下不解之缘,那时他首先接触的是 Logo 程序语言,并沉溺于 Pac-Man 
                  游戏中。这也许就是他至今仍担任 SONY Electronic Publishing/Psygnosis 
                  的首席图形设计师的原因所在。Daniel 喜欢与妻子 Mary 和刚出生的女儿 Hadassah 一起共渡时光。可通过 <A 
                  href="mailto:drobbins@gentoo.org">drobbins@gentoo.org</A> 与 
                  Daniel Robbins 取得联系。 </P></TD></TR></TBODY></TABLE><BR><BR>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD><IMG height=1 alt="" src="POSIX 线程详解1.files/blue_rule.gif" 
                  width="100%"><BR><IMG height=6 alt="" 
                  src="POSIX 线程详解1.files/c.gif" width=8 
            border=0></TD></TR></TBODY></TABLE>
            <TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
              <TBODY>
              <TR align=right>
                <TD><IMG height=4 alt="" src="POSIX 线程详解1.files/c.gif" 
                  width="100%"><BR>
                  <TABLE cellSpacing=0 cellPadding=0 border=0>
                    <TBODY>
                    <TR>
                      <TD vAlign=center><IMG height=16 alt="" 
                        src="POSIX 线程详解1.files/u_bold.gif" width=16 
                      border=0><BR></TD>
                      <TD vAlign=top align=right><A class=fbox 
                        href="http://www-128.ibm.com/developerworks/cn/linux/thread/posix_thread1/index.html#main"><B>回页首</B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
            <P class=no-print><SPAN class=atitle><A 
            name=rate>对本文的评价</A></SPAN></P><SPAN class=no-print>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR vAlign=top>
                <TD>
                  <FORM 
                  action=https://www-128.ibm.com/developerworks/secure/cnratings.jsp 
                  method=get><INPUT type=hidden value="POSIX 线程详解" 
                  name=ArticleTitle><INPUT type=hidden value=Linux 
                  name=Zone><INPUT type=hidden 
                  value=http://www.ibm.com/developerworks/cn/thankyou/ 
                  name=RedirectURL><INPUT type=hidden value=china 
name=localsite>
                  <SCRIPT language=javascript>document.write('<input type="hidden" name="url" value="'+location.href+'">');</SCRIPT>

                  <TABLE cellSpacing=0 cellPadding=0 border=0>
                    <TBODY>
                    <TR>
                      <TD><IMG height=8 alt="" src="POSIX 线程详解1.files/c.gif" 
                        width=100 border=0></TD></TR>
                    <TR vAlign=top>
                      <TD><INPUT type=radio value=1 name=Rating>太差! (1)</TD></TR>
                    <TR vAlign=top>
                      <TD><INPUT type=radio value=2 name=Rating>需提高 (2)</TD></TR>
                    <TR vAlign=top>
                      <TD><INPUT type=radio value=3 name=Rating>一般;尚可 
(3)</TD></TR>
                    <TR vAlign=top>
                      <TD><INPUT type=radio value=4 name=Rating>好文章 (4)</TD></TR>
                    <TR vAlign=top>
                      <TD><INPUT type=radio value=5 
                    name=Rating>真棒!(5)</TD></TR></TBODY></TABLE><BR><B>建议?</B><BR><TEXTAREA id=Comments name=Comments rows=5 wrap=virtual cols=60>&nbsp;</TEXTAREA><BR><BR><INPUT type=submit value=反馈意见></FORM></TD></TR>
              <TR vAlign=top>
                <TD bgColor=#ffffff><IMG height=8 alt="" 
                  src="POSIX 线程详解1.files/c.gif" width=100 
            border=0></TD></TR></TBODY></TABLE></SPAN><SPAN class=no-print>
            <TABLE cellSpacing=0 cellPadding=0 align=right>
              <TBODY>
              <TR align=right>
                <TD><IMG height=8 alt="" src="POSIX 线程详解1.files/c.gif" 
                  width="100%"><BR>
                  <TABLE cellSpacing=0 cellPadding=0 border=0>
                    <TBODY>
                    <TR>
                      <TD vAlign=center><IMG height=16 alt="" 
                        src="POSIX 线程详解1.files/u_bold.gif" width=16 
                      border=0><BR></TD>
                      <TD vAlign=top align=right><A class=fbox 
                        href="http://www-128.ibm.com/developerworks/cn/linux/thread/posix_thread1/index.html#main"><B>回页首</B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR></SPAN></TD>
          <TD width=10><IMG height=1 alt="" src="POSIX 线程详解1.files/c.gif" 
            width=10></TD></TR></TBODY></TABLE>
      <P class=greytext>其他公司、产品或服务的名称可能是其他公司的商标或服务标志。</P></TD></TR></TBODY></TABLE><!--FOOTER_BEGIN--><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD class=bbg height=19>
      <TABLE cellSpacing=0 cellPadding=0 border=0>
        <TBODY>
        <TR>
          <TD><SPAN class=spacer>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><A 
            class=mainlink href="http://www.ibm.com/cn/ibm/index.shtml">关于 
            IBM</A></TD>
          <TD class=footer-divider width=27>&nbsp;&nbsp;&nbsp;&nbsp;</TD>
          <TD><A class=mainlink 
            href="http://www.ibm.com/cn/ibm/privacy/index.shtml">隐私条约</A></TD>
          <TD class=footer-divider width=27>&nbsp;&nbsp;&nbsp;&nbsp;</TD>
          <TD><A class=mainlink href="http://www.ibm.com/contact/">联系 
          IBM</A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<SCRIPT language=JavaScript1.2 src="POSIX 线程详解1.files/stats.js" 
type=text/javascript></SCRIPT>
<NOSCRIPT><IMG height=1 alt="" 
src="E:\MyLove\资料\Posix线程编程指南\POSIX 线程详解1.files\c(1).gif" width=1 
border=0></NOSCRIPT><!--FOOTER_END--><!--XSLT stylesheet used to transform this file:  dw-document-html-5.3.xsl--> 
</BODY></HTML>

⌨️ 快捷键说明

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