{"id":47,"date":"2012-11-20T18:03:56","date_gmt":"2012-11-20T10:03:56","guid":{"rendered":"http:\/\/sunyuping.cn\/?p=47"},"modified":"2012-11-20T18:03:56","modified_gmt":"2012-11-20T10:03:56","slug":"%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%bc%96%e7%a8%8b%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.sunyuping.com\/index.php\/2012\/11\/20\/%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%bc%96%e7%a8%8b%e6%8c%87%e5%8d%97\/","title":{"rendered":"\u591a\u7ebf\u7a0b\u7f16\u7a0b\u6307\u5357"},"content":{"rendered":"<p>\t\t\t\t1. \u5173\u4e8e\u591a\u7ebf\u7a0b\u7f16\u7a0b<br \/>\n\u591a\u5e74\u4ee5\u6765\uff0c\u8ba1\u7b97\u673a\u7684\u6027\u80fd\u5728\u5f88\u5927\u7a0b\u5ea6\u4e0a\u88ab\u5355\u6838\u5904\u7406\u5668\u7684\u901f\u5ea6\u6240\u9650\u5236\u3002\u5728\u5f53\u524d\u6280\u672f\u4e0b\uff0c\u5355\u6838\u5904\u7406\u5668\u7684\u901f\u5ea6\u5df2\u7ecf\u5230\u8fbe\u67d0\u79cd\u6781\u9650\uff0c\u56e0\u6b64\uff0c\u82af\u7247\u5236\u9020\u5546\u4eec\u8f6c\u800c\u4e13\u6ce8\u4e8e\u591a\u6838\u8bbe\u8ba1\uff0c\u4ee5\u4f7f\u8ba1\u7b97\u673a\u53ef\u4ee5\u540c\u65f6\u6267\u884c\u591a\u4e2a\u4efb\u52a1\u3002Mac OS X \u53ef\u4ee5\u5229\u7528\u591a\u6838\u8ba1\u7b97\uff0c\u66f4\u597d\u7684\u6267\u884c\u7cfb\u7edf\u76f8\u5173\u7684\u4efb\u52a1\u3002\u800c\u5f00\u53d1\u4eba\u5458\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7ebf\u7a0b\u63d0\u9ad8\u81ea\u5df1\u7a0b\u5e8f\u7684\u6027\u80fd\u3002<br \/>\n1) \u4ec0\u4e48\u662f\u7ebf\u7a0b\uff1f<br \/>\n\u7ebf\u7a0b\u662f\u5728\u7a0b\u5e8f\u5185\u90e8\u8fd0\u884c\u591a\u4e2a\u6d41\u7a0b\u7684\u8f7b\u91cf\u5355\u4f4d\u3002\u5728\u7cfb\u7edf\u7ea7\u522b\u4e0a\uff0c\u7a0b\u5e8f\u4f7f\u7528\u7cfb\u7edf\u63d0\u4f9b\u7684\u6267\u884c\u65f6\u95f4\uff0c\u5404\u81ea\u8fd0\u884c\u3002\u7136\u800c\uff0c\u5728\u6bcf\u4e2a\u7a0b\u5e8f\u5185\u90e8\uff0c\u5b58\u5728\u7740\u4e00\u4e2a\u6216\u591a\u4e2a\u88ab\u6267\u884c\u7684\u7ebf\u7a0b\uff0c\u8fd9\u4e9b\u7ebf\u7a0b\u53ef\u4ee5\u5728\u540c\u4e00\u65f6\u523b\uff08\u6216\u5c06\u8fd1\u540c\u65f6\uff09\u5b8c\u6210\u4e0d\u540c\u7684\u4efb\u52a1\u3002\u7531\u64cd\u4f5c\u7cfb\u7edf\u672c\u8eab\u7ba1\u7406\u8fd9\u4e9b\u7ebf\u7a0b\u7684\u6267\u884c\uff0c\u4f8b\u5982\u4e3a\u7ebf\u7a0b\u5206\u914d\u6267\u884c\u65f6\u95f4\u548c\u6267\u884c\u7684\u5185\u6838\uff0c\u6216\u662f\u4e2d\u65ad\u7ebf\u7a0b\u6765\u4f7f\u5176\u4ed6\u7ebf\u7a0b\u6709\u673a\u4f1a\u6267\u884c\u3002<br \/>\n\u4ece\u6280\u672f\u89d2\u5ea6\u6765\u770b\uff0c\u7ebf\u7a0b\u662f\u201c\u5185\u6838\u7ea7\u201d\u548c\u201c\u7a0b\u5e8f\u7ea7\u201d\u6570\u636e\u7ed3\u6784\u7684\u96c6\u5408\uff0c\u7528\u6765\u7ba1\u7406\u4ee3\u7801\u7684\u6267\u884c\u3002\u5185\u6838\u7ea7\u7684\u6570\u636e\u7ed3\u6784\u4e3b\u8981\u5904\u7406\u9488\u5bf9\u7ebf\u7a0b\u7684\u4e8b\u4ef6\uff0c\u5b89\u6392\u7ebf\u7a0b\u5728\u53ef\u7528\u7684\u5185\u6838\u4e0a\u6267\u884c\u3002\u800c\u7a0b\u5e8f\u7ea7\u7684\u7ed3\u6784\u5305\u62ec\u8c03\u7528\u6808\uff08\u53ef\u4ee5\u4fdd\u5b58\u51fd\u6570\u8c03\u7528\uff09\uff0c\u8fd8\u6709\u7528\u6765\u7ba1\u7406\u548c\u8ba1\u7b97\u7ebf\u7a0b\u5c5e\u6027\u548c\u72b6\u6001\u7684\u6570\u636e\u3002<br \/>\n\u5728\u975e\u5e76\u884c\u7a0b\u5e8f\u4e2d\uff0c\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u7684\u6267\u884c\u3002\u7ebf\u7a0b\u8d77\u59cb\u4e8emain\u51fd\u6570\uff0c\u7ed3\u675f\u4e8emain\u51fd\u6570\u3002\u5728main\u51fd\u6570\u5185\u90e8\uff0c\u7a0b\u5e8f\u4e00\u53e5\u4e00\u53e5\u7684\u6267\u884c\u3002\u76f8\u6bd4\u8f83\u800c\u8a00\uff0c\u652f\u6301\u5e76\u884c\u7684\u7a0b\u5e8f\u8d77\u59cb\u4e8e\u4e00\u4e2a\u7ebf\u7a0b\uff0c\u7136\u540e\u5728\u6dfb\u52a0\u5176\u4ed6\u7ebf\u7a0b\uff0c\u4ece\u800c\u521b\u5efa\u4e86\u989d\u5916\u7684\u6267\u884c\u8def\u5f84\u3002\u6bcf\u4e2a\u8fd9\u6837\u7684\u8def\u5f84\u90fd\u62e5\u6709\u81ea\u5df1\u7684\u6267\u884c\u8fc7\u7a0b\uff0c\u800c\u548c\u7a0b\u5e8f\u4e2d\u7684\u4e3b\u7ebf\u7a0b\u5e76\u884c\u4e0d\u6096\u3002\u5728\u7a0b\u5e8f\u4e2d\u52a0\u5165\u591a\u7ebf\u7a0b\uff0c\u4f1a\u4e3a\u4f60\u5e26\u6765\u4ee5\u4e0b\u4e24\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u597d\u5904\uff1a<br \/>\n1. \u591a\u7ebf\u7a0b\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u53cd\u5e94\u901f\u5ea6\u3002<br \/>\n2. \u5728\u591a\u6838\u7cfb\u7edf\u4e0a\uff0c\u591a\u7ebf\u7a0b\u53ef\u4ee5\u589e\u5f3a\u7a0b\u5e8f\u7684\u5b9e\u65f6\u5904\u7406\u80fd\u529b\u3002<br \/>\n\u5982\u679c\u4f60\u7684\u7a0b\u5e8f\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\uff0c\u8fd9\u4e00\u4e2a\u7ebf\u7a0b\u5c31\u5f97\u505a\u6240\u6709\u4e8b\u60c5\u3002\u5b83\u5fc5\u987b\u54cd\u5e94\u4e8b\u4ef6\u3001\u66f4\u65b0\u7a0b\u5e8f\u7a97\u53e3\u3001\u6267\u884c\u6240\u6709\u7684\u8fd0\u7b97\u5de5\u4f5c\u3002\u5355\u7ebf\u7a0b\u7684\u95ee\u9898\u662f\u5728\u7279\u5b9a\u65f6\u523b\u5185\uff0c\u5b83\u53ea\u80fd\u5904\u7406\u4e00\u4ef6\u4e8b\u3002\u90a3\u4e48\u5982\u679c\u6211\u4eec\u7684\u67d0\u4e9b\u8ba1\u7b97\u5de5\u4f5c\u9700\u8981\u8017\u8d39\u5f88\u957f\u65f6\u95f4\uff0c\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u5f53\u4ee3\u7801\u5fd9\u4e8e\u8ba1\u7b97\u9700\u8981\u7684\u503c\u65f6\uff0c\u7a0b\u5e8f\u5c31\u505c\u6b62\u5bf9\u7528\u6237\u4e8b\u4ef6\u7684\u54cd\u5e94\uff0c\u4e5f\u4e0d\u4f1a\u518d\u5bf9\u7a97\u53e3\u8fdb\u884c\u66f4\u65b0\u3002\u5982\u679c\u65f6\u95f4\u5f88\u957f\u7684\u8bdd\uff0c\u7528\u6237\u53ef\u80fd\u4ee5\u4e3a\u7a0b\u5e8f\u5361\u4f4f\u4e86\uff0c\u5f3a\u884c\u5173\u95ed\u7a0b\u5e8f\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u5c06\u9700\u8981\u7684\u8ba1\u7b97\u5de5\u4f5c\u653e\u5230\u4e00\u4e2a\u72ec\u7acb\u7684\u7ebf\u7a0b\u4e2d\u53bb\uff0c\u4f60\u7684\u4e3b\u7ebf\u7a0b\u5c31\u6709\u8db3\u591f\u7684\u65f6\u95f4\u53bb\u54cd\u5e94\u7528\u6237\u4e8b\u4ef6\u3002<br \/>\n\u5728\u591a\u6838\u7535\u8111\u65e5\u76ca\u666e\u53ca\u7684\u4eca\u5929\uff0c\u7ebf\u7a0b\u63d0\u9ad8\u4e86\u67d0\u4e9b\u7a0b\u5e8f\u7684\u6027\u80fd\u3002\u6267\u884c\u591a\u4e2a\u4efb\u52a1\u7684\u7ebf\u7a0b\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u5904\u7406\u5668\u5185\u6838\uff0c\u4ece\u800c\u4f7f\u589e\u52a0\u7ed9\u5b9a\u65f6\u95f4\u5185\u5b8c\u6210\u7684\u5de5\u4f5c\u91cf\u6210\u4e3a\u53ef\u80fd\u3002<br \/>\n\u4f46\u662f\uff0c\u7ebf\u7a0b\u5e76\u4e0d\u662f\u6539\u5584\u7a0b\u5e8f\u6027\u80fd\u95ee\u9898\u7684\u4e07\u91d1\u6cb9\u3002\u4f34\u968f\u7740\u7ebf\u7a0b\u63d0\u4f9b\u7684\u597d\u5904\uff0c\u66f4\u591a\u7684\u6f5c\u5728\u95ee\u9898\u4e5f\u968f\u4e4b\u4ea7\u751f\u3002\u5728\u7a0b\u5e8f\u4e2d\u52a0\u5165\u591a\u4e2a\u6267\u884c\u8def\u5f84\u4f1a\u5927\u5927\u589e\u52a0\u4ee3\u7801\u7684\u590d\u6742\u5ea6\u3002\u6bcf\u4e2a\u7ebf\u7a0b\u90fd\u9700\u8981\u534f\u8c03\u5404\u81ea\u7684\u884c\u4e3a\uff0c\u6765\u9632\u6b62\u5f04\u4e71\u7a0b\u5e8f\u7684\u72b6\u6001\u3002\u8fd9\u662f\u56e0\u4e3a\u4f4d\u4e8e\u540c\u4e00\u7a0b\u5e8f\u7684\u6240\u6709\u7ebf\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u5185\u5b58\u7a7a\u95f4\uff0c\u5b83\u4eec\u5bf9\u6240\u6709\u7684\u8fd9\u4e9b\u6570\u636e\u7ed3\u6784\u90fd\u6709\u8bbf\u95ee\u6743\u9650\u3002\u5982\u679c\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8ba1\u7b97\u4e00\u4efd\u6570\u636e\uff0c\u5176\u4e2d\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u80fd\u5c06\u53e6\u5916\u7ebf\u7a0b\u4fee\u6539\u7684\u5185\u5bb9\u8986\u76d6\uff0c\u90a3\u4e48\u8ba1\u7b97\u7ed3\u679c\u5c31\u4e71\u5957\u4e86\u3002\u5373\u4f7f\u662f\u4f7f\u7528\u4e86\u6070\u5f53\u7684\u4fdd\u62a4\u65b9\u5f0f\uff0c\u6211\u4eec\u8fd8\u662f\u5fc5\u987b\u6ce8\u610f\u7f16\u8bd1\u5668\u4f18\u5316\u9009\u9879\uff08\u5b83\u53ef\u80fd\u5bfc\u81f4\u4ee3\u7801\u51fa\u73b0\u5f88\u5fae\u5999\u7684\u9519\u8bef\uff09\u3002<br \/>\n2\uff09\u7ebf\u7a0b\u76f8\u5173\u672f\u8bed<br \/>\n\u5728\u6df1\u5165\u7814\u7a76\u7ebf\u7a0b\u548c\u76f8\u5173\u6280\u672f\u4e4b\u524d\uff0c\u5fc5\u987b\u5148\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u672f\u8bed\u7684\u5b9a\u4e49\u3002<br \/>\n\u5982\u679c\u4f60\u719f\u6089Carbon\u6846\u67b6\u4e2d\u7684\u591a\u6838\u5904\u7406\u670d\u52a1\u63a5\u53e3\uff08Multiprocessor Services API\uff09\uff0c\u6216\u662f\u719f\u6089Unix\u7cfb\u7edf\uff0c\u4f60\u5c06\u4f1a\u53d1\u73b0\u672f\u8bed\u201c\u4efb\u52a1\u201d(task)\u5728\u672c\u6587\u6863\u4e2d\u7684\u542b\u4e49\u7565\u6709\u4e0d\u540c\u3002\u5728Mac OS\u7684\u65e9\u671f\u7248\u672c\u4e2d\uff0c\u672f\u8bed\u201c\u4efb\u52a1\u201d\u88ab\u7528\u6765\u533a\u522b\u4f7f\u7528Multiprocessor Services\u521b\u5efa\u7684\u548c\u4f7f\u7528Carbon Thread Manager\u521b\u5efa\u7684\u7ebf\u7a0b\u3002\u800c\u5728Unix\u7cfb\u7edf\u4e4b\u4e0a\uff0c\u672f\u8bed\u201c\u4efb\u52a1\u201d\u6709\u65f6\u6307\u7684\u662f\u8fd0\u884c\u4e2d\u7684\u8fdb\u7a0b\uff08process\uff09\u3002\u5b9e\u9645\u60c5\u51b5\u4e2d\uff0c\u4e00\u4e2aMultiprocessor Services\u7684\u4efb\u52a1\u548c\u4e00\u4e2a\u62a2\u5360\u5f0f\u7ebf\u7a0b\u662f\u4e00\u6837\u7684\uff08\u6ce8\uff1a\u6ca1\u6709\u6df1\u5165\u7684\u7528\u8fc7Carbon\uff0c\u6709\u4e0d\u59a5\u4e4b\u5904\u8fd8\u671b\u6307\u6b63\uff09\u3002<br \/>\n\u8003\u8651\u5230Carbon Thread Manager\u548cMultiprocessor Services\u7684API\u90fd\u662f\u5728Mac OS\u7cfb\u7edf\u4e0a\u7684\u9057\u7559\u6280\u672f\uff0c\u672c\u6587\u6863\u9075\u5faa\u4ee5\u4e0b\u7684\u672f\u8bed\u89c4\u8303\uff1a<br \/>\n1. \u672f\u8bed\u7ebf\u7a0b\uff08thread\uff09\u6307\u72ec\u7acb\u7684\u4ee3\u7801\u6267\u884c\u8def\u5f84\u3002<br \/>\n2. \u672f\u8bed\u8fdb\u7a0b\uff08process\uff09\u6307\u7a0b\u5e8f\u7684\u8fd0\u884c\uff0c\u8fdb\u7a0b\u53ef\u4ee5\u5305\u62ec\u591a\u4e2a\u7ebf\u7a0b\u3002<br \/>\n3. \u672f\u8bed\u4efb\u52a1\uff08task\uff09\u6307\u7684\u662f\u4e00\u4efd\u53ef\u4ee5\u88ab\u6267\u884c\u7684\u5de5\u4f5c\uff0c\u662f\u4e2a\u62bd\u8c61\u6982\u5ff5\u3002<br \/>\n3\uff09\u7ebf\u7a0b\u5907\u9009\u65b9\u6848<br \/>\n\u81ea\u5df1\u521b\u5efa\u7ebf\u7a0b\u65f6\u7684\u4e00\u4e2a\u95ee\u9898\u662f\uff1a\u5b83\u4eec\u4e3a\u4f60\u7684\u4ee3\u7801\u589e\u52a0\u4e86\u4e0d\u786e\u5b9a\u56e0\u7d20\u3002\u7ebf\u7a0b\u662f\u8ba9\u7a0b\u5e8f\u652f\u6301\u5e76\u884c\u64cd\u4f5c\u7684\u4e00\u79cd\u76f8\u5bf9\u4f4e\u5c42\u6b21\u7684\u65b9\u5f0f\uff0c\u800c\u4e14\u6bd4\u8f83\u590d\u6742\u3002\u5982\u679c\u4f60\u6ca1\u6709\u5b8c\u5168\u7406\u89e3\u81ea\u5df1\u9488\u5bf9\u591a\u7ebf\u6210\u8bbe\u8ba1\u7684\u521d\u8877\uff0c\u5c31\u5f88\u5bb9\u6613\u9047\u5230\u540c\u6b65\u6216\u65f6\u95f4\u63a7\u5236\u7684\u95ee\u9898\u3002\u8f7b\u8005\u6539\u53d8\u7a0b\u5e8f\u7684\u884c\u4e3a\uff0c\u4e25\u91cd\u7684\u4f1a\u9020\u6210\u7a0b\u5e8f\u5d29\u6e83\u6216\u662f\u5f04\u4e71\u7528\u6237\u7684\u6570\u636e\u3002<br \/>\n\u53e6\u4e00\u4e2a\u9700\u8981\u8003\u8651\u7684\u56e0\u7d20\u662f\uff1a\u4f60\u662f\u5426\u771f\u7684\u9700\u8981\u5e76\u884c\u64cd\u4f5c\uff1f\u7ebf\u7a0b\u53ef\u4ee5\u89e3\u51b3\u5728\u540c\u4e00\u8fdb\u7a0b\u4e2d\u540c\u65f6\u6267\u884c\u591a\u6bb5\u4ee3\u7801\u7684\u95ee\u9898\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e9b\u5de5\u4f5c\u5e76\u4e0d\u80fd\u4fdd\u8bc1\u88ab\u540c\u65f6\u6267\u884c\u3002\u7ebf\u7a0b\u53ef\u80fd\u5e26\u6765\u66f4\u591a\u7684\u8d1f\u8377\uff0c\u6709\u5185\u5b58\u6d88\u8017\u65b9\u9762\u7684\uff0c\u6291\u6216\u662f\u5360\u7528CPU\u65f6\u95f4\u3002\u4f60\u9700\u8981\u7814\u7a76\u662f\u5426\u503c\u5f97\u4e3a\u67d0\u4e2a\u4efb\u52a1\u627f\u62c5\u8fd9\u6837\u7684\u8d1f\u8377\uff0c\u6216\u8005\u4f7f\u7528\u5176\u4ed6\u7b80\u5355\u7684\u6267\u884c\u65b9\u5f0f\u3002<br \/>\nTable 1-1 \u5217\u51fa\u4e86\u53ef\u4f9b\u9009\u62e9\u7684\u7ebf\u7a0b\u5b9e\u73b0\u65b9\u5f0f\u3002\u8868\u4e2d\u5305\u542b\u4e86\u7ebf\u7a0b\u7684\u66ff\u4ee3\u6280\u672f\uff08\u64cd\u4f5c\u5bf9\u8c61\u2013 operation object \u548cGrand central Dispatch\uff09\uff0c\u8fd8\u5305\u542b\u4e86\u65e8\u5728\u63d0\u9ad8\u6548\u7387\u7684\u5355\u7ebf\u7a0b\u6280\u672f\u3002<br \/>\nTable 1-1 Alternative technologies to threads<br \/>\nTechnology Description<br \/>\nOperation objects\uff5c Mac OS X v10.5\u540e\u88ab\u5f15\u5165\uff0c\u4e00\u4e2a\u64cd\u4f5c\u5bf9\u8c61\u662f\u4e00\u9879\u4efb\u52a1\u7684\u5c01\u88c5\uff0c\u53ef\u4ee5\u88ab\u5b50\u7ebf\u7a0b\u4eec\u6765\u6267\u884c\u3002\u4f7f\u7528\u8fd9\u6837\u7684\u5c01\u88c5\u6280\u672f\uff0c\u53ef\u4ee5\u5ffd\u7565\u7ebf\u7a0b\u7ba1\u7406\u65b9\u9762\u7684\u9ebb\u70e6\uff0c\u4f7f\u7a0b\u5e8f\u5458\u4e13\u6ce8\u4e8e\u4efb\u52a1\u672c\u8eab\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u642d\u914d\u4f7f\u7528\u64cd\u4f5c\u961f\u5217\u5bf9\u8c61\uff08operation queue object\uff09\u6765\u4f7f\u7528\u64cd\u4f5c\u5bf9\u8c61\u3002\u64cd\u4f5c\u961f\u5217\u5bf9\u8c61\u4f1a\u7ba1\u7406\u64cd\u4f5c\u5bf9\u8c61\u5728\u591a\u7ebf\u7a0b\u4e2d\u7684\u6267\u884c\u3002\u5177\u4f53\u5185\u5bb9\u53c2\u8003Concurrency Programming Guide.<br \/>\nGrand Central Dispatch \uff5cMac OS X v10.6\u540e\u88ab\u5f15\u5165\uff0cGrand Central Dispatch\u662f\u8ba9\u6211\u4eec\u4e13\u6ce8\u4e8e\u4efb\u52a1\u672c\u8eab\u800c\u975e\u7ebf\u7a0b\u7ba1\u7406\u7684\u53e6\u5916\u7684\u9009\u62e9\u3002\u4f7f\u7528Grand Central Dispatch\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u9879\u4efb\u52a1\uff0c\u5e76\u5c06\u5176\u52a0\u5165\u5230\u4e00\u4e2a\u5de5\u4f5c\u961f\u5217\u4e2d\uff0c\u961f\u5217\u4f1a\u8d1f\u8d23\u5728\u5408\u9002\u7684\u7ebf\u7a0b\u4e2d\u6267\u884c\u4efb\u52a1\u3002\u961f\u5217\u8fd8\u4f1a\u67e5\u770b\u53ef\u7528\u5185\u6838\u7684\u6570\u91cf\u548c\u5f53\u524d\u4efb\u52a1\u8d1f\u8f7d\uff0c\u4ece\u800c\u6bd4\u81ea\u5df1\u4f7f\u7528\u7ebf\u7a0b\u66f4\u9ad8\u6548\u7684\u6267\u884c\u4efb\u52a1\u3002<br \/>\nIdle-time notifications \uff5c\u5bf9\u4e8e\u90a3\u4e9b\u76f8\u5bf9\u6765\u8bf4\u8f83\u5c0f\u7684\u3001\u4f18\u5148\u7ea7\u4f4e\u7684\u4efb\u52a1\uff0c\u201c\u7a7a\u95f2\u65f6\u95f4\u901a\u77e5\u201d\u7684\u65b9\u5f0f\u53ef\u4ee5\u8ba9\u4f60\u5728\u7a0b\u5e8f\u7a7a\u95f2\u7684\u65f6\u5019\u6267\u884c\u5b83\u4eec\u3002Cocoa\u7528NSNotificationQueue\u5bf9\u8c61\u63d0\u4f9b\u7a7a\u95f2\u65f6\u901a\u77e5\u529f\u80fd\u3002\u8981\u8bf7\u6c42\u7a7a\u95f2\u65f6\u901a\u77e5\uff0c\u5c31\u63d0\u4ea4\u901a\u77e5\u5bf9\u8c61\u5230\u9ed8\u8ba4\u7684NSNotificationQueue\uff08\u901a\u77e5\u961f\u5217\uff09\u3002\u961f\u5217\u4f1a\u5ef6\u8fdf\u63d0\u4ea4\u901a\u77e5\u5bf9\u8c61\uff0c\u76f4\u5230run loop\u7a7a\u95f2\u3002\u66f4\u591a\u4fe1\u606f\u8bf7\u67e5\u770bNotification Programming Topics.<br \/>\n\u5f85\u7eed\u3002\u3002\u3002\u6bcf\u5929\u4f1a\u6301\u7eed\u66f4\u65b0\u3002<br \/>\nAsynchronous functions \uff5c\u7cfb\u7edf\u63a5\u53e3\u5305\u62ec\u4e86\u5f88\u591a\u5f02\u6b65\u51fd\u6570\uff0c\u8fd9\u4e9b\u51fd\u6570\u672c\u8eab\u5c31\u81ea\u52a8\u652f\u6301\u5e76\u884c\u64cd\u4f5c\u3002\u5b83\u4eec\u53ef\u80fd\u4f7f\u7528\u7cfb\u7edf\u5b88\u62a4\u8fdb\u7a0b\u6765\u521b\u5efa\u81ea\u5df1\u7684\u7ebf\u7a0b\u3001\u6267\u884c\u4efb\u52a1\u5e76\u8fd4\u56de\u7ed3\u679c\uff08\u5177\u4f53\u7684\u5b9e\u73b0\u65b9\u5f0f\u5e76\u4e0d\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u548c\u4f60\u7684\u4ee3\u7801\u662f\u5206\u5f00\u7684\uff09\u3002\u5728\u8bbe\u8ba1\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u5148\u67e5\u67e5\u8fd9\u4e00\u7c7b\u652f\u6301\u5f02\u6b65\u64cd\u4f5c\u7684\u51fd\u6570\uff0c\u800c\u5c3d\u91cf\u5c11\u5728\u81ea\u5df1\u5b9a\u4e49\u7684\u7ebf\u7a0b\u4e2d\u7528\u7b49\u6548\u7684\u540c\u6b65\u51fd\u6570\u3002<br \/>\nTimers \uff5c\u5f53\u9047\u5230\u67d0\u4e9b\u9700\u8981\u5b9a\u65f6\u6267\u884c\u7684\u5c0f\u4efb\u52a1\uff0c\u800c\u4e14\u8fd9\u4e9b\u4efb\u52a1\u5e76\u6ca1\u6709\u52a8\u7528\u7ebf\u7a0b\u7684\u5fc5\u8981\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u5728\u4e3b\u7ebf\u7a0b\u4e2d\u4f7f\u7528\u5b9a\u65f6\u5668\u3002\u8be6\u7ec6\u4fe1\u606f\u8bf7\u67e5\u770b\u201cTimer Sources.\u201d<br \/>\nSeparate processes \uff5c\u5c3d\u7ba1\u8fdb\u7a0b\u76f8\u5bf9\u4e8e\u7ebf\u7a0b\u6765\u8bf4\u6709\u4e9b\u201c\u91cd\u91cf\u7ea7\u201d\uff0c\u5982\u679c\u67d0\u9879\u4efb\u52a1\u548c\u7a0b\u5e8f\u65e0\u76f4\u63a5\u5173\u7cfb\uff0c\u521b\u5efa\u72ec\u7acb\u7684\u8fdb\u7a0b\u8fd8\u662f\u6709\u5fc5\u8981\u7684\u3002\u4f8b\u5982\uff1a\u4efb\u52a1\u9700\u8981\u7533\u8bf7\u5927\u91cf\u7684\u5185\u5b58\u7a7a\u95f4\u6216\u8005\u5fc5\u987b\u4f7f\u7528root\u6743\u9650\u6267\u884c\u3002\u6211\u4eec\u8fd8\u53ef\u80fd\u9700\u8981\u4f7f\u752864\u4f4d\u7684\u670d\u52a1\u5668\u8fdb\u7a0b\u6765\u8ba1\u7b97\u5927\u6570\u636e\uff0c\u800c\u752832\u4f4d\u7684\u7a0b\u5e8f\u663e\u793a\u8fd0\u884c\u7ed3\u679c\u3002<br \/>\n4\uff09\u7ebf\u7a0b\u7684\u7cfb\u7edf\u652f\u6301<br \/>\n\u5982\u679c\u4f60\u8981\u5c06\u7ebf\u7a0b\u52a0\u5165\u5230\u73b0\u6709\u7684\u4ee3\u7801\u4e2d\u53bb\uff0cMac OS\u548ciOS\u63d0\u4f9b\u4e86\u51e0\u79cd\u521b\u5efa\u7ebf\u7a0b\u7684\u6280\u672f\u3002\u53e6\u5916\uff0c\u8fd9\u4e24\u4e2a\u7cfb\u7edf\u8fd8\u4e3a\u7ba1\u7406\u548c\u540c\u6b65\u7ebf\u7a0b\u5185\u7684\u5de5\u4f5c\u63d0\u4f9b\u4e86\u652f\u6301\u3002\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u63cf\u8ff0\u4e86\u51e0\u79cd\u5728Mac OS\u548ciOS\u4e0a\u4f7f\u7528\u7ebf\u7a0b\u7684\u5173\u952e\u6280\u672f\u3002<br \/>\nListing 2-2\u5217\u51fa\u4e86\u5728\u7a0b\u5e8f\u4e2d\u53ef\u80fd\u7528\u5230\u7684\u7ebf\u7a0b\u6280\u672f<br \/>\nTable 1-2 Thread technologies<br \/>\nTechnology<br \/>\nDescription<br \/>\nCocoa threads \uff5cCocoa\u4f7f\u7528NSThread\u7c7b\u6765\u5b9e\u73b0\u7ebf\u7a0b\u3002Cocoa\u8fd8\u4e3aNSObject\u7c7b\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\u6765\u5728\u5df2\u6709\u7ebf\u7a0b\u4e2d\u751f\u6210\u65b0\u7684\u7ebf\u7a0b\u5e76\u6267\u884c\u4ee3\u7801\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u201cUsing NSThread\u201d and \u201cUsing NSObject to Spawn a Thread.\u201d<br \/>\nPOSIX threads \uff5cPOSIX\u7ebf\u7a0b\u6280\u672f\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u57fa\u4e8eC\u7684\u63a5\u53e3\u6765\u521b\u5efa\u7ebf\u7a0b\u3002\u5982\u679c\u4f60\u4e0d\u6253\u7b97\u7f16\u5199Cocoa\u7684\u7a0b\u5e8f\uff0c\u90a3\u4e48\u5b83\u662f\u6700\u597d\u7684\u9009\u62e9\u3002POSIX\u7684\u63a5\u53e3\u76f8\u5bf9\u7b80\u5355\u6613\u7528\u4e14\u6269\u5c55\u6027\u826f\u597d\uff0c\u4fbf\u4e8e\u81ea\u5b9a\u4e49\u7ebf\u7a0b\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u201cUsing POSIX Threads\u201d<br \/>\nMultiprocessing Services \uff5cMultiprocessing Services\u662f\u8001\u5f0f\u7684C\u63a5\u53e3\u3002\u88ab\u7528\u4e8e\u652f\u6301Mac OS\u8f83\u65e9\u7684\u7248\u672c\u3002\u8fd9\u9879\u6280\u672f\u5728Mac OS X\u4e0a\u53ef\u7528\uff0c\u4f46\u5728\u65b0\u7684\u5f00\u53d1\u9879\u76ee\u4e2d\u5e94\u8be5\u907f\u514d\u4f7f\u7528\uff0c\u800c\u5e94\u4f7f\u7528NSThread\u548cPOSIX\u7684\u7ebf\u7a0b\u6280\u672f\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003Multiprocessing Services Programming Guide\u3002<br \/>\n\u4ece\u7a0b\u5e8f\u7684\u5c42\u9762\u4e0a\u6765\u770b\uff0c\u6240\u6709\u7ebf\u7a0b\u7684\u884c\u4e3a\u5728\u672c\u8d28\u4e0a\u5e94\u8be5\u662f\u4e00\u6837\u7684\u2014\u2014\u65e0\u8bba\u662f\u4efb\u4f55\u7684\u5e73\u53f0\u3002\u542f\u52a8\u7ebf\u7a0b\u540e\uff0c\u7ebf\u7a0b\u4f1a\u6709\u8fd9\u51e0\u79cd\u8fd0\u884c\u72b6\u6001\uff1a\u6b63\u5728\u8fd0\u884c\uff08running\uff09\uff0c\u51c6\u5907\u5c31\u7eea\uff08ready\uff09\u548c\u88ab\u963b\u585e\uff08blocked\uff09\u3002\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u5f53\u524d\u672a\u8fd0\u884c\uff0c\u90a3\u4e48\u5b83\u53ef\u80fd\u662f\u88ab\u963b\u585e\uff0c\u6216\u8005\u662f\u5728\u7b49\u5f85\u8f93\u5165\uff0c\u4e5f\u6709\u53ef\u80fd\u5df2\u7ecf\u5c31\u7eea\uff0c\u4f46\u672a\u88ab\u5b89\u6392\u6267\u884c\uff08scheduled\uff09\u3002\u7ebf\u7a0b\u4f1a\u5728\u8fd9\u51e0\u4e2a\u72b6\u6001\u4e4b\u95f4\u6765\u6765\u56de\u56de\u3002\u76f4\u5230\u771f\u6b63\u6267\u884c\u5b8c\u6bd5\u9000\u51fa\uff0c\u8fdb\u5165\u7ec8\u7ed3\uff08terminated\uff09\u72b6\u6001\u3002<br \/>\n\u5f53\u4f60\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7ebf\u7a0b\u65f6\uff0c\u4f60\u5fc5\u987b\u4e3a\u5176\u6307\u5b9a\u5165\u53e3\u51fd\u6570\uff08\u5728Cocoa\u4e2d\uff0c\u53eb\u5165\u53e3\u65b9\u6cd5\uff08method\uff09\uff09\u3002\u5165\u53e3\u51fd\u6570\u5305\u62ec\u4f60\u60f3\u8981\u5728\u7ebf\u7a0b\u4e2d\u6267\u884c\u7684\u4ee3\u7801\u3002\u5f53\u51fd\u6570\u8fd4\u56de\uff0c\u6216\u5f53\u4f60\u663e\u5f0f\u7684\u7ec8\u7ed3\u7ebf\u7a0b\u65f6\uff0c\u7ebf\u7a0b\u5c31\u6c38\u8fdc\u7ed3\u675f\u4e86\uff0c\u7136\u540e\u4f1a\u88ab\u7cfb\u7edf\u56de\u6536\u3002\u7ebf\u7a0b\u5728\u5185\u5b58\u548c\u65f6\u95f4\u7247\u5360\u7528\u65b9\u9762\u4ee3\u4ef7\u6602\u8d35\uff0c\u6b63\u56e0\u4e3a\u5982\u6b64\uff0c\u5efa\u8bae\u4f60\u5728\u5165\u53e3\u51fd\u6570\u4e2d\u5b8c\u6210\u5927\u91cf\u7684\u5de5\u4f5c\uff0c\u6216\u8005\u81ea\u5df1\u8bbe\u7f6e\u4e00\u4e2a\u8fd0\u884c\u56de\u8def\uff08run loop\uff09\u6765\u5faa\u73af\u6267\u884c\u5de5\u4f5c\u3002<br \/>\n\u66f4\u591a\u7ebf\u7a0b\u53ef\u7528\u6280\u672f\u7684\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u201cThread Management.\u201d<br \/>\n\u8fd0\u884c\u56de\u8def\uff08Run Loops\uff09<br \/>\n\u8fd0\u884c\u56de\u8def\u662f\u7ebf\u7a0b\u4e2d\u7ba1\u7406\u5f02\u6b65\u4e8b\u4ef6\u83b7\u53d6\u7684\u57fa\u7840\u3002\u5b83\u7684\u5de5\u4f5c\u662f\u4e3a\u7ebf\u7a0b\u76d1\u89c6\u4e8b\u4ef6\u6e90\uff08event sources\uff09\u3002\u5f53\u4e8b\u4ef6\u5230\u6765\u4e4b\u65f6\uff0c\u7cfb\u7edf\u5524\u9192\u7ebf\u7a0b\u5e76\u5c06\u4e8b\u4ef6\u53d1\u9001\u7ed9\u8fd0\u884c\u56de\u8def\uff0c\u7136\u540e\u5728\u4f20\u9012\u7ed9\u4f60\u6307\u5b9a\u7684\u5904\u7406\u8005\u3002\u5982\u679c\u6ca1\u6709\u9700\u8981\u5904\u7406\u7684\u4e8b\u4ef6\u5230\u6765\uff0c\u8fd0\u884c\u56de\u8def\u5c06\u7ebf\u7a0b\u7f6e\u4e8e\u4f11\u7720\u72b6\u6001\u3002<br \/>\n\u5728\u7ebf\u7a0b\u4e2d\u4f7f\u7528\u8fd0\u884c\u56de\u8def\u4e0d\u662f\u5fc5\u987b\u7684\u3002\u4f46\u662f\u5982\u679c\u8fd9\u6837\u505a\u7684\u8bdd\uff0c\u4f1a\u6709\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002\u4f7f\u7528\u8fd0\u884c\u56de\u8def\u53ef\u4ee5\u521b\u5efa\u957f\u671f\u5b58\u5728\u7684\u7ebf\u7a0b\uff0c\u5e76\u5c3d\u53ef\u80fd\u5c11\u7684\u5360\u7528\u8d44\u6e90\u3002\u56e0\u4e3a\u8fd0\u884c\u56de\u8def\u5728\u65e0\u4e8b\u53ef\u505a\u7684\u65f6\u5019\u8ba9\u7ebf\u7a0b\u4f11\u7720\u3002\u5b83\u51cf\u5c11\u4e86\u8f6e\u8be2\uff08polling\uff09\u7684\u9700\u8981\uff0c\u800c\u8f6e\u8be2\u4f1a\u6d6a\u8d39CPU\u5faa\u73af\u6570\uff0c\u963b\u6b62CPU\u4f11\u7720\uff0c\u4ece\u800c\u6bd4\u8f83\u8017\u7535\u3002<br \/>\n\u8981\u8bbe\u7f6e\u4e00\u4e2a\u8fd0\u884c\u56de\u8def\uff0c\u4f60\u6240\u8981\u505a\u7684\u53ea\u662f\u8fd0\u884c\u4f60\u7684\u7ebf\u7a0b\uff0c\u83b7\u5f97\u4e00\u4e2a\u8fd0\u884c\u56de\u8def\u7684\u5bf9\u8c61\uff0c\u201c\u5b89\u88c5\u201d\u4f60\u7684\u4e8b\u4ef6\u5904\u7406\u8005\uff0c\u5e76\u4e14\u544a\u8bc9\u8fd0\u884c\u56de\u8def\u53bb\u8fd0\u884c\u3002\u4e0d\u7ba1\u662fCocoa\u8fd8\u662fCarbon\u90fd\u5728\u4e3b\u7ebf\u7a0b\u4e2d\u81ea\u52a8\u4e3a\u4f60\u63d0\u4f9b\u4e86\u9ed8\u8ba4\u8fd0\u884c\u56de\u8def\u7684\u8bbe\u7f6e\u3002\u5982\u679c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u957f\u671f\u5b58\u5728\u7684\u5b50\u7ebf\u7a0b\uff0c\u5c31\u9700\u8981\u81ea\u5df1\u6765\u5728\u7ebf\u7a0b\u91cc\u5b9a\u4e49\u8fd0\u884c\u56de\u8def\u4e86\u3002<br \/>\n\u5173\u4e8e\u8fd0\u884c\u56de\u8def\u7684\u8be6\u7ec6\u4fe1\u606f\u548c\u4f8b\u5b50\uff0c\u8bf7\u53c2\u8003\u201cRun Loops.\u201d\u3002<br \/>\n\u540c\u6b65\u5de5\u5177<br \/>\n\u591a\u7ebf\u7a0b\u7f16\u7a0b\u4e2d\u7684\u4e00\u4e2a\u5927\u9ebb\u70e6\u662f\u7ebf\u7a0b\u95f4\u7684\u8d44\u6e90\u4e89\u593a\u3002\u5982\u679c\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u4fee\u6539\u4e00\u4efd\u8d44\u6e90\uff0c\u95ee\u9898\u5c31\u6765\u4e86\u3002\u51cf\u5c11\u95ee\u9898\u7684\u65b9\u6cd5\u4e4b\u4e00\u5c31\u662f\u51cf\u5c11\u5171\u4eab\u8d44\u6e90\uff0c\u4fdd\u8bc1\u6bcf\u4e2a\u7ebf\u7a0b\u90fd\u6709\u81ea\u5df1\u7684\u4e00\u4efd\u8d44\u6e90\u53ef\u4ee5\u4f7f\u7528\u3002\u5f53\u7136\uff0c\u7ba1\u7406\u5b8c\u5168\u72ec\u7acb\u7684\u8d44\u6e90\u662f\u4e0d\u53ef\u80fd\u7684\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u8981\u7528\u5230\u9501\uff08locks\uff09,\u6761\u4ef6\u63a7\u5236\uff08conditions\uff09\uff0c\u539f\u5b50\u64cd\u4f5c\uff08atomic operations\uff09\u7b49\u6280\u672f\u81ea\u5df1\u63a7\u5236\u7ebf\u7a0b\u5bf9\u8d44\u6e90\u540c\u6b65\u7684\u8bbf\u95ee\u3002<br \/>\n\u201c\u9501\u201d\u4e3a\u4ee3\u7801\u63d0\u4f9b\u4e86\u201c\u66b4\u529b\u201d\u7684\u4fdd\u62a4\u65b9\u5f0f\uff0c\u5728\u540c\u4e00\u65f6\u523b\uff0c\u4ee3\u7801\u53ea\u80fd\u88ab\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c\u3002\u5176\u4e2d\uff0c\u201c\u4e92\u65a5\u9501\u201d\u662f\u6700\u5e38\u7528\u7684\u4e00\u79cd\u5f62\u5f0f\uff0c\u4e5f\u88ab\u53eb\u505a\u4e92\u65a5\u4f53\uff08mutex\uff09\u3002\u5f53\u4e00\u4e2a\u7ebf\u7a0b\u8bd5\u56fe\u83b7\u53d6\u88ab\u5176\u4ed6\u7ebf\u7a0b\u5360\u7528\u7684\u4e92\u65a5\u4f53\u65f6\uff0c\u8be5\u7ebf\u7a0b\u4f1a\u88ab\u963b\u585e\uff0c\u76f4\u5230\u4e92\u65a5\u4f53\u88ab\u91ca\u653e\u3002\u51e0\u4e2a\u7cfb\u7edf\u6846\u67b6\u63d0\u4f9b\u5bf9\u4e92\u65a5\u4f53\u7684\u652f\u6301\uff0c\u800c\u5b83\u4eec\u90fd\u57fa\u4e8e\u540c\u6837\u7684\u5e95\u5c42\u6280\u672f\u3002Cocoa\u63d0\u4f9b\u989d\u5916\u7684\u51e0\u79cd\u4e92\u65a5\u4f53\u6765\u652f\u6301\u4e0d\u540c\u7684\u64cd\u4f5c\uff0c\u6bd4\u5982\u9012\u5f52\u64cd\u4f5c\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u201cLocks.\u201d<br \/>\n\u9664\u4e86\u9501\u4ee5\u5916\uff0c\u7cfb\u7edf\u652f\u6301\u6761\u4ef6\u63a7\u5236\u3002\u5b83\u53ef\u4ee5\u4fdd\u8bc1\u7a0b\u5e8f\u4e2d\u4efb\u52a1\u6309\u7167\u6b63\u786e\u7684\u987a\u5e8f\u6267\u884c\u3002\u6761\u4ef6\u63a7\u5236\u5c31\u50cf\u4e00\u4e2a\u201c\u95e8\u536b\u201d\uff0c\u5b83\u4f1a\u4e00\u76f4\u963b\u585e\u67d0\u4e2a\u7ebf\u7a0b\u3002\u76f4\u5230\u7279\u5b9a\u7684\u6761\u4ef6\u4e3a\u771f\uff0c\u624d\u5141\u8bb8\u7ebf\u7a0b\u7ee7\u7eed\u6267\u884c\u3002POSIX\u5c42\u548cFoundatoin\u6846\u67b6\u90fd\u76f4\u63a5\u652f\u6301\u6761\u4ef6\u63a7\u5236\u3002\uff08\u5982\u679c\u4f60\u4f7f\u7528\u64cd\u4f5c\u5bf9\u8c61\uff08operation object\uff09\uff0c\u4f60\u53ef\u4ee5\u8bbe\u7f6e\u5b83\u4eec\u4e4b\u95f4\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ece\u800c\u8d77\u5230\u8bbe\u7f6e\u4efb\u52a1\u64cd\u4f5c\u987a\u5e8f\u7684\u76ee\u7684\uff0c\u8fd9\u548c\u6761\u4ef6\u63a7\u5236\u5f88\u7c7b\u4f3c\uff09\u3002<br \/>\n\u5e76\u884c\u7a0b\u5e8f\u8bbe\u8ba1\u4e2d\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u201c\u539f\u5b50\u64cd\u4f5c\u201d\uff08atomic operation\uff09\u6765\u4fdd\u62a4\u3001\u540c\u6b65\u5bf9\u6570\u636e\u7684\u8bbf\u95ee\u3002\u539f\u5b50\u64cd\u4f5c\u63d0\u4f9b\u4e86\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u9501\u5b9a\u65b9\u6848\uff0c\u5728\u5bf9\u67d0\u4e9b\u6807\u91cf\u6570\u636e\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\u6216\u903b\u8f91\u8fd0\u7b97\u7684\u65f6\u5019\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u539f\u5b50\u64cd\u4f5c\u3002\u539f\u5b50\u64cd\u4f5c\u4f1a\u4f7f\u7528\u7279\u5b9a\u7684\u786c\u4ef6\u6307\u4ee4\u6765\u4fdd\u8bc1\u5bf9\u4e8e\u67d0\u4e2a\u53d8\u91cf\u7684\u4fee\u6539\u5b8c\u6210\u540e\u5176\u4ed6\u7684\u7ebf\u7a0b\u624d\u80fd\u7ee7\u7eed\u8bbf\u95ee\u3002<br \/>\n\u5173\u4e8e\u540c\u6b65\u5de5\u5177\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u201cSynchronization Tools.\u201d<br \/>\n\u7ebf\u7a0b\u95f4\u901a\u4fe1<br \/>\n\u867d\u7136\u597d\u7684\u8bbe\u8ba1\u4f1a\u5c3d\u53ef\u80fd\u51cf\u5c11\u7ebf\u7a0b\u95f4\u7684\u901a\u4fe1\uff0c\u4f46\u662f\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u7ebf\u7a0b\u95f4\u7684\u901a\u4fe1\u662f\u5fc5\u8981\u7684\uff08\u7ebf\u7a0b\u7684\u4efb\u52a1\u5c31\u662f\u4e3a\u7a0b\u5e8f\u5de5\u4f5c\uff0c\u4f46\u662f\u5982\u679c\u7ebf\u7a0b\u7684\u8fd0\u884c\u7ed3\u679c\u65e0\u6cd5\u88ab\u4f7f\u7528\uff0c\u4f1a\u6709\u4ec0\u4e48\u5f71\u54cd\uff1f\uff09\u7ebf\u7a0b\u53ef\u80fd\u9700\u8981\u6267\u884c\u65b0\u7684\u5de5\u4f5c\u8bf7\u6c42\u6216\u662f\u5411\u7a0b\u5e8f\u4e3b\u7ebf\u7a0b\u56de\u62a5\u5de5\u4f5c\u8fdb\u5ea6\u3002\u5728\u8fd9\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u5c31\u9700\u8981\u628a\u4e00\u4e2a\u7ebf\u7a0b\u7684\u4fe1\u606f\u4f20\u9012\u7ed9\u53e6\u5916\u4e00\u4e2a\u7ebf\u7a0b\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u7a0b\u5e8f\u4e2d\u7684\u7ebf\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u8fdb\u7a0b\u7a7a\u95f4\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u6709\u5f88\u591a\u79cd\u901a\u4fe1\u65b9\u6848\u3002<br \/>\n\u7ebf\u7a0b\u95f4\u901a\u4fe1\u6709\u5f88\u591a\u65b9\u5f0f\uff0c\u5404\u6709\u4f18\u52a3\uff0c\u201cConfiguring Thread-Local Storage\u201d \u8868\u4e2d\u7f57\u5217\u4e86\u5728Mac OS X\u4e0a\u5e38\u7528\u5230\u7684\u901a\u4fe1\u673a\u5236\uff08\u9664\u4e86\u6d88\u606f\u961f\u5217\uff08message queue\uff09\u548cCocoa\u5206\u5e03\u5f0f\u5bf9\u8c61\uff08Cocoa distributed object\uff09\u5916\uff0c\u5176\u4ed6\u4e5f\u53ef\u4ee5\u5728iOS\u4e0a\u901a\u7528\uff09\u3002\u8be6\u7ec6\u5217\u8868\u5982\u4e0b\uff1a<br \/>\nTable 1-3 Communication mechanisms<br \/>\nDirect messaging\uff5cCocoa\u7a0b\u5e8f\u652f\u6301\u76f4\u63a5\u5728\u5176\u4ed6\u7ebf\u7a0b\u4e2d\u6267\u884c\u65b9\u6cd5\uff08perform selector\uff09\u3002\u8fd9\u4e2a\u529f\u80fd\u610f\u5473\u7740\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u76f4\u63a5\u5728\u53e6\u5916\u4e00\u4e2a\u7ebf\u7a0b\u4e2d\u6267\u884c\u65b9\u6cd5\u3002\u56e0\u4e3a\u8981\u5728\u76ee\u6807\u7ebf\u7a0b\u4e2d\u6267\u884c\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\u53d1\u9001\u7684\u6d88\u606f\u4f1a\u5728\u7ebf\u7a0b\u4e2d\u88ab\u81ea\u52a8\u5e8f\u5217\u5316\u3002\u5173\u4e8einput sources\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u201cCocoa Perform Selector Sources.\u201d\uff08\u540e\u7ae0\u4f1a\u6709\u8be6\u7ec6\u8bf4\u660e\uff09\u3002<br \/>\nGlobal variables, shared memory, and objects \uff5c\u53e6\u5916\u4e00\u79cd\u901a\u4fe1\u7684\u65b9\u5f0f\u5c31\u662f\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u3001\u5171\u4eab\u5bf9\u8c61\uff0c\u6216\u662f\u5171\u4eab\u5185\u5b58\u5757\u3002\u867d\u7136\u5171\u4eab\u53d8\u91cf\u65e2\u5feb\u53c8\u7b80\u5355\uff0c\u8fd9\u79cd\u65b9\u5f0f\u76f8\u6bd4\u8f83\u76f4\u63a5\u6d88\u606f\u65b9\u5f0f\u66f4\u52a0\u8106\u5f31\u3002\u5fc5\u987b\u4f7f\u7528\u9501\u6216\u8005\u5176\u4ed6\u540c\u6b65\u673a\u5236\u6765\u201c\u4fdd\u62a4\u201d\u5171\u4eab\u53d8\u91cf\u3002\u5426\u5219\uff0c\u53ef\u80fd\u5bfc\u81f4\u7ebf\u7a0b\u95f4\u7684\u7ade\u4e89\u72b6\u6001\u3001\u6570\u636e\u88ab\u635f\u574f\uff0c\u6216\u7a0b\u5e8f\u5d29\u6e83\u3002<br \/>\nConditions\uff5c\u6761\u4ef6\u7a7a\u4e4b\u662f\u63a7\u5236\u7ebf\u7a0b\u540c\u6b65\u7684\u53e6\u4e00\u4e2a\u5de5\u5177\u3002\u53ef\u4ee5\u628a\u6761\u4ef6\u63a7\u5236\u770b\u505a\u662f\u4e00\u4e2a\u201c\u95e8\u536b\u201d\uff0c\u5b83\u53ea\u4f1a\u5728\u7279\u5b9a\u6761\u4ef6\u7b26\u5408\u7684\u65f6\u5019\u624d\u5141\u8bb8\u7ebf\u7a0b\u6267\u884c\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u201cUsing Conditions.\u201d<br \/>\nRun loop sources \uff5c\u5728\u7ebf\u7a0b\u4e2d\u52a0\u5165\u8fd0\u884c\u56de\u8def\u6e90\u53ef\u4ee5\u8ba9\u4f60\u63a5\u6536\u5230\u7a0b\u5e8f\u7684\u7279\u5b9a\u6d88\u606f\u3002\u7531\u4e8e\u8fd0\u884c\u56de\u8def\u662f\u201c\u4e8b\u4ef6\u9a71\u52a8\u201d\u7684\uff0c\u5b83\u4f1a\u5728\u65e0\u4e8b\u53ef\u505a\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u8ba9\u7ebf\u7a0b\u4f11\u7720\uff0c\u4ece\u800c\u63d0\u9ad8\u7ebf\u7a0b\u8fd0\u884c\u7684\u6548\u7387\u3002\u66f4\u591a\u5173\u4e8e\u8fd0\u884c\u56de\u8def\u548c\u8fd0\u884c\u56de\u8def\u6e90\u7684\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u201cRun Loops.\u201d<br \/>\nPorts and sockets \uff5c\u57fa\u4e8e\u7aef\u53e3\u7684\u901a\u4fe1\u662f\u4e00\u79cd\u66f4\u52a0\u590d\u6742\u7684\u65b9\u5f0f\uff0c\u4f46\u662f\u5b83\u975e\u5e38\u7a33\u5b9a\u3002\u66f4\u91cd\u8981\u7684\u662f\uff0c\u7aef\u53e3\u548c\u5957\u63a5\u5b57\u53ef\u4ee5\u88ab\u5728\u5916\u90e8\u5b9e\u4f53\u7684\u8bbf\u95ee\uff0c\u6bd4\u5982\u8bf4\u5176\u4ed6\u7684\u8fdb\u7a0b\uff08process\uff09\u548c\u670d\u52a1\uff08service\uff09\u3002\u4e3a\u4e86\u63d0\u9ad8\u6548\u7387\uff0c\u7aef\u53e3\u4f7f\u7528\u8fd0\u884c\u56de\u8def\u6e90\u534f\u52a9\u6267\u884c\uff0c\u56e0\u6b64\u7ebf\u7a0b\u5728\u7aef\u53e3\u4e0a\u65e0\u7b49\u5f85\u6570\u636e\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u4f11\u7720\u3002\u66f4\u591a\u5173\u4e8e\u8fd0\u884c\u56de\u8def\u548c\u57fa\u4e8e\u7aef\u53e3\u7684\u8f93\u5165\u6e90\uff08input source\uff09\u65b9\u9762\u7684\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u201cRun Loops.\u201d<br \/>\nMessage queues\uff5c \u591a\u8fdb\u7a0b\u7684\u670d\u52a1\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e2d\u5148\u8fdb\u5148\u51fa\uff08FIFO\uff09\u961f\u5217\u7684\u62bd\u8c61\u6a21\u578b\u6765\u7ba1\u7406\u63a5\u6536\u548c\u4f20\u51fa\u7684\u6570\u636e\u3002\u867d\u7136\u6d88\u606f\u961f\u5217\u7b80\u5355\u4e14\u65b9\u4fbf\uff0c\u4f46\u5b83\u4e0d\u50cf\u5176\u4ed6\u901a\u4fe1\u6280\u672f\u90a3\u6837\u9ad8\u6548\u3002\u5173\u4e8e\u5982\u4f55\u4f7f\u7528\u6d88\u606f\u961f\u5217\uff0c\u8bf7\u67e5\u770bMultiprocessing Services Programming Guide.<br \/>\nCocoa distributed objects\uff5c\u5206\u5e03\u5f0f\u5bf9\u8c61\u662fCocoa\u6280\u672f\u4e2d\u7684\u4e00\u9879\uff0c\u5b83\u4e3a\u57fa\u4e8e\u7aef\u53e3\u901a\u4fe1\u7684\u5b9e\u73b0\u63d0\u4f9b\u4e86\u4e00\u79cd\u9ad8\u7ea7\u7684\u65b9\u5f0f\u3002\u867d\u7136\u4e5f\u53ef\u4ee5\u628a\u5206\u5e03\u5f0f\u5bf9\u8c61\u7528\u5728\u7ebf\u7a0b\u95f4\u901a\u4fe1\u4e2d\uff0c\u4f46\u662f\u4e0d\u5efa\u8bae\u8fd9\u6837\u505a\uff0c\u56e0\u4e3a\u4f1a\u5bfc\u81f4\u5f88\u9ad8\u7684\u7cfb\u7edf\u5f00\u9500\u3002\u5206\u5e03\u5f0f\u5bf9\u8c61\u5728\u8fdb\u7a0b\u95f4\u901a\u4fe1\u4e2d\u53ef\u4ee5\u5f88\u597d\u7684\u6392\u4e0a\u7528\u573a\uff0c\u56e0\u4e3a\u8fdb\u7a0b\u95f4\u901a\u4fe1\u672c\u8eab\u5c31\u5df2\u7ecf\u6709\u8f83\u9ad8\u7684\u5f00\u9500\u4e86\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770bDistributed Objects Programming Topics.\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5173\u4e8e\u591a\u7ebf\u7a0b\u7f16\u7a0b \u591a\u5e74\u4ee5\u6765\uff0c\u8ba1\u7b97\u673a\u7684\u6027\u80fd\u5728\u5f88\u5927\u7a0b\u5ea6\u4e0a\u88ab\u5355\u6838\u5904\u7406\u5668\u7684\u901f\u5ea6\u6240\u9650\u5236\u3002\u5728\u5f53\u524d\u6280\u672f\u4e0b\uff0c\u5355\u6838\u5904\u7406\u5668\u7684\u901f &#8230; <a title=\"\u591a\u7ebf\u7a0b\u7f16\u7a0b\u6307\u5357\" class=\"read-more\" href=\"https:\/\/www.sunyuping.com\/index.php\/2012\/11\/20\/%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%bc%96%e7%a8%8b%e6%8c%87%e5%8d%97\/\" aria-label=\"\u9605\u8bfb \u591a\u7ebf\u7a0b\u7f16\u7a0b\u6307\u5357\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":0,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}