{"id":727,"date":"2022-11-23T23:06:38","date_gmt":"2022-11-23T15:06:38","guid":{"rendered":"https:\/\/niuguodong.com\/?p=727"},"modified":"2025-12-24T13:08:16","modified_gmt":"2025-12-24T05:08:16","slug":"c%e5%a4%9a%e7%ba%bf%e7%a8%8bmtx%e4%b8%8ecnd","status":"publish","type":"post","link":"https:\/\/niuguodong.com\/index.php\/2022\/11\/23\/c%e5%a4%9a%e7%ba%bf%e7%a8%8bmtx%e4%b8%8ecnd\/","title":{"rendered":"C\u591a\u7ebf\u7a0bmtx\u4e0ecnd"},"content":{"rendered":"\n<p>threads.h\u91cc\u7684cnd\u4e3a\u4ec0\u4e48\u5fc5\u987b\u8981\u914d\u5408mtx\u4e00\u8d77\u7528\uff1f\u6bd4\u5982cnd_wait()\uff0c\u4e3a\u4ec0\u4e48\u8981\u5148\u83b7\u53d6\u4fe1\u53f7\u91cf\uff0c\u7136\u540e\u518d\u7528cnd_wait()\u91ca\u653e\u4fe1\u53f7\u91cf\uff1f\u7136\u540e\u518d\u7b49\u5f85\uff1f<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u68d2\u7684\u95ee\u9898\uff0c\u5b83\u89e6\u53ca\u4e86\u6761\u4ef6\u53d8\u91cf\uff08Condition Variables\uff09\u8bbe\u8ba1\u7684\u6838\u5fc3\u539f\u56e0\u3002\u7b80\u5355\u6765\u8bf4\uff0c<strong>\u6761\u4ef6\u53d8\u91cf\u5fc5\u987b\u4e0e\u4e92\u65a5\u9501\uff08mutex\uff09\u914d\u5408\u4f7f\u7528\uff0c\u662f\u4e3a\u4e86\u907f\u514d\u4e00\u79cd\u79f0\u4e3a\u201c\u7ade\u6001\u6761\u4ef6\uff08Race Condition\uff09\u201d\u7684\u81f4\u547d\u95ee\u9898\uff0c\u5e76\u786e\u4fdd\u5bf9\u5171\u4eab\u6570\u636e\u7684\u5b89\u5168\u8bbf\u95ee\u3002<\/strong><\/p>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u5206\u6b65\u62c6\u89e3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u6761\u4ef6\u53d8\u91cf\u7684\u6838\u5fc3\u4f5c\u7528<\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u8981\u660e\u767d\u6761\u4ef6\u53d8\u91cf\uff08<code>cnd_t<\/code>\uff09\u672c\u8eab<strong>\u4e0d\u5b58\u50a8\u4efb\u4f55\u72b6\u6001\u6216\u6570\u636e<\/strong>\u3002\u5b83\u4e0d\u50cf\u4e00\u4e2a\u8ba1\u6570\u5668\u6216\u4e00\u4e2a\u6807\u5fd7\u4f4d\u3002\u5b83\u7684\u552f\u4e00\u4f5c\u7528\u5c31\u662f<strong>\u4f20\u9012\u4fe1\u53f7<\/strong>\uff0c\u8ba9\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u901a\u77e5\u5176\u4ed6\u7ebf\u7a0b\uff1a\u201c\u563f\uff0c\u67d0\u4e2a\u6761\u4ef6\u53ef\u80fd\u5df2\u7ecf\u6ee1\u8db3\u4e86\uff0c\u4f60\u4eec\u53ef\u4ee5\u9192\u6765\u68c0\u67e5\u4e00\u4e0b\u4e86\u3002\u201d<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u201c\u6761\u4ef6\u201d\u662f\u4ec0\u4e48\uff1f<\/h3>\n\n\n\n<p>\u8fd9\u4e2a\u201c\u6761\u4ef6\u201d\u901a\u5e38\u662f\u4e00\u4e2a\u57fa\u4e8e\u5171\u4eab\u6570\u636e\u7684\u5224\u65ad\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u201c\u961f\u5217\u662f\u5426\u4e3a\u7a7a\uff1f\u201d (<code>queue.empty()<\/code>)<\/li>\n\n\n\n<li>\u201c\u7f13\u51b2\u533a\u662f\u5426\u5df2\u6ee1\uff1f\u201d (<code>buffer.full()<\/code>)<\/li>\n\n\n\n<li>\u201c\u67d0\u4e2a\u4efb\u52a1\u662f\u5426\u5df2\u5b8c\u6210\uff1f\u201d (<code>task.completed<\/code>)<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u4e9b\u5171\u4eab\u6570\u636e\u5fc5\u987b\u88ab\u4fdd\u62a4\uff0c\u5426\u5219\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u5199\u4f1a\u5bfc\u81f4\u6570\u636e\u6df7\u4e71\u3002\u8fd9\u5c31\u662f\u4e92\u65a5\u9501\uff08<code>mtx_t<\/code>\uff09\u7684 job\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u4e3a\u4ec0\u4e48&nbsp;<code>cnd_wait<\/code>&nbsp;\u8981\u5148\u89e3\u9501\u518d\u7b49\u5f85\uff1f<\/h3>\n\n\n\n<p>\u8fd9\u662f\u6574\u4e2a\u8bbe\u8ba1\u4e2d\u6700\u5173\u952e\u3001\u6700\u7cbe\u5999\u7684\u90e8\u5206\u3002\u5047\u8bbe\u6211\u4eec\u6ca1\u6709\u4e92\u65a5\u9501\uff0c\u6216\u8005&nbsp;<code>cnd_wait<\/code>&nbsp;\u4e0d\u91ca\u653e\u9501\uff0c\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f<\/p>\n\n\n\n<p><strong>\u707e\u96be\u573a\u666f\uff08\u6ca1\u6709\u4e92\u65a5\u9501\u7684\u4fdd\u62a4\uff09<\/strong>\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7ebf\u7a0bA<\/strong>&nbsp;\u68c0\u67e5\u6761\u4ef6\uff0c\u53d1\u73b0\u6761\u4ef6\u4e0d\u6ee1\u8db3\uff08\u4f8b\u5982\uff0c\u961f\u5217\u662f\u7a7a\u7684\uff09\u3002<\/li>\n\n\n\n<li>\u5c31\u5728<strong>\u7ebf\u7a0bA<\/strong>\u51c6\u5907\u8c03\u7528&nbsp;<code>cnd_wait<\/code>&nbsp;<strong>\u4e4b\u524d<\/strong>\uff0c\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u8d70\u4e86\u5b83\uff0c\u8f6c\u800c\u6267\u884c<strong>\u7ebf\u7a0bB<\/strong>\u3002<\/li>\n\n\n\n<li><strong>\u7ebf\u7a0bB<\/strong>&nbsp;\u83b7\u53d6\u4e86\u6570\u636e\uff08\u4f8b\u5982\uff0c\u5411\u961f\u5217\u653e\u5165\u4e00\u4e2a\u6570\u636e\uff09\uff0c\u4fee\u6539\u4e86\u6761\u4ef6\uff08\u961f\u5217\u4e0d\u518d\u4e3a\u7a7a\uff09\uff0c\u7136\u540e\u8c03\u7528&nbsp;<code>cnd_signal<\/code>&nbsp;\u53d1\u9001\u4fe1\u53f7\u3002<\/li>\n\n\n\n<li>\u4f46\u6b64\u65f6<strong>\u7ebf\u7a0bA<\/strong>\u8fd8\u6ca1\u6709\u8fdb\u5165\u7b49\u5f85\u72b6\u6001\uff01\u6240\u4ee5\u8fd9\u4e2a\u4fe1\u53f7\u4e22\u5931\u4e86\uff08\u5c31\u50cf\u4f60\u5728\u522b\u4eba\u8fd8\u6ca1\u8fdb\u7b49\u5019\u5ba4\u4e4b\u524d\u5c31\u558a\u4e86\u4e00\u58f0\u201c\u6709\u4f60\u7684\u5feb\u9012\u201d\uff0c\u4f46\u4ed6\u6839\u672c\u6ca1\u542c\u5230\uff09\u3002<\/li>\n\n\n\n<li><strong>\u7ebf\u7a0bA<\/strong>&nbsp;\u6062\u590d\u6267\u884c\uff0c\u73b0\u5728\u5b83\u8c03\u7528&nbsp;<code>cnd_wait<\/code>&nbsp;\u5e76\u8fdb\u5165\u7b49\u5f85\u3002\u56e0\u4e3a\u5b83\u9519\u8fc7\u4e86\u4fe1\u53f7\uff0c\u5b83\u53ef\u80fd\u4f1a\u6c38\u8fdc\u7b49\u4e0b\u53bb\uff08\u6b7b\u9501\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong><code>cnd_wait<\/code>&nbsp;\u7684\u539f\u5b50\u64cd\u4f5c\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898<\/strong>\uff1a<\/p>\n\n\n\n<p><code>cnd_wait(&amp;cond, &amp;mtx)<\/code>&nbsp;\u7684\u5185\u90e8\u6267\u884c\u662f<strong>\u539f\u5b50\u6027\uff08Atomic\uff09<\/strong>&nbsp;\u7684\uff0c\u5b83\u505a\u4e86\u4e09\u4ef6\u4e8b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u89e3\u9501\u4e92\u65a5\u9501 (<code>mtx_unlock<\/code>)<\/strong>\uff1a\u91ca\u653e\u5bf9\u5171\u4eab\u6570\u636e\u7684\u9501\u5b9a\u3002<\/li>\n\n\n\n<li><strong>\u8fdb\u5165\u7b49\u5f85\u72b6\u6001<\/strong>\uff1a\u963b\u585e\u5f53\u524d\u7ebf\u7a0b\uff0c\u7b49\u5f85\u4fe1\u53f7\u3002<\/li>\n\n\n\n<li><strong>\u91cd\u65b0\u52a0\u9501 (<code>mtx_lock<\/code>)<\/strong>\uff1a\u5f53\u88ab&nbsp;<code>cnd_signal<\/code>&nbsp;\u6216&nbsp;<code>cnd_broadcast<\/code>&nbsp;\u5524\u9192\u540e\uff0c\u5728\u4ece&nbsp;<code>cnd_wait<\/code>&nbsp;\u8fd4\u56de<strong>\u4e4b\u524d<\/strong>\uff0c\u91cd\u65b0\u83b7\u53d6\u4e92\u65a5\u9501\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong>\u201c\u89e3\u9501\u201d\u548c\u201c\u7b49\u5f85\u201d\u8fd9\u4e24\u4e2a\u6b65\u9aa4\u662f\u6346\u7ed1\u5728\u4e00\u8d77\u3001\u4e0d\u53ef\u5206\u5272\u7684\uff08\u539f\u5b50\u64cd\u4f5c\uff09\u3002<\/strong>&nbsp;\u8fd9\u610f\u5473\u7740\uff0c\u4e0d\u53ef\u80fd\u51fa\u73b0\u201c\u4fe1\u53f7\u5df2\u7ecf\u53d1\u51fa\uff0c\u4f46\u7ebf\u7a0b\u8fd8\u6ca1\u5f00\u59cb\u7b49\u5f85\u201d\u7684\u7ade\u6001\u6761\u4ef6\u3002\u4fe1\u53f7\u8981\u4e48\u5728\u7b49\u5f85<strong>\u4e4b\u524d<\/strong>\u53d1\u51fa\uff08\u8fd9\u65f6\u4e92\u65a5\u9501\u8fd8\u9501\u7740\uff0c\u53d1\u9001\u4fe1\u53f7\u7684\u7ebf\u7a0b\u4f1a\u88ab\u963b\u585e\uff09\uff0c\u8981\u4e48\u5728\u7b49\u5f85<strong>\u4e4b\u540e<\/strong>\u53d1\u51fa\uff08\u8fd9\u65f6\u7ebf\u7a0b\u5df2\u7ecf\u5728\u7b49\u5f85\uff0c\u80fd\u6536\u5230\u4fe1\u53f7\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u6b63\u786e\u7684\u4f7f\u7528\u6a21\u5f0f<\/h3>\n\n\n\n<p>\u56e0\u6b64\uff0c\u4f7f\u7528\u6761\u4ef6\u53d8\u91cf\u7684\u6807\u51c6\u8303\u5f0f\uff08Pattern\uff09\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>c\/\/ \u6d88\u8d39\u8005\u7ebf\u7a0b\nmtx_lock(&amp;mtx); \/\/ 1. \u5148\u9501\u4f4f\u4e92\u65a5\u9501\uff0c\u4fdd\u62a4\u5171\u4eab\u6570\u636e\n\nwhile (condition_is_not_true) { \/\/ 2. \u68c0\u67e5\u6761\u4ef6\uff08\u5fc5\u987b\u7528\u5faa\u73af\uff0c\u4e0d\u80fd\u7528if\uff09\n    \/\/ \u6761\u4ef6\u4e0d\u6ee1\u8db3\uff0c\u7b49\u5f85\u3002cnd_wait\u4f1a\u539f\u5b50\u5730\uff1a\u89e3\u9501 -&gt; \u7b49\u5f85 -&gt; \u9192\u6765\u540e\u91cd\u65b0\u52a0\u9501\n    cnd_wait(&amp;cond, &amp;mtx);\n}\n\n\/\/ 3. \u6761\u4ef6\u6ee1\u8db3\uff0c\u5904\u7406\u6570\u636e\uff08\u4f8b\u5982\uff0c\u4ece\u961f\u5217\u53d6\u8d70\u6570\u636e\uff09\n\/\/ ... \u64cd\u4f5c\u5171\u4eab\u6570\u636e ...\n\nmtx_unlock(&amp;mtx); \/\/ 4. \u5904\u7406\u5b8c\u6570\u636e\uff0c\u91ca\u653e\u4e92\u65a5\u9501<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>c\/\/ \u751f\u4ea7\u8005\u7ebf\u7a0b\nmtx_lock(&amp;mtx); \/\/ 1. \u5148\u9501\u4f4f\u4e92\u65a5\u9501\uff0c\u4fdd\u62a4\u5171\u4eab\u6570\u636e\n\n\/\/ 2. \u4fee\u6539\u5171\u4eab\u6570\u636e\uff0c\u4f7f\u6761\u4ef6\u53d8\u4e3a\u771f\n\/\/ ... \u64cd\u4f5c\u5171\u4eab\u6570\u636e ...\n\n\/\/ 3. \u53d1\u9001\u4fe1\u53f7\uff0c\u901a\u77e5\u53ef\u80fd\u6b63\u5728\u7b49\u5f85\u7684\u6d88\u8d39\u8005\ncnd_signal(&amp;cond); \/\/ \u6216\u8005 cnd_broadcast(&amp;cond);\n\nmtx_unlock(&amp;mtx); \/\/ 4. \u91ca\u653e\u4e92\u65a5\u9501<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3\uff1a\u4e3a\u4ec0\u4e48\u5fc5\u987b\u914d\u5408\u4f7f\u7528\uff1f<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">\u7ec4\u4ef6<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u804c\u8d23<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u4e3a\u4ec0\u4e48\u9700\u8981\u5bf9\u65b9<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u4e92\u65a5\u9501 (<code>mtx_t<\/code>)<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u4fdd\u62a4\u5171\u4eab\u6570\u636e<\/strong>\u3002\u786e\u4fdd\u4efb\u4f55\u65f6\u5019\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u80fd\u4fee\u6539\u201c\u6761\u4ef6\u201d\u6240\u4f9d\u8d56\u7684\u6570\u636e\u3002<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u9700\u8981\u6761\u4ef6\u53d8\u91cf\u6765<strong>\u9ad8\u6548\u5730\u7b49\u5f85<\/strong>\u6761\u4ef6\u53d8\u5316\uff0c\u800c\u4e0d\u662f\u901a\u8fc7\u5faa\u73af\u68c0\u67e5\uff08\u5fd9\u7b49\u5f85\uff09\u6d6a\u8d39CPU\u3002<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u6761\u4ef6\u53d8\u91cf (<code>cnd_t<\/code>)<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u4f20\u9012\u4fe1\u53f7<\/strong>\u3002\u8ba9\u7ebf\u7a0b\u53ef\u4ee5\u5728\u6761\u4ef6\u4e0d\u6ee1\u8db3\u65f6<strong>\u4f11\u7720<\/strong>\uff0c\u5e76\u5728\u6761\u4ef6\u53ef\u80fd\u6539\u53d8\u65f6\u88ab<strong>\u5524\u9192<\/strong>\u3002<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u9700\u8981\u4e92\u65a5\u9501\u6765<strong>\u4fdd\u62a4\u68c0\u67e5\u6761\u4ef6\u7684\u8fc7\u7a0b<\/strong>\u548c<strong>\u4fee\u6539\u6761\u4ef6\u7684\u8fc7\u7a0b<\/strong>\uff0c\u907f\u514d\u7ade\u6001\u6761\u4ef6\uff0c\u5e76\u786e\u4fdd\u201c\u68c0\u67e5-\u7b49\u5f85\u201d\u6216\u201c\u4fee\u6539-\u53d1\u4fe1\u53f7\u201d\u7684\u539f\u5b50\u6027\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u4e00\u4e2a\u751f\u52a8\u7684\u6bd4\u55bb<\/strong>\uff1a<\/p>\n\n\n\n<p>\u628a\u5b83\u4eec\u60f3\u8c61\u6210\u4e00\u4e2a<strong>\u7b49\u5019\u5ba4<\/strong>\u548c\u4e00\u628a<strong>\u94a5\u5319<\/strong>\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5171\u4eab\u6570\u636e<\/strong>\uff1a\u7b49\u5019\u5ba4\u91cc\u7684\u4e00\u4e2a\u516c\u544a\u677f\u3002<\/li>\n\n\n\n<li><strong>\u4e92\u65a5\u9501 (<code>mtx_t<\/code>)<\/strong>\uff1a\u7b49\u5019\u5ba4\u7684<strong>\u552f\u4e00\u4e00\u628a\u94a5\u5319<\/strong>\u3002\u62ff\u5230\u94a5\u5319\u624d\u80fd\u8fdb\u53bb\u770b\/\u4fee\u6539\u516c\u544a\u677f\u3002<\/li>\n\n\n\n<li><strong>\u6761\u4ef6\u53d8\u91cf (<code>cnd_t<\/code>)<\/strong>\uff1a\u7b49\u5019\u5ba4\u91cc\u7684\u4e00\u4e2a<strong>\u94c3\u94db<\/strong>\u3002<\/li>\n\n\n\n<li><strong>\u7ebf\u7a0b<\/strong>\uff1a\u4eba\u4eec\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6d41\u7a0b<\/strong>\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4f60\u60f3\u67e5\u770b\u516c\u544a\u677f\uff08\u68c0\u67e5\u6761\u4ef6\uff09\uff0c\u5fc5\u987b\u5148\u62ff\u5230\u94a5\u5319\uff08<code>mtx_lock<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u4f60\u770b\u5230\u516c\u544a\u677f\u4e0a\u5199\u7740\u201c\u8d44\u6e90\u4e0d\u8db3\u201d\uff08\u6761\u4ef6\u4e0d\u6ee1\u8db3\uff09\u3002\u4f60\u4e0d\u80fd\u4e00\u76f4\u5360\u7740\u94a5\u5319\u5728\u90a3\u513f\u76ef\u7740\u770b\uff08\u5fd9\u7b49\u5f85\uff09\uff0c\u8fd9\u6837\u522b\u4eba\u5c31\u6ca1\u6cd5\u6539\u516c\u544a\u677f\u4e86\u3002<\/li>\n\n\n\n<li>\u4f60\u8d70\u8fdb\u7b49\u5019\u5ba4\uff0c<strong>\u628a\u94a5\u5319\u653e\u56de\u95e8\u53e3<\/strong>\uff08<code>cnd_wait<\/code>&nbsp;<strong>\u89e3\u9501<\/strong>\uff09\uff0c\u7136\u540e<strong>\u5750\u4e0b\u7761\u89c9<\/strong>\uff08<code>cnd_wait<\/code>&nbsp;<strong>\u7b49\u5f85<\/strong>\uff09\u3002\u8fd9\u4e24\u4e2a\u52a8\u4f5c\u662f\u4e00\u6c14\u5475\u6210\u7684\uff0c\u786e\u4fdd\u4e86\u4e0d\u4f1a\u6709\u4eba\u5728\u4f60\u7761\u89c9\u7684\u65f6\u5019\u8fdb\u4e0d\u6765\u3002<\/li>\n\n\n\n<li>\u53e6\u4e00\u4e2a\u4eba\u6765\u4e86\uff0c\u4ed6\u62ff\u5230\u94a5\u5319\uff08<code>mtx_lock<\/code>\uff09\uff0c\u4fee\u6539\u4e86\u516c\u544a\u677f\uff08\u201c\u8d44\u6e90\u5df2\u5c31\u7eea\u201d\uff09\uff0c\u7136\u540e<strong>\u6447\u54cd\u94c3\u94db<\/strong>\uff08<code>cnd_signal<\/code>\uff09\uff0c\u6700\u540e\u653e\u4e0b\u94a5\u5319\u79bb\u5f00\uff08<code>mtx_unlock<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u94c3\u94db\u5435\u9192\u4e86\u4f60\u3002\u4f60\u9192\u6765\u540e\u7684\u7b2c\u4e00\u4ef6\u4e8b\u5c31\u662f\u53bb<strong>\u95e8\u53e3\u62ff\u94a5\u5319<\/strong>\uff08<code>cnd_wait<\/code>&nbsp;<strong>\u91cd\u65b0\u52a0\u9501<\/strong>\uff09\uff0c\u7136\u540e\u518d\u6b21\u67e5\u770b\u516c\u544a\u677f\uff08\u91cd\u65b0\u68c0\u67e5\u6761\u4ef6\uff09\u5e76\u7ee7\u7eed\u5de5\u4f5c\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u5982\u679c\u6ca1\u6709\u8fd9\u4e2a\u201c\u653e\u4e0b\u94a5\u5319\u518d\u7761\u89c9\u201d\u548c\u201c\u9192\u6765\u5148\u62ff\u94a5\u5319\u201d\u7684\u673a\u5236\uff0c\u6574\u4e2a\u7cfb\u7edf\u5c31\u4f1a\u9677\u5165\u6df7\u4e71\u548c\u6b7b\u9501\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u6761\u4ef6\u53d8\u91cf\u5fc5\u987b\u548c\u4e92\u65a5\u9501\u914d\u5408\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>threads.h\u91cc\u7684cnd\u4e3a\u4ec0\u4e48\u5fc5\u987b\u8981\u914d\u5408mtx\u4e00\u8d77\u7528\uff1f\u6bd4\u5982cnd_wait()\uff0c\u4e3a\u4ec0\u4e48\u8981\u5148\u83b7\u53d6\u4fe1\u53f7\u91cf\uff0c\u7136\u540e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,5],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-c","category-5"],"_links":{"self":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":0,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"wp:attachment":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}