{"id":119687,"date":"2026-10-30T05:48:56","date_gmt":"2026-10-29T21:48:56","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/119687.html"},"modified":"2026-10-30T05:48:56","modified_gmt":"2026-10-29T21:48:56","slug":"linux-%e5%a4%9a%e7%ba%bf%e7%a8%8b%e6%a0%b8%e5%bf%83%e7%9f%a5%e8%af%86%e7%b2%be%e5%8d%8e%e5%85%a8%e6%80%bb%e7%bb%93%ef%bc%9a%e5%9f%ba%e7%a1%80%e6%a6%82%e5%bf%b5%e3%80%81posix-api%e3%80%81%e4%ba%92","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/119687.html","title":{"rendered":"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501"},"content":{"rendered":"<p>\u5728 Linux \u7cfb\u7edf\u7f16\u7a0b\u4e2d&#xff0c;\u591a\u7ebf\u7a0b\u662f\u5b9e\u73b0\u5e76\u53d1\u4efb\u52a1\u7684\u6838\u5fc3\u624b\u6bb5\u3002\u76f8\u6bd4\u591a\u8fdb\u7a0b&#xff0c;\u591a\u7ebf\u7a0b\u62e5\u6709\u66f4\u4f4e\u7684\u521b\u5efa\u5f00\u9500\u3001\u66f4\u9ad8\u7684\u5e76\u53d1\u6548\u7387&#xff0c;\u662f\u540e\u7aef\u5f00\u53d1\u3001\u5d4c\u5165\u5f0f\u5f00\u53d1\u7684\u5fc5\u5907\u77e5\u8bc6\u70b9\u3002\u672c\u6587\u7cfb\u7edf\u68b3\u7406 Linux \u591a\u7ebf\u7a0b\u4ece\u57fa\u7840\u6982\u5ff5\u5230\u6838\u5fc3 API\u3001\u4e92\u65a5\u540c\u6b65\u673a\u5236&#xff0c;\u518d\u5230\u6b7b\u9501\u539f\u7406\u7684\u5b8c\u6574\u77e5\u8bc6\u4f53\u7cfb&#xff0c;\u9002\u5408\u5165\u95e8\u5b66\u4e60\u4e0e\u590d\u4e60\u56de\u987e\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u7ebf\u7a0b\u57fa\u7840\u6982\u8bba<\/h3>\n<h4>1. \u4ec0\u4e48\u662f\u7ebf\u7a0b<\/h4>\n<p>Linux \u4e2d\u7ebf\u7a0b\u662f\u8f7b\u91cf\u7ea7\u8fdb\u7a0b&#xff08;LWP&#xff09;&#xff0c;\u7ebf\u7a0b\u5fc5\u987b\u96b6\u5c5e\u4e8e\u67d0\u4e00\u4e2a\u8fdb\u7a0b&#xff0c;\u4e0d\u80fd\u72ec\u7acb\u5b58\u5728\u3002<\/p>\n<ul>\n<li>\u8fdb\u7a0b&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u6700\u5c0f\u7684\u8d44\u6e90\u5206\u914d\u5355\u4f4d&#xff0c;\u62e5\u6709\u72ec\u7acb\u7684\u5730\u5740\u7a7a\u95f4\u3001\u6587\u4ef6\u63cf\u8ff0\u7b26\u7b49\u5b8c\u6574\u8d44\u6e90\u3002<\/li>\n<li>\u7ebf\u7a0b&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u6700\u5c0f\u7684\u6267\u884c\/\u8c03\u5ea6\u5355\u4f4d&#xff0c;\u662f\u8fdb\u7a0b\u5185\u90e8\u7684\u4e00\u6761\u6267\u884c\u6d41\u3002<\/li>\n<li>\u4e00\u4e2a\u8fdb\u7a0b\u5185\u9ed8\u8ba4\u5b58\u5728\u4e00\u6761\u7ebf\u7a0b&#xff0c;\u5373\u4e3b\u7ebf\u7a0b&#xff1b;\u540c\u4e00\u8fdb\u7a0b\u5185\u7684\u591a\u4e2a\u7ebf\u7a0b\u662f\u5e73\u7ea7\u5173\u7cfb\u3002<\/li>\n<\/ul>\n<h4>2. \u7ebf\u7a0b\u7684\u4f5c\u7528<\/h4>\n<p>\u5b9e\u73b0\u5e76\u53d1\u6267\u884c&#xff0c;\u9002\u5408\u5904\u7406\u76f8\u5bf9\u8017\u65f6\u7684\u4efb\u52a1&#xff08;\u5982 IO \u64cd\u4f5c\u3001\u590d\u6742\u8ba1\u7b97&#xff09;&#xff0c;\u63d0\u5347\u7a0b\u5e8f\u6267\u884c\u6548\u7387\u4e0e\u54cd\u5e94\u901f\u5ea6\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u8fdb\u7a0b vs \u7ebf\u7a0b&#xff1a;\u6838\u5fc3\u533a\u522b\u5bf9\u6bd4<\/h3>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6\u8fdb\u7a0b\u7ebf\u7a0b<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u8d44\u6e90\u5173\u7cfb<\/td>\n<td align=\"left\">\u8fdb\u7a0b\u95f4\u8d44\u6e90\u76f8\u4e92\u72ec\u7acb&#xff0c;\u4e0d\u5171\u4eab\u5730\u5740\u7a7a\u95f4<\/td>\n<td align=\"left\">\u540c\u4e00\u8fdb\u7a0b\u5185\u7684\u7ebf\u7a0b\u5171\u4eab\u5168\u5c40\u8d44\u6e90&#xff08;\u5168\u5c40\u53d8\u91cf\u3001\u5806\u3001\u6587\u4ef6\u63cf\u8ff0\u7b26\u7b49&#xff09;&#xff0c;\u4ec5\u6808\u533a\u72ec\u7acb&#xff08;\u9ed8\u8ba4 8MB&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u7a33\u5b9a\u6027<\/td>\n<td align=\"left\">\u7a33\u5b9a\u6027\u66f4\u9ad8&#xff0c;\u5355\u4e2a\u8fdb\u7a0b\u5d29\u6e83\u4e0d\u5f71\u54cd\u5176\u4ed6\u8fdb\u7a0b<\/td>\n<td align=\"left\">\u7a33\u5b9a\u6027\u5f31&#xff0c;\u5355\u4e2a\u7ebf\u7a0b\u5d29\u6e83\u4f1a\u5bfc\u81f4\u6574\u4e2a\u8fdb\u7a0b\u9000\u51fa<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u521b\u5efa\u5f00\u9500<\/td>\n<td align=\"left\">\u5f00\u9500\u5927&#xff0c;\u521b\u5efa\u65b0\u8fdb\u7a0b\u9700\u5206\u914d\u72ec\u7acb\u5730\u5740\u7a7a\u95f4&#xff08;\u7ea6 3GB&#xff09;<\/td>\n<td align=\"left\">\u5f00\u9500\u5c0f&#xff0c;\u4ec5\u9700\u5f00\u8f9f\u72ec\u7acb\u6808\u533a&#xff08;\u9ed8\u8ba4 8MB&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u5e76\u53d1\u5ea6<\/td>\n<td align=\"left\">\u5e76\u53d1\u5ea6\u8f83\u4f4e&#xff0c;\u8fdb\u7a0b\u5207\u6362\u5f00\u9500\u5927<\/td>\n<td align=\"left\">\u5e76\u53d1\u5ea6\u66f4\u9ad8&#xff0c;\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u5c0f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e09\u3001POSIX \u7ebf\u7a0b\u7f16\u7a0b\u57fa\u7840<\/h3>\n<p>Linux \u63d0\u4f9b POSIX \u7ebf\u7a0b\u5e93&#xff08;pthread&#xff09;&#xff0c;\u7f16\u7a0b\u901a\u7528\u6b65\u9aa4&#xff1a;\u521b\u5efa\u7ebf\u7a0b \u2192 \u7ebf\u7a0b\u6267\u884c\u4efb\u52a1 \u2192 \u56de\u6536\u7ebf\u7a0b\u8d44\u6e90\u3002<\/p>\n<p>\u7f16\u8bd1\u65f6\u5fc5\u987b\u94fe\u63a5\u7ebf\u7a0b\u5e93&#xff1a;<\/p>\n<p>gcc xxx.c <span class=\"token parameter variable\">-o<\/span> xxx <span class=\"token parameter variable\">-lpthread<\/span><\/p>\n<h4>1. \u67e5\u770b\u7ebf\u7a0b\u4fe1\u606f\u7684\u547d\u4ee4<\/h4>\n<p><span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-eLo<\/span> pid,ppid,lwp,stat,comm<br \/>\n<span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-eLf<\/span><\/p>\n<p>\u5176\u4e2d LWP \u5373\u4e3a\u8f7b\u91cf\u7ea7\u8fdb\u7a0b&#xff08;\u7ebf\u7a0b&#xff09;ID\u3002<\/p>\n<h4>2. \u6838\u5fc3\u7ebf\u7a0b API<\/h4>\n<h5>&#xff08;1&#xff09;\u521b\u5efa\u7ebf\u7a0b&#xff1a;pthread_create<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_t<\/span> <span class=\"token operator\">*<\/span>thread<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token class-name\">pthread_attr_t<\/span> <span class=\"token operator\">*<\/span>attr<span class=\"token punctuation\">,<\/span><br \/>\n                   <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span>start_routine<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>arg<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7ebf\u7a0b<\/li>\n<li>\u53c2\u6570&#xff1a;\n<ul>\n<li>thread&#xff1a;\u8f93\u51fa\u53c2\u6570&#xff0c;\u8fd4\u56de\u521b\u5efa\u6210\u529f\u7684\u7ebf\u7a0b ID<\/li>\n<li>attr&#xff1a;\u7ebf\u7a0b\u5c5e\u6027&#xff0c;\u4e00\u822c\u4f20 NULL \u4f7f\u7528\u9ed8\u8ba4\u5c5e\u6027<\/li>\n<li>start_routine&#xff1a;\u7ebf\u7a0b\u6267\u884c\u51fd\u6570&#xff08;\u56de\u8c03\u51fd\u6570&#xff09;&#xff0c;\u51fd\u6570\u539f\u578b\u5fc5\u987b\u4e3a void* \u51fd\u6570\u540d(void* arg)<\/li>\n<li>arg&#xff1a;\u4f20\u9012\u7ed9\u7ebf\u7a0b\u6267\u884c\u51fd\u6570\u7684\u53c2\u6570<\/li>\n<\/ul>\n<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de\u9519\u8bef\u7801<\/li>\n<\/ul>\n<h5>&#xff08;2&#xff09;\u83b7\u53d6\u5f53\u524d\u7ebf\u7a0b ID&#xff1a;pthread_self<\/h5>\n<p><span class=\"token class-name\">pthread_t<\/span> <span class=\"token function\">pthread_self<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u83b7\u53d6\u5f53\u524d\u7ebf\u7a0b\u7684\u7ebf\u7a0b ID<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u8fd4\u56de\u5f53\u524d\u7ebf\u7a0b ID&#xff0c;\u7c7b\u578b\u4e3a unsigned long int&#xff0c;\u683c\u5f0f\u5316\u8f93\u51fa\u7528 %lu<\/li>\n<\/ul>\n<h5>&#xff08;3&#xff09;\u7ebf\u7a0b\u4e3b\u52a8\u9000\u51fa&#xff1a;pthread_exit<\/h5>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">pthread_exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>retval<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u5b50\u7ebf\u7a0b\u4e3b\u52a8\u9000\u51fa&#xff0c;\u53ef\u643a\u5e26\u9000\u51fa\u72b6\u6001<\/li>\n<li>\u53c2\u6570&#xff1a;retval&#xff1a;\u7ebf\u7a0b\u9000\u51fa\u7684\u8fd4\u56de\u503c&#xff0c;\u53ef\u88ab pthread_join \u83b7\u53d6<\/li>\n<li>\u6ce8\u610f&#xff1a;\u4e0d\u8981\u7528 exit \u9000\u51fa\u7ebf\u7a0b&#xff0c;exit \u4f1a\u5bfc\u81f4\u6574\u4e2a\u8fdb\u7a0b\u9000\u51fa&#xff1b;\u7ebf\u7a0b\u5185 return \u4e5f\u53ef\u9000\u51fa\u7ebf\u7a0b&#xff0c;\u4f46\u4ec5\u80fd\u9000\u51fa\u5f53\u524d\u51fd\u6570\u5c42\u7ea7\u3002<\/li>\n<\/ul>\n<h5>&#xff08;4&#xff09;\u53d6\u6d88\u5176\u4ed6\u7ebf\u7a0b&#xff1a;pthread_cancel<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_cancel<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_t<\/span> thread<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u5411\u6307\u5b9a\u7ebf\u7a0b\u53d1\u9001\u53d6\u6d88\u8bf7\u6c42&#xff0c;\u8bf7\u6c42\u5176\u7ec8\u6b62\u6267\u884c<\/li>\n<li>\u53c2\u6570&#xff1a;thread&#xff1a;\u76ee\u6807\u7ebf\u7a0b ID<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de\u975e 0 \u9519\u8bef\u7801<\/li>\n<li>\u6ce8\u610f&#xff1a;\u8be5\u51fd\u6570\u4ec5\u53d1\u9001\u8bf7\u6c42&#xff0c;\u4e0d\u7b49\u5f85\u7ebf\u7a0b\u771f\u6b63\u7ed3\u675f&#xff1b;\u7ebf\u7a0b\u662f\u5426\u54cd\u5e94\u53d6\u6d88\u53d6\u51b3\u4e8e\u81ea\u8eab\u7684\u53d6\u6d88\u5c5e\u6027\u3002<\/li>\n<\/ul>\n<h5>&#xff08;5&#xff09;\u963b\u585e\u56de\u6536\u7ebf\u7a0b&#xff1a;pthread_join<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_join<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_t<\/span> thread<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>retval<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u963b\u585e\u7b49\u5f85\u6307\u5b9a\u7ebf\u7a0b\u7ed3\u675f&#xff0c;\u5e76\u56de\u6536\u5176\u8d44\u6e90&#xff0c;\u83b7\u53d6\u7ebf\u7a0b\u9000\u51fa\u72b6\u6001<\/li>\n<li>\u53c2\u6570&#xff1a;\n<ul>\n<li>thread&#xff1a;\u8981\u56de\u6536\u7684\u7ebf\u7a0b ID<\/li>\n<li>retval&#xff1a;\u4e8c\u7ea7\u6307\u9488&#xff0c;\u7528\u4e8e\u63a5\u6536\u7ebf\u7a0b\u9000\u51fa\u7684\u8fd4\u56de\u503c&#xff08;pthread_exit \u7684\u53c2\u6570&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de\u975e 0 \u9519\u8bef\u7801<\/li>\n<li>\u7279\u70b9&#xff1a;\u963b\u585e\u5f0f\u8c03\u7528&#xff0c;\u76ee\u6807\u7ebf\u7a0b\u672a\u7ed3\u675f\u65f6\u8c03\u7528\u7ebf\u7a0b\u4f1a\u4e00\u76f4\u7b49\u5f85\u3002<\/li>\n<\/ul>\n<h5>&#xff08;6&#xff09;\u8bbe\u7f6e\u7ebf\u7a0b\u5206\u79bb\u5c5e\u6027&#xff1a;pthread_detach<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_detach<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_t<\/span> thread<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u7ed9\u6307\u5b9a\u7ebf\u7a0b\u8bbe\u7f6e\u5206\u79bb\u5c5e\u6027&#xff1b;\u8bbe\u7f6e\u540e\u7ebf\u7a0b\u9000\u51fa\u65f6&#xff0c;\u7cfb\u7edf\u4f1a\u81ea\u52a8\u56de\u6536\u5176\u6808\u533a\u7b49\u8d44\u6e90&#xff0c;\u65e0\u9700\u4e3b\u7ebf\u7a0b\u8c03\u7528 pthread_join \u56de\u6536\u3002<\/li>\n<li>\u53c2\u6570&#xff1a;thread&#xff1a;\u76ee\u6807\u7ebf\u7a0b ID<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de\u975e 0 \u9519\u8bef\u7801<\/li>\n<li>\u6ce8\u610f&#xff1a;\u5206\u79bb\u540e\u7684\u7ebf\u7a0b\u65e0\u6cd5\u518d\u88ab join \u56de\u6536\u3002<\/li>\n<\/ul>\n<h4>3. \u5b8c\u6574\u793a\u4f8b&#xff1a;\u591a\u7ebf\u7a0b\u521b\u5efa\u4e0e\u56de\u6536<\/h4>\n<p>\u4e0b\u9762\u793a\u4f8b\u6f14\u793a\u4e3b\u7ebf\u7a0b\u521b\u5efa\u4e24\u4e2a\u5b50\u7ebf\u7a0b&#xff0c;\u5b50\u7ebf\u7a0b\u901a\u8fc7 pthread_self \u6253\u5370\u81ea\u8eab\u7ebf\u7a0b ID&#xff0c;\u5e76\u4f7f\u7528 pthread_exit \u8fd4\u56de\u9000\u51fa\u4fe1\u606f&#xff1b;\u4e3b\u7ebf\u7a0b\u901a\u8fc7 pthread_join \u963b\u585e\u56de\u6536\u5b50\u7ebf\u7a0b\u5e76\u8bfb\u53d6\u8fd4\u56de\u503c\u3002<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;pthread.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">thread_func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>arg<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> num <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>arg<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5b50\u7ebf\u7a0b %d \u542f\u52a8&#xff0c;\u7ebf\u7a0b ID&#xff1a;%lu\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n           num<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span><span class=\"token punctuation\">)<\/span><span class=\"token function\">pthread_self<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>msg <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">malloc<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">64<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>msg <span class=\"token operator\">!&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">snprintf<\/span><span class=\"token punctuation\">(<\/span>msg<span class=\"token punctuation\">,<\/span> <span class=\"token number\">64<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u7ebf\u7a0b %d \u6b63\u5e38\u9000\u51fa&#034;<\/span><span class=\"token punctuation\">,<\/span> num<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token function\">pthread_exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>msg<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/* \u4e0d\u4f1a\u6267\u884c\u5230 *\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">pthread_t<\/span> tid1<span class=\"token punctuation\">,<\/span> tid2<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> arg1 <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> arg2 <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">pthread_create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>tid1<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> thread_func<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>arg1<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;pthread_create 1&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">pthread_create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>tid2<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> thread_func<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>arg2<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;pthread_create 2&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u4e3b\u7ebf\u7a0b ID&#xff1a;%lu\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span><span class=\"token punctuation\">)<\/span><span class=\"token function\">pthread_self<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>ret1 <span class=\"token operator\">&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>ret2 <span class=\"token operator\">&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">pthread_join<\/span><span class=\"token punctuation\">(<\/span>tid1<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>ret1<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;pthread_join 1&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">pthread_join<\/span><span class=\"token punctuation\">(<\/span>tid2<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>ret2<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;pthread_join 2&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u56de\u6536\u7ed3\u679c&#xff1a;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>ret1<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u56de\u6536\u7ed3\u679c&#xff1a;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>ret2<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token function\">free<\/span><span class=\"token punctuation\">(<\/span>ret1<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">free<\/span><span class=\"token punctuation\">(<\/span>ret2<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u7f16\u8bd1\u5e76\u8fd0\u884c&#xff1a;<\/p>\n<p>gcc pthread_demo.c <span class=\"token parameter variable\">-o<\/span> pthread_demo <span class=\"token parameter variable\">-lpthread<\/span><br \/>\n.\/pthread_demo<\/p>\n<p>\u9884\u671f\u8f93\u51fa\u793a\u4f8b&#xff08;\u5b50\u7ebf\u7a0b\u6267\u884c\u987a\u5e8f\u4e0d\u56fa\u5b9a&#xff0c;\u7ebf\u7a0b ID \u6570\u503c\u56e0\u73af\u5883\u800c\u5f02&#xff09;&#xff1a;<\/p>\n<p>\u4e3b\u7ebf\u7a0b ID&#xff1a;140482621056768<br \/>\n\u5b50\u7ebf\u7a0b 1 \u542f\u52a8&#xff0c;\u7ebf\u7a0b ID&#xff1a;140482612664064<br \/>\n\u5b50\u7ebf\u7a0b 2 \u542f\u52a8&#xff0c;\u7ebf\u7a0b ID&#xff1a;140482604271360<br \/>\n\u56de\u6536\u7ed3\u679c&#xff1a;\u7ebf\u7a0b 1 \u6b63\u5e38\u9000\u51fa<br \/>\n\u56de\u6536\u7ed3\u679c&#xff1a;\u7ebf\u7a0b 2 \u6b63\u5e38\u9000\u51fa<\/p>\n<hr \/>\n<h3>\u56db\u3001\u7ebf\u7a0b\u63a7\u5236&#xff1a;\u4e92\u65a5\u9501&#xff08;Mutex&#xff09;<\/h3>\n<h4>1. \u6838\u5fc3\u6982\u5ff5<\/h4>\n<ul>\n<li>\u4e34\u754c\u8d44\u6e90&#xff1a;\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d\u4f1a\u88ab\u591a\u4e2a\u7ebf\u7a0b\u8bfb\u5199\u7684\u5171\u4eab\u8d44\u6e90&#xff0c;\u5982\u5168\u5c40\u53d8\u91cf\u3001\u6587\u4ef6\u3001\u8bbe\u5907\u3002<\/li>\n<li>\u4e92\u65a5&#xff1a;\u5bf9\u4e34\u754c\u8d44\u6e90\u7684\u6392\u4ed6\u6027\u8bbf\u95ee&#xff0c;\u540c\u4e00\u65f6\u523b\u4ec5\u5141\u8bb8\u4e00\u4e2a\u7ebf\u7a0b\u8bbf\u95ee\u4e34\u754c\u8d44\u6e90\u3002<\/li>\n<li>\u4e3a\u4ec0\u4e48\u9700\u8981\u4e92\u65a5&#xff1a;<br \/>\n\u4f8b\u5982 i&#043;&#043; \u64cd\u4f5c\u5728\u6c47\u7f16\u5c42\u9762\u81f3\u5c11\u5206\u4e3a 3 \u6b65&#xff08;\u8bfb\u53d6\u5185\u5b58\u5230\u5bc4\u5b58\u5668\u3001\u5bc4\u5b58\u5668\u81ea\u589e\u3001\u5199\u56de\u5185\u5b58&#xff09;\u3002\u7ebf\u7a0b\u8c03\u5ea6\u53ef\u80fd\u5728\u4efb\u610f\u4e00\u6b65\u53d1\u751f\u5207\u6362&#xff0c;\u82e5\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u5bf9\u540c\u4e00\u4e2a\u53d8\u91cf\u81ea\u589e&#xff0c;\u4f1a\u51fa\u73b0\u6570\u636e\u4e00\u81f4\u6027\u9519\u8bef\u3002<\/li>\n<li>\u539f\u5b50\u64cd\u4f5c&#xff1a;\u4e00\u6b21\u8c03\u5ea6\u5185\u5fc5\u987b\u5b8c\u6574\u6267\u884c\u5b8c\u6bd5\u3001\u4e0d\u53ef\u88ab\u6253\u65ad\u7684\u4ee3\u7801\u6bb5&#xff1b;\u4e92\u65a5\u9501\u53ef\u4ee5\u5c06\u4e34\u754c\u533a\u4ee3\u7801\u53d8\u4e3a\u539f\u5b50\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<h4>2. \u4e92\u65a5\u9501\u4f7f\u7528\u6b65\u9aa4<\/h4>\n<p>\u5b9a\u4e49\u4e92\u65a5\u9501 \u2192 \u521d\u59cb\u5316\u9501 \u2192 \u8bbf\u95ee\u4e34\u754c\u8d44\u6e90\u524d\u52a0\u9501 \u2192 \u8bbf\u95ee\u7ed3\u675f\u89e3\u9501 \u2192 \u7a0b\u5e8f\u7ed3\u675f\u9500\u6bc1\u9501<\/p>\n<h5>&#xff08;1&#xff09;\u5b9a\u4e49\u4e92\u65a5\u9501<\/h5>\n<p><span class=\"token class-name\">pthread_mutex_t<\/span> mutex<span class=\"token punctuation\">;<\/span><\/p>\n<h5>&#xff08;2&#xff09;\u521d\u59cb\u5316\u4e92\u65a5\u9501<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_mutex_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_mutex_t<\/span> <span class=\"token operator\">*<\/span>mutex<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token class-name\">pthread_mutexattr_t<\/span> <span class=\"token operator\">*<\/span>attr<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u53c2\u6570&#xff1a;mutex&#xff1a;\u4e92\u65a5\u9501\u5730\u5740&#xff1b;attr&#xff1a;\u9501\u5c5e\u6027&#xff0c;\u4e00\u822c\u4f20 NULL \u7528\u9ed8\u8ba4\u5c5e\u6027<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de\u975e 0<\/li>\n<\/ul>\n<h5>&#xff08;3&#xff09;\u52a0\u9501<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_mutex_lock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_mutex_t<\/span> <span class=\"token operator\">*<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u5bf9\u4e34\u754c\u533a\u52a0\u9501&#xff0c;\u52a0\u9501\u540e\u5176\u4ed6\u7ebf\u7a0b\u5c1d\u8bd5\u52a0\u9501\u4f1a\u963b\u585e<\/li>\n<li>\u6ce8\u610f&#xff1a;\u52a0\u9501\u5230\u89e3\u9501\u4e4b\u95f4\u7684\u4ee3\u7801\u4e3a\u4e34\u754c\u533a&#xff0c;\u5e94\u5c3d\u91cf\u77ed\u5c0f&#xff0c;\u4e0d\u8981\u5305\u542b\u4f11\u7720\u3001\u5927\u8017\u65f6\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<h5>&#xff08;4&#xff09;\u89e3\u9501<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_mutex_unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_mutex_t<\/span> <span class=\"token operator\">*<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u91ca\u653e\u4e92\u65a5\u9501&#xff0c;\u5176\u4ed6\u963b\u585e\u7684\u7ebf\u7a0b\u53ef\u4ee5\u7ade\u4e89\u83b7\u53d6\u9501<\/li>\n<\/ul>\n<h5>&#xff08;5&#xff09;\u9500\u6bc1\u4e92\u65a5\u9501<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">pthread_mutex_destroy<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">pthread_mutex_t<\/span> <span class=\"token operator\">*<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u4f7f\u7528\u5b8c\u6bd5\u540e\u9500\u6bc1\u4e92\u65a5\u9501&#xff0c;\u91ca\u653e\u8d44\u6e90<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e94\u3001\u7ebf\u7a0b\u63a7\u5236&#xff1a;\u540c\u6b65\u4e0e\u4fe1\u53f7\u91cf<\/h3>\n<h4>1. \u6838\u5fc3\u6982\u5ff5<\/h4>\n<ul>\n<li>\u540c\u6b65&#xff1a;\u5728\u4e92\u65a5\u7684\u57fa\u7840\u4e0a&#xff0c;\u8ba9\u591a\u4e2a\u7ebf\u7a0b\u6309\u7167\u6307\u5b9a\u7684\u5148\u540e\u987a\u5e8f\u8bbf\u95ee\u4e34\u754c\u8d44\u6e90&#xff0c;\u662f\u4e92\u65a5\u7684\u4e00\u79cd\u7279\u4f8b\u3002<\/li>\n<li>\u4e92\u65a5 vs \u540c\u6b65&#xff1a;\n<ul>\n<li>\u4e92\u65a5\u9501&#xff1a;\u52a0\u9501\u548c\u89e3\u9501\u5728\u540c\u4e00\u4e2a\u7ebf\u7a0b\u5185\u5b8c\u6210&#xff0c;\u4fdd\u8bc1\u8d44\u6e90\u6392\u4ed6\u8bbf\u95ee\u3002<\/li>\n<li>\u4fe1\u53f7\u91cf&#xff08;\u540c\u6b65&#xff09;&#xff1a;PV \u64cd\u4f5c\u7531\u4e0d\u540c\u7ebf\u7a0b\u4ea4\u53c9\u6267\u884c&#xff08;\u7ebf\u7a0b A \u91ca\u653e\u3001\u7ebf\u7a0b B \u7533\u8bf7&#xff09;&#xff0c;\u4fdd\u8bc1\u6267\u884c\u987a\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>2. \u4fe1\u53f7\u91cf\u57fa\u7840<\/h4>\n<p>Linux \u63d0\u4f9b\u65e0\u540d\u4fe1\u53f7\u91cf\u7528\u4e8e\u7ebf\u7a0b\u95f4\u540c\u6b65&#xff0c;\u5e38\u7528\u4e8c\u503c\u4fe1\u53f7\u91cf&#xff08;\u503c\u53ea\u80fd\u4e3a 0 \u6216 1&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\u503c\u4e3a 0&#xff1a;\u7ea2\u706f&#xff0c;\u7ebf\u7a0b\u8c03\u7528\u7533\u8bf7\u64cd\u4f5c\u4f1a\u963b\u585e<\/li>\n<li>\u503c\u4e3a 1&#xff1a;\u7eff\u706f&#xff0c;\u7ebf\u7a0b\u53ef\u7533\u8bf7\u8d44\u6e90&#xff0c;\u7533\u8bf7\u540e\u503c\u81ea\u52a8\u51cf 1<\/li>\n<\/ul>\n<p>\u8ba1\u6570\u4fe1\u53f7\u91cf\u521d\u59cb\u503c\u53ef\u5927\u4e8e 1&#xff0c;\u9002\u7528\u4e8e\u591a\u4efd\u76f8\u540c\u8d44\u6e90\u7684\u5e76\u53d1\u8bbf\u95ee\u573a\u666f\u3002<\/p>\n<h4>3. \u4fe1\u53f7\u91cf\u4f7f\u7528\u6b65\u9aa4<\/h4>\n<p>\u5b9a\u4e49\u4fe1\u53f7\u91cf \u2192 \u521d\u59cb\u5316\u4fe1\u53f7\u91cf \u2192 PV \u64cd\u4f5c&#xff08;\u7533\u8bf7\/\u91ca\u653e&#xff09; \u2192 \u9500\u6bc1\u4fe1\u53f7\u91cf<\/p>\n<h5>&#xff08;1&#xff09;\u5b9a\u4e49\u4fe1\u53f7\u91cf<\/h5>\n<p><span class=\"token class-name\">sem_t<\/span> sem<span class=\"token punctuation\">;<\/span><\/p>\n<h5>&#xff08;2&#xff09;\u521d\u59cb\u5316\u4fe1\u53f7\u91cf<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">sem_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">sem_t<\/span> <span class=\"token operator\">*<\/span>sem<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> pshared<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">int<\/span> value<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u53c2\u6570&#xff1a;\n<ul>\n<li>sem&#xff1a;\u4fe1\u53f7\u91cf\u5730\u5740<\/li>\n<li>pshared&#xff1a;0 \u8868\u793a\u7ebf\u7a0b\u95f4\u4f7f\u7528&#xff1b;\u975e 0 \u8868\u793a\u8fdb\u7a0b\u95f4\u4f7f\u7528<\/li>\n<li>value&#xff1a;\u4fe1\u53f7\u91cf\u521d\u59cb\u503c<\/li>\n<\/ul>\n<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de -1<\/li>\n<\/ul>\n<h5>&#xff08;3&#xff09;P \u64cd\u4f5c&#xff08;\u7533\u8bf7\u8d44\u6e90&#xff09;&#xff1a;sem_wait<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">sem_wait<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">sem_t<\/span> <span class=\"token operator\">*<\/span>sem<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u7533\u8bf7\u8d44\u6e90\u3002\u82e5\u4fe1\u53f7\u91cf\u503c &gt; 0&#xff0c;\u5219\u503c\u51cf 1&#xff0c;\u7a0b\u5e8f\u7ee7\u7eed&#xff1b;\u82e5\u503c\u4e3a 0&#xff0c;\u5219\u7ebf\u7a0b\u963b\u585e&#xff0c;\u76f4\u5230\u6709\u8d44\u6e90\u91ca\u653e\u3002<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de -1<\/li>\n<\/ul>\n<h5>&#xff08;4&#xff09;V \u64cd\u4f5c&#xff08;\u91ca\u653e\u8d44\u6e90&#xff09;&#xff1a;sem_post<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">sem_post<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">sem_t<\/span> <span class=\"token operator\">*<\/span>sem<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u91ca\u653e\u8d44\u6e90&#xff0c;\u4fe1\u53f7\u91cf\u503c\u81ea\u52a8\u52a0 1&#xff0c;\u4e0d\u4f1a\u963b\u585e\u8c03\u7528\u7ebf\u7a0b<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de -1<\/li>\n<\/ul>\n<h5>&#xff08;5&#xff09;\u9500\u6bc1\u4fe1\u53f7\u91cf<\/h5>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">sem_destroy<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">sem_t<\/span> <span class=\"token operator\">*<\/span>sem<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u9500\u6bc1\u4fe1\u53f7\u91cf&#xff0c;\u91ca\u653e\u8d44\u6e90<\/li>\n<\/ul>\n<p>\u8865\u5145&#xff1a;\u4fe1\u53f7\u91cf\u4fdd\u62a4\u7684\u4e34\u754c\u533a\u5185\u53ef\u5305\u542b\u77ed\u8017\u65f6\u3001\u8f7b\u5ea6\u4f11\u7720\u64cd\u4f5c&#xff1b;\u4f46\u4e92\u65a5\u9501\u4e34\u754c\u533a\u5fc5\u987b\u5c3d\u91cf\u7cbe\u7b80&#xff0c;\u7981\u6b62\u957f\u65f6\u95f4\u4f11\u7720\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001\u6b7b\u9501<\/h3>\n<h4>1. \u4ec0\u4e48\u662f\u6b7b\u9501<\/h4>\n<p>\u7531\u4e8e\u9501\u8d44\u6e90\u7533\u8bf7\u4e0e\u91ca\u653e\u903b\u8f91\u4e0d\u5408\u7406&#xff0c;\u5bfc\u81f4\u591a\u4e2a\u7ebf\u7a0b\/\u8fdb\u7a0b\u76f8\u4e92\u7b49\u5f85\u5bf9\u65b9\u6301\u6709\u7684\u8d44\u6e90&#xff0c;\u4ece\u800c\u90fd\u65e0\u6cd5\u7ee7\u7eed\u5411\u524d\u6267\u884c\u7684\u73b0\u8c61\u3002<\/p>\n<h4>2. \u6b7b\u9501\u4ea7\u751f\u7684\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6<\/h4>\n<li>\u4e92\u65a5\u6761\u4ef6&#xff1a;\u4e00\u4e2a\u8d44\u6e90\u540c\u4e00\u65f6\u95f4\u53ea\u80fd\u88ab\u4e00\u4e2a\u6267\u884c\u6d41\u5360\u7528\u3002<\/li>\n<li>\u8bf7\u6c42\u4e0e\u4fdd\u6301\u6761\u4ef6&#xff1a;\u6267\u884c\u6d41\u56e0\u7533\u8bf7\u65b0\u8d44\u6e90\u963b\u585e\u65f6&#xff0c;\u4e0d\u91ca\u653e\u5df2\u7ecf\u6301\u6709\u7684\u8d44\u6e90\u3002<\/li>\n<li>\u4e0d\u5265\u593a\u6761\u4ef6&#xff1a;\u6267\u884c\u6d41\u5df2\u83b7\u5f97\u7684\u8d44\u6e90&#xff0c;\u5728\u4f7f\u7528\u5b8c\u6bd5\u524d\u4e0d\u80fd\u88ab\u5f3a\u884c\u5265\u593a&#xff0c;\u53ea\u80fd\u4e3b\u52a8\u91ca\u653e\u3002<\/li>\n<li>\u5faa\u73af\u7b49\u5f85\u6761\u4ef6&#xff1a;\u591a\u4e2a\u6267\u884c\u6d41\u4e4b\u95f4\u5f62\u6210\u5934\u5c3e\u76f8\u63a5\u7684\u5faa\u73af\u7b49\u5f85\u8d44\u6e90\u7684\u94fe\u8def\u3002<\/li>\n<p>\u56db\u4e2a\u6761\u4ef6\u540c\u65f6\u6ee1\u8db3\u624d\u4f1a\u4ea7\u751f\u6b7b\u9501&#xff1b;\u9884\u9632\u6b7b\u9501\u53ea\u9700\u7834\u574f\u5176\u4e2d\u4efb\u610f\u4e00\u4e2a\u6761\u4ef6\u5373\u53ef\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u603b\u7ed3<\/h3>\n<p>Linux \u591a\u7ebf\u7a0b\u7f16\u7a0b\u7684\u6838\u5fc3\u8109\u7edc\u662f&#xff1a;<\/p>\n<li>\u7406\u89e3\u7ebf\u7a0b\u672c\u8d28\u662f\u8f7b\u91cf\u7ea7\u8fdb\u7a0b&#xff0c;\u5171\u4eab\u8fdb\u7a0b\u8d44\u6e90\u3001\u4ec5\u6808\u72ec\u7acb&#xff1b;<\/li>\n<li>\u638c\u63e1 pthread \u5e93\u7684\u521b\u5efa\u3001\u9000\u51fa\u3001\u56de\u6536\u3001\u5206\u79bb\u6838\u5fc3 API&#xff1b;<\/li>\n<li>\u638c\u63e1\u4e92\u65a5\u9501\u4fdd\u62a4\u4e34\u754c\u8d44\u6e90&#xff0c;\u7406\u89e3\u52a0\u9501\u3001\u89e3\u9501\u3001\u9500\u6bc1\u7684\u5b8c\u6574\u6d41\u7a0b&#xff1b;<\/li>\n<li>\u638c\u63e1\u4fe1\u53f7\u91cf\u5b9e\u73b0\u7ebf\u7a0b\u540c\u6b65&#xff0c;\u7406\u89e3 PV \u64cd\u4f5c\u4e0e\u4e8c\u503c\u4fe1\u53f7\u91cf&#xff1b;<\/li>\n<li>\u7406\u89e3\u6b7b\u9501\u4ea7\u751f\u7684\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6&#xff0c;\u5e76\u80fd\u901a\u8fc7\u7834\u574f\u4efb\u4e00\u6761\u4ef6\u6765\u9884\u9632\u6b7b\u9501\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Linux \u7cfb\u7edf\u7f16\u7a0b\u4e2d&#xff0c;\u591a\u7ebf\u7a0b\u662f\u5b9e\u73b0\u5e76\u53d1\u4efb\u52a1\u7684\u6838\u5fc3\u624b\u6bb5\u3002\u76f8\u6bd4\u591a\u8fdb\u7a0b&#xff0c;\u591a\u7ebf\u7a0b\u62e5\u6709\u66f4\u4f4e\u7684\u521b\u5efa\u5f00\u9500\u3001\u66f4\u9ad8\u7684\u5e76\u53d1\u6548\u7387&#xff0c;\u662f\u540e\u7aef\u5f00\u53d1\u3001\u5d4c\u5165\u5f0f\u5f00\u53d1\u7684\u5fc5\u5907\u77e5\u8bc6\u70b9\u3002\u672c\u6587\u7cfb\u7edf\u68b3\u7406 Linux \u591a\u7ebf\u7a0b\u4ece\u57fa\u7840\u6982\u5ff5\u5230\u6838\u5fc3 API\u3001\u4e92\u65a5\u540c\u6b65\u673a\u5236&#xff0c;\u518d\u5230\u6b7b\u9501\u539f\u7406\u7684\u5b8c\u6574\u77e5\u8bc6\u4f53\u7cfb&#xff0c;\u9002\u5408\u5165\u95e8\u5b66\u4e60\u4e0e\u590d\u4e60\u56de\u987e\u3002\u4e00\u3001\u7ebf\u7a0b\u57fa\u7840\u6982\u8bba<br \/>\n1. \u4ec0\u4e48\u662f\u7ebf\u7a0b<br \/>\nLinux \u4e2d\u7ebf\u7a0b\u662f\u8f7b\u91cf\u7ea7\u8fdb\u7a0b&#xff08;LWP&#xff09;&#xff0c;\u7ebf\u7a0b\u5fc5\u987b\u96b6\u5c5e\u4e8e\u67d0<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[174,58,190,1813],"topic":[],"class_list":["post-119687","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-linux","tag-190","tag-1813"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/119687.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5728 Linux \u7cfb\u7edf\u7f16\u7a0b\u4e2d&#xff0c;\u591a\u7ebf\u7a0b\u662f\u5b9e\u73b0\u5e76\u53d1\u4efb\u52a1\u7684\u6838\u5fc3\u624b\u6bb5\u3002\u76f8\u6bd4\u591a\u8fdb\u7a0b&#xff0c;\u591a\u7ebf\u7a0b\u62e5\u6709\u66f4\u4f4e\u7684\u521b\u5efa\u5f00\u9500\u3001\u66f4\u9ad8\u7684\u5e76\u53d1\u6548\u7387&#xff0c;\u662f\u540e\u7aef\u5f00\u53d1\u3001\u5d4c\u5165\u5f0f\u5f00\u53d1\u7684\u5fc5\u5907\u77e5\u8bc6\u70b9\u3002\u672c\u6587\u7cfb\u7edf\u68b3\u7406 Linux \u591a\u7ebf\u7a0b\u4ece\u57fa\u7840\u6982\u5ff5\u5230\u6838\u5fc3 API\u3001\u4e92\u65a5\u540c\u6b65\u673a\u5236&#xff0c;\u518d\u5230\u6b7b\u9501\u539f\u7406\u7684\u5b8c\u6574\u77e5\u8bc6\u4f53\u7cfb&#xff0c;\u9002\u5408\u5165\u95e8\u5b66\u4e60\u4e0e\u590d\u4e60\u56de\u987e\u3002\u4e00\u3001\u7ebf\u7a0b\u57fa\u7840\u6982\u8bba 1. \u4ec0\u4e48\u662f\u7ebf\u7a0b Linux \u4e2d\u7ebf\u7a0b\u662f\u8f7b\u91cf\u7ea7\u8fdb\u7a0b&#xff08;LWP&#xff09;&#xff0c;\u7ebf\u7a0b\u5fc5\u987b\u96b6\u5c5e\u4e8e\u67d0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/119687.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-29T21:48:56+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119687.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/119687.html\",\"name\":\"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-29T21:48:56+00:00\",\"dateModified\":\"2026-10-29T21:48:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/119687.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/119687.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119687.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/119687.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5728 Linux \u7cfb\u7edf\u7f16\u7a0b\u4e2d&#xff0c;\u591a\u7ebf\u7a0b\u662f\u5b9e\u73b0\u5e76\u53d1\u4efb\u52a1\u7684\u6838\u5fc3\u624b\u6bb5\u3002\u76f8\u6bd4\u591a\u8fdb\u7a0b&#xff0c;\u591a\u7ebf\u7a0b\u62e5\u6709\u66f4\u4f4e\u7684\u521b\u5efa\u5f00\u9500\u3001\u66f4\u9ad8\u7684\u5e76\u53d1\u6548\u7387&#xff0c;\u662f\u540e\u7aef\u5f00\u53d1\u3001\u5d4c\u5165\u5f0f\u5f00\u53d1\u7684\u5fc5\u5907\u77e5\u8bc6\u70b9\u3002\u672c\u6587\u7cfb\u7edf\u68b3\u7406 Linux \u591a\u7ebf\u7a0b\u4ece\u57fa\u7840\u6982\u5ff5\u5230\u6838\u5fc3 API\u3001\u4e92\u65a5\u540c\u6b65\u673a\u5236&#xff0c;\u518d\u5230\u6b7b\u9501\u539f\u7406\u7684\u5b8c\u6574\u77e5\u8bc6\u4f53\u7cfb&#xff0c;\u9002\u5408\u5165\u95e8\u5b66\u4e60\u4e0e\u590d\u4e60\u56de\u987e\u3002\u4e00\u3001\u7ebf\u7a0b\u57fa\u7840\u6982\u8bba 1. \u4ec0\u4e48\u662f\u7ebf\u7a0b Linux \u4e2d\u7ebf\u7a0b\u662f\u8f7b\u91cf\u7ea7\u8fdb\u7a0b&#xff08;LWP&#xff09;&#xff0c;\u7ebf\u7a0b\u5fc5\u987b\u96b6\u5c5e\u4e8e\u67d0","og_url":"https:\/\/www.wsisp.com\/helps\/119687.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-29T21:48:56+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/119687.html","url":"https:\/\/www.wsisp.com\/helps\/119687.html","name":"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-29T21:48:56+00:00","dateModified":"2026-10-29T21:48:56+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/119687.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/119687.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/119687.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u591a\u7ebf\u7a0b\u6838\u5fc3\u77e5\u8bc6\u7cbe\u534e\u5168\u603b\u7ed3\uff1a\u57fa\u7840\u6982\u5ff5\u3001POSIX API\u3001\u4e92\u65a5\u540c\u6b65\u4e0e\u6b7b\u9501"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=119687"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119687\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=119687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=119687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=119687"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=119687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}