{"id":118370,"date":"2026-10-27T02:16:51","date_gmt":"2026-10-26T18:16:51","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/118370.html"},"modified":"2026-10-27T02:16:51","modified_gmt":"2026-10-26T18:16:51","slug":"linux-%e7%ba%bf%e7%a8%8b%e4%ba%92%e6%96%a5","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/118370.html","title":{"rendered":"Linux \u7ebf\u7a0b\u4e92\u65a5"},"content":{"rendered":"<h2>\u7ebf\u7a0b\u540c\u6b65\u4e0e\u4e92\u65a5\u603b\u7ed3<\/h2>\n<h3><\/h3>\n<p>\u672c\u7ae0\u4e3b\u7ebf\u662f\u201c\u5148\u4e92\u65a5&#xff0c;\u518d\u540c\u6b65\u201d&#xff1a;<\/p>\n<table>\n<tr>\u90e8\u5206\u89e3\u51b3\u7684\u95ee\u9898\u624b\u6bb5<\/tr>\n<tbody>\n<tr>\n<td>1. \u7ebf\u7a0b\u4e92\u65a5&#xff08;\u672c\u8282&#xff09;<\/td>\n<td>\u540c\u4e00\u65f6\u523b\u53ea\u80fd\u6709\u4e00\u4e2a\u6267\u884c\u6d41\u8fdb\u5165\u4e34\u754c\u533a<\/td>\n<td>\u4e92\u65a5\u91cf pthread_mutex_t<\/td>\n<\/tr>\n<tr>\n<td>2. \u7ebf\u7a0b\u540c\u6b65&#xff08;\u540e\u7eed&#xff09;<\/td>\n<td>\u6309\u7279\u5b9a\u987a\u5e8f\u8bbf\u95ee&#xff0c;\u907f\u514d\u9965\u997f<\/td>\n<td>\u6761\u4ef6\u53d8\u91cf\u3001\u4fe1\u53f7\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8bfe\u4ef6\u672c\u8282\u56db\u4e2a\u76ee\u6807&#xff1a;1-1 \u80cc\u666f\u6982\u5ff5 \u2192 1-2 \u4e92\u65a5\u91cf mutex \u2192 1-3 \u5b9e\u73b0\u539f\u7406 \u2192 1-4 \u5c01\u88c5\u3002<\/p>\n<h3>1. \u4e94\u4e2a\u80cc\u666f\u6982\u5ff5<\/h3>\n<table>\n<tr>\u6982\u5ff5\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>\u5171\u4eab\u8d44\u6e90<\/td>\n<td>\u591a\u4e2a\u7ebf\u7a0b\u90fd\u80fd\u8bbf\u95ee\u7684\u8d44\u6e90<\/td>\n<\/tr>\n<tr>\n<td>\u4e34\u754c\u8d44\u6e90<\/td>\n<td>\u591a\u7ebf\u7a0b\u6267\u884c\u6d41\u4e2d\u88ab\u4fdd\u62a4\u7684\u5171\u4eab\u8d44\u6e90<\/td>\n<\/tr>\n<tr>\n<td>\u4e34\u754c\u533a<\/td>\n<td>\u6bcf\u4e2a\u7ebf\u7a0b\u5185\u90e8\u8bbf\u95ee\u4e34\u754c\u8d44\u6e90\u7684\u90a3\u6bb5\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td>\u4e92\u65a5<\/td>\n<td>\u4efb\u4f55\u65f6\u523b\u4fdd\u8bc1\u6709\u4e14\u53ea\u6709\u4e00\u4e2a\u6267\u884c\u6d41\u8fdb\u5165\u4e34\u754c\u533a\u3001\u8bbf\u95ee\u4e34\u754c\u8d44\u6e90&#xff0c;\u901a\u5e38\u5bf9\u4e34\u754c\u8d44\u6e90\u8d77\u4fdd\u62a4\u4f5c\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u539f\u5b50\u6027<\/td>\n<td>\u4e0d\u4f1a\u88ab\u4efb\u4f55\u8c03\u5ea6\u673a\u5236\u6253\u65ad\u7684\u64cd\u4f5c&#xff1b;\u53ea\u6709\u4e24\u6001&#xff1a;\u8981\u4e48\u5b8c\u6210&#xff0c;\u8981\u4e48\u672a\u5b8c\u6210&#xff08;\u5982\u4f55\u5b9e\u73b0\u7559\u5f85 1-3 \u8ba8\u8bba&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2. \u4e3a\u4ec0\u4e48\u9700\u8981\u4e92\u65a5&#xff1a;\u552e\u7968\u7cfb\u7edf\u53cd\u4f8b<\/h3>\n<p>ticket &#061; 100 \u5168\u5c40\u53d8\u91cf&#xff0c;4 \u4e2a\u7ebf\u7a0b\u5404\u81ea while(1)&#xff1a;<\/p>\n<p><span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>ticket <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">usleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                       <span class=\"token comment\">\/\/ \u6a21\u62df\u6f2b\u957f\u7684\u4e1a\u52a1\u8fc7\u7a0b<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%s sells ticket:%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> id<span class=\"token punctuation\">,<\/span> ticket<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        ticket<span class=\"token operator\">&#8212;<\/span><span class=\"token punctuation\">;<\/span>                           <span class=\"token comment\">\/\/ \u975e\u539f\u5b50<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4e00\u6b21\u771f\u5b9e\u8fd0\u884c\u7ed3\u679c&#xff1a;thread 4 \u5356\u5230 1&#xff0c;thread 2 \u5356 0&#xff0c;thread 1 \u5356 -1&#xff0c;thread 3 \u5356 -2 \u2014\u2014 \u65e2\u91cd\u590d\u8d85\u5356\u53c8\u5356\u51fa\u8d1f\u6570\u7968\u3002<\/p>\n<p>\u539f\u56e0\u9010\u6761\u62c6\u89e3\u5982\u4e0b&#xff1a;<\/p>\n<li>if \u8bed\u53e5\u5224\u65ad\u6761\u4ef6\u4e3a\u771f\u4e4b\u540e&#xff0c;\u4ee3\u7801\u53ef\u4ee5\u5e76\u53d1\u7684\u5207\u6362\u5230\u5176\u4ed6\u7ebf\u7a0b&#xff08;\u5224\u65ad\u4e0e\u4fee\u6539\u4e4b\u95f4\u7559\u51fa\u4e86\u7a7a\u6863&#xff09;&#xff1b;<\/li>\n<li>usleep \u6a21\u62df\u7684\u6f2b\u957f\u4e1a\u52a1\u8fc7\u7a0b\u4e2d&#xff0c;\u53ef\u80fd\u6709\u5f88\u591a\u7ebf\u7a0b\u5df2\u7ecf\u201c\u770b\u5230 ticket&gt;0\u201d\u5e76\u8fdb\u5165\u8be5\u4ee3\u7801\u6bb5&#xff1b;<\/li>\n<li>&#8211;ticket \u672c\u8eab\u4e0d\u662f\u539f\u5b50\u64cd\u4f5c&#xff0c;objdump -d \u53ef\u89c1\u5b83\u5bf9\u5e94\u4e09\u6761\u6c47\u7f16&#xff1a;<\/li>\n<p>mov  0x2004e3(%rip),%eax    # load   &#xff1a;\u4ece\u5185\u5b58\u8bfb\u5230\u5bc4\u5b58\u5668<br \/>\nsub  $0x1,%eax              # update &#xff1a;\u5bc4\u5b58\u5668\u5185 -1<br \/>\nmov  %eax,0x2004da(%rip)    # store  &#xff1a;\u5199\u56de\u5185\u5b58<\/p>\n<p>\u6ce8\u610f&#xff1a;<\/p>\n<ul>\n<li>\u4ee3\u7801\u5fc5\u987b\u8981\u6709\u4e92\u65a5\u884c\u4e3a&#xff1a;\u8fdb\u5165\u4e34\u754c\u533a\u6267\u884c\u65f6\u4e0d\u5141\u8bb8\u5176\u4ed6\u7ebf\u7a0b\u8fdb\u5165&#xff1b;<\/li>\n<li>\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8981\u6c42\u6267\u884c\u4e34\u754c\u533a\u3001\u800c\u4e34\u754c\u533a\u65e0\u4eba\u6267\u884c\u65f6&#xff0c;\u53ea\u80fd\u5141\u8bb8\u4e00\u4e2a\u7ebf\u7a0b\u8fdb\u5165&#xff1b;<\/li>\n<li>\u7ebf\u7a0b\u4e0d\u5728\u4e34\u754c\u533a\u4e2d\u6267\u884c\u65f6&#xff0c;\u4e0d\u80fd\u963b\u6b62\u5176\u4ed6\u7ebf\u7a0b\u8fdb\u5165\u3002<\/li>\n<\/ul>\n<p>\u672c\u8d28\u7ed3\u8bba&#xff1a;\u9700\u8981\u4e00\u628a\u9501&#xff0c;Linux \u4e0a\u5b83\u5c31\u662f\u4e92\u65a5\u91cf\u3002<\/p>\n<h3>3. \u4e92\u65a5\u91cf\u63a5\u53e3<\/h3>\n<p>\u521d\u59cb\u5316<\/p>\n<p><span class=\"token comment\">\/\/ \u65b9\u6cd51 \u9759\u6001\u5206\u914d&#xff08;\u5168\u5c40\/\u9759\u6001&#xff09;<\/span><br \/>\n<span class=\"token class-name\">pthread_mutex_t<\/span> mutex <span class=\"token operator\">&#061;<\/span> PTHREAD_MUTEX_INITIALIZER<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u65b9\u6cd52 \u52a8\u6001\u5206\u914d<\/span><br \/>\n<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>restrict mutex<span class=\"token punctuation\">,<\/span><br \/>\n                       <span class=\"token keyword\">const<\/span> <span class=\"token class-name\">pthread_mutexattr_t<\/span> <span class=\"token operator\">*<\/span>restrict attr<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/   mutex&#xff1a;\u8981\u521d\u59cb\u5316\u7684\u4e92\u65a5\u91cf     attr&#xff1a;NULL<\/span><\/p>\n<p>\u9500\u6bc1<\/p>\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<p>\u4e09\u6761\u6ce8\u610f&#xff1a;\u2460 \u7528 PTHREAD_MUTEX_INITIALIZER \u521d\u59cb\u5316\u7684\u4e0d\u9700\u8981\u9500\u6bc1&#xff1b;\u2461 \u4e0d\u8981\u9500\u6bc1\u4e00\u4e2a\u5df2\u7ecf\u52a0\u9501\u7684\u4e92\u65a5\u91cf&#xff1b;\u2462 \u5df2\u9500\u6bc1\u7684\u4e92\u65a5\u91cf\u8981\u786e\u4fdd\u540e\u7eed\u6ca1\u6709\u7ebf\u7a0b\u518d\u5c1d\u8bd5\u52a0\u9501\u3002<\/p>\n<p>\u52a0\u9501 \/ \u89e3\u9501<\/p>\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><br \/>\n<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><br \/>\n<span class=\"token comment\">\/\/ \u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de\u9519\u8bef\u53f7<\/span><\/p>\n<p>pthread_mutex_lock \u7684\u4e24\u79cd\u60c5\u5f62&#xff1a;<\/p>\n<ul>\n<li>\u4e92\u65a5\u91cf\u672a\u9501 \u2192 \u76f4\u63a5\u9501\u5b9a\u5e76\u8fd4\u56de\u6210\u529f&#xff1b;<\/li>\n<li>\u5df2\u88ab\u5176\u4ed6\u7ebf\u7a0b\u9501\u5b9a&#xff0c;\u6216\u540c\u65f6\u6709\u5176\u4ed6\u7ebf\u7a0b\u7533\u8bf7\u4f46\u6ca1\u7ade\u4e89\u5230 \u2192 \u8c03\u7528\u9677\u5165\u963b\u585e&#xff08;\u6267\u884c\u6d41\u88ab\u6302\u8d77&#xff09;&#xff0c;\u7b49\u5f85\u4e92\u65a5\u91cf\u89e3\u9501\u3002<\/li>\n<\/ul>\n<p>\u6539\u9020\u540e\u7684\u552e\u7968\u4ee3\u7801<\/p>\n<p><span class=\"token class-name\">pthread_mutex_t<\/span> mutex<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">route<\/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><br \/>\n    <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>id <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>arg<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">pthread_mutex_lock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>ticket <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">usleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1000<\/span><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;%s sells ticket:%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> id<span class=\"token punctuation\">,<\/span> ticket<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            ticket<span class=\"token operator\">&#8212;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token function\">pthread_mutex_unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">pthread_mutex_unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u6ce8\u610f&#xff1a;break \u4e4b\u524d\u4e5f\u5fc5\u987b\u89e3\u9501<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<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> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">pthread_mutex_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>mutex<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/* create t1..t4, join t1..t4 *\/<\/span><br \/>\n    <span class=\"token function\">pthread_mutex_destroy<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u9501\u5fc5\u987b\u8986\u76d6 if \u5224\u65ad &#043; ticket&#8211; \u6574\u4e2a\u903b\u8f91&#xff0c;\u53ea\u9501 ticket&#8211; \u4f9d\u7136\u4f1a\u8d85\u5356\u3002<\/p>\n<h3>4. \u4e92\u65a5\u91cf\u5b9e\u73b0\u539f\u7406<\/h3>\n<ul>\n<li>i&#043;&#043; \/ &#043;&#043;i \u90fd\u4e0d\u662f\u539f\u5b50\u7684&#xff0c;\u76f4\u63a5\u5171\u4eab\u4f1a\u5e26\u6765\u6570\u636e\u4e00\u81f4\u6027\u95ee\u9898&#xff1b;<\/li>\n<li>\u4e3a\u5b9e\u73b0\u4e92\u65a5\u9501&#xff0c;\u5927\u591a\u6570\u4f53\u7cfb\u7ed3\u6784\u90fd\u63d0\u4f9b swap \u6216 exchange \u6307\u4ee4&#xff0c;\u4f5c\u7528\u662f\u628a\u5bc4\u5b58\u5668\u4e0e\u5185\u5b58\u5355\u5143\u7684\u6570\u636e\u76f8\u4ea4\u6362&#xff1b;<\/li>\n<li>\u56e0\u4e3a\u53ea\u6709\u4e00\u6761\u6307\u4ee4&#xff0c;\u4fdd\u8bc1\u4e86\u539f\u5b50\u6027&#xff1a;\u5373\u4f7f\u591a\u5904\u7406\u5668\u5e73\u53f0&#xff0c;\u8bbf\u95ee\u5185\u5b58\u7684\u603b\u7ebf\u5468\u671f\u4e5f\u6709\u5148\u540e&#xff0c;\u4e00\u4e2a\u5904\u7406\u5668\u6267\u884c\u4ea4\u6362\u6307\u4ee4\u65f6&#xff0c;\u53e6\u4e00\u4e2a\u5904\u7406\u5668\u7684\u4ea4\u6362\u6307\u4ee4\u53ea\u80fd\u7b49\u603b\u7ebf\u5468\u671f\u3002<\/li>\n<\/ul>\n<p>lock:                       ; \u52a0\u9501<br \/>\n    mov  $0, %al<br \/>\n    xchg %al, mutex         ; \u539f\u5b50\u4ea4\u6362<br \/>\n    if (%al &gt; 0)  return 0  ; \u539f\u6765 mutex&#061;&#061;1&#xff0c;\u4ea4\u6362\u6210\u529f\u62ff\u5230\u9501<br \/>\n    else { \u6302\u8d77\u7b49\u5f85; goto lock; }<\/p>\n<p>unlock:                     ; \u89e3\u9501<br \/>\n    mov  $1, %al<br \/>\n    xchg %al, mutex<br \/>\n    if (%al &gt; 0) { \u5524\u9192\u7b49\u5f85\u8be5 mutex \u7684\u7ebf\u7a0b; return 0; }<br \/>\n    return 0;<\/p>\n<p>\u8981\u70b9&#xff1a;\u6240\u8c13\u201c\u52a0\u9501\u201d\u5c31\u662f\u4e00\u6b21\u539f\u5b50\u4ea4\u6362&#xff1b;\u6ca1\u6362\u5230&#xff08;\u62ff\u5230 0&#xff09;\u5c31\u8bf4\u660e\u9501\u88ab\u522b\u4eba\u6301\u7740&#xff0c;\u53ea\u80fd\u6302\u8d77\u7b49\u5f85 \u2014\u2014 \u8fd9\u5c31\u662f mutex \u7684\u5e95\u5c42\u673a\u5236\u3002<\/p>\n<h3>5. \u4e92\u65a5\u91cf\u7684 C&#043;&#043; \u5c01\u88c5&#xff08;1-4&#xff09;<\/h3>\n<p>Lock.hpp&#xff0c;\u547d\u540d\u7a7a\u95f4 LockModule&#xff0c;\u4e24\u4e2a\u7c7b&#xff1a;<\/p>\n<p>\u2460 Mutex&#xff08;\u53ef\u72ec\u7acb\u4f7f\u7528\u7684\u9501\u672c\u4f53&#xff09;<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Mutex<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">public<\/span><span class=\"token operator\">:<\/span><br \/>\n    <span class=\"token function\">Mutex<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> Mutex <span class=\"token operator\">&amp;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">delete<\/span><span class=\"token punctuation\">;<\/span>                 <span class=\"token comment\">\/\/ \u7981\u6b62\u62f7\u8d1d<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> Mutex <span class=\"token operator\">&amp;<\/span><span class=\"token keyword\">operator<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> Mutex <span class=\"token operator\">&amp;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">delete<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u7981\u6b62\u8d4b\u503c<\/span><br \/>\n    <span class=\"token function\">Mutex<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token punctuation\">{<\/span> <span class=\"token function\">pthread_mutex_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>_mutex<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">void<\/span> <span class=\"token function\">Lock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>   <span class=\"token punctuation\">{<\/span> <span class=\"token function\">pthread_mutex_lock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>_mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">void<\/span> <span class=\"token function\">Unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">pthread_mutex_unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>_mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    pthread_mutex_t <span class=\"token operator\">*<\/span><span class=\"token function\">GetMutexOriginal<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&amp;<\/span>_mutex<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span>  <span class=\"token comment\">\/\/ \u9700\u8981\u539f\u751f\u63a5\u53e3\u65f6\u7528<\/span><br \/>\n    <span class=\"token operator\">~<\/span><span class=\"token function\">Mutex<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">pthread_mutex_destroy<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>_mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">private<\/span><span class=\"token operator\">:<\/span><br \/>\n    pthread_mutex_t _mutex<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u2461 LockGuard&#xff08;RAII \u98ce\u683c\u7684\u9501\u7ba1\u7406&#xff09;<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">LockGuard<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">public<\/span><span class=\"token operator\">:<\/span><br \/>\n    <span class=\"token function\">LockGuard<\/span><span class=\"token punctuation\">(<\/span>Mutex <span class=\"token operator\">&amp;<\/span>mutex<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">:<\/span> <span class=\"token function\">_mutex<\/span><span class=\"token punctuation\">(<\/span>mutex<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> _mutex<span class=\"token punctuation\">.<\/span><span class=\"token function\">Lock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token operator\">~<\/span><span class=\"token function\">LockGuard<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> _mutex<span class=\"token punctuation\">.<\/span><span class=\"token function\">Unlock<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">private<\/span><span class=\"token operator\">:<\/span><br \/>\n    Mutex <span class=\"token operator\">&amp;<\/span>_mutex<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u7528\u8d77\u6765\u4e1a\u52a1\u4ee3\u7801\u53d8\u5f97\u6781\u7b80&#xff0c;\u4e14\u4efb\u4f55\u51fa\u53e3\u90fd\u4e0d\u4f1a\u6f0f\u89e3\u9501&#xff1a;<\/p>\n<p>Mutex mutex<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    LockGuard <span class=\"token function\">lockguard<\/span><span class=\"token punctuation\">(<\/span>mutex<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u4f5c\u7528\u57df\u5f00\u59cb \u2192 \u52a0\u9501<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>ticket <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">usleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> ticket<span class=\"token operator\">&#8212;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span>                   <span class=\"token comment\">\/\/ \u4f5c\u7528\u57df\u7ed3\u675f\/break \u2192 \u6790\u6784\u81ea\u52a8\u89e3\u9501<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>RAII \u98ce\u683c\u7684\u4e92\u65a5\u9501 C&#043;&#043;11 \u5df2\u5185\u5efa&#xff0c;\u5bf9\u5e94 std::mutex &#043; std::lock_guard&lt;std::mutex&gt;&#xff1b;\u672c\u8282\u53ea\u662f\u81ea\u884c\u5c01\u88c5\u4ee5\u4fbf\u540e\u9762&#xff08;\u751f\u4ea7\u8005\u6d88\u8d39\u8005\u3001\u7ebf\u7a0b\u6c60&#xff09;\u76f4\u63a5\u4f7f\u7528\u3002<\/p>\n<h3>6. \u8981\u70b9\u901f\u8bb0\u4e0e\u6613\u9519\u70b9<\/h3>\n<li>\u9501\u7684\u8303\u56f4 &#061; \u4e34\u754c\u533a&#xff1a;\u5224\u65ad\u6761\u4ef6\u4e0e\u4fee\u6539\u5171\u4eab\u53d8\u91cf\u5fc5\u987b\u540c\u65f6\u5728\u9501\u5185&#xff0c;\u4e0d\u80fd\u53ea\u9501 &#8211;\u3002<\/li>\n<li>\u6bcf\u4e2a\u51fa\u53e3\u90fd\u8981\u89e3\u9501&#xff1a;\u6b63\u5e38\u5206\u652f\u3001else \u5206\u652f\u3001break\u3001\u5f02\u5e38\u8def\u5f84 \u2014\u2014 \u7528 LockGuard \u4e00\u6b21\u6027\u89e3\u51b3\u3002<\/li>\n<li>\u9759\u6001\u521d\u59cb\u5316\u4e0d\u9700\u8981 destroy&#xff1b;\u4e0d\u8981\u9500\u6bc1\u52a0\u9501\u4e2d\u7684\/\u4ecd\u4f1a\u88ab\u4f7f\u7528\u7684\u9501\u3002<\/li>\n<li>pthread_mutex_* \u5931\u8d25\u662f\u8fd4\u56de\u9519\u8bef\u53f7&#xff0c;\u4e0d\u8bbe\u7f6e errno\u3002<\/li>\n<li>\u4e0d\u8981\u6301\u9501\u505a\u8017\u65f6\u64cd\u4f5c&#xff1a;\u4f8b\u5b50\u628a usleep\/printf \u653e\u5728\u9501\u5185&#xff0c;\u7b49\u4e8e\u628a\u5e76\u53d1\u91cd\u65b0\u538b\u56de\u4e32\u884c&#xff08;\u80fd\u6b63\u786e&#xff0c;\u4f46\u541e\u5410\u53d8\u5dee&#xff09;\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u7ebf\u7a0b\u540c\u6b65\u4e0e\u4e92\u65a5\u603b\u7ed3\u672c\u7ae0\u4e3b\u7ebf\u662f\u201c\u5148\u4e92\u65a5&#xff0c;\u518d\u540c\u6b65\u201d&#xff1a;\u90e8\u5206\u89e3\u51b3\u7684\u95ee\u9898\u624b\u6bb51. \u7ebf\u7a0b\u4e92\u65a5&#xff08;\u672c\u8282&#xff09;\u540c\u4e00\u65f6\u523b\u53ea\u80fd\u6709\u4e00\u4e2a\u6267\u884c\u6d41\u8fdb\u5165\u4e34\u754c\u533a\u4e92\u65a5\u91cf pthread_mutex_t2. \u7ebf\u7a0b\u540c\u6b65&#xff08;\u540e\u7eed&#xff09;\u6309\u7279\u5b9a\u987a\u5e8f\u8bbf\u95ee&#xff0c;\u907f\u514d\u9965\u997f\u6761\u4ef6\u53d8\u91cf\u3001\u4fe1\u53f7\u91cf\u8bfe\u4ef6\u672c\u8282\u56db\u4e2a\u76ee\u6807&#xff1a;1-1 \u80cc\u666f\u6982\u5ff5 \u2192 1-2 \u4e92\u65a5\u91cf mutex \u2192 1-3 \u5b9e\u73b0\u539f\u7406 \u2192 1-4 \u5c01\u88c5\u3002<br \/>\n1. \u4e94\u4e2a\u80cc\u666f\u6982\u5ff5\u6982\u5ff5\u542b\u4e49\u5171\u4eab\u8d44\u6e90\u591a<\/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":[58,43],"topic":[],"class_list":["post-118370","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u7ebf\u7a0b\u4e92\u65a5 - \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\/118370.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u7ebf\u7a0b\u4e92\u65a5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7ebf\u7a0b\u540c\u6b65\u4e0e\u4e92\u65a5\u603b\u7ed3\u672c\u7ae0\u4e3b\u7ebf\u662f\u201c\u5148\u4e92\u65a5&#xff0c;\u518d\u540c\u6b65\u201d&#xff1a;\u90e8\u5206\u89e3\u51b3\u7684\u95ee\u9898\u624b\u6bb51. \u7ebf\u7a0b\u4e92\u65a5&#xff08;\u672c\u8282&#xff09;\u540c\u4e00\u65f6\u523b\u53ea\u80fd\u6709\u4e00\u4e2a\u6267\u884c\u6d41\u8fdb\u5165\u4e34\u754c\u533a\u4e92\u65a5\u91cf pthread_mutex_t2. \u7ebf\u7a0b\u540c\u6b65&#xff08;\u540e\u7eed&#xff09;\u6309\u7279\u5b9a\u987a\u5e8f\u8bbf\u95ee&#xff0c;\u907f\u514d\u9965\u997f\u6761\u4ef6\u53d8\u91cf\u3001\u4fe1\u53f7\u91cf\u8bfe\u4ef6\u672c\u8282\u56db\u4e2a\u76ee\u6807&#xff1a;1-1 \u80cc\u666f\u6982\u5ff5 \u2192 1-2 \u4e92\u65a5\u91cf mutex \u2192 1-3 \u5b9e\u73b0\u539f\u7406 \u2192 1-4 \u5c01\u88c5\u3002 1. \u4e94\u4e2a\u80cc\u666f\u6982\u5ff5\u6982\u5ff5\u542b\u4e49\u5171\u4eab\u8d44\u6e90\u591a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/118370.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-26T18:16:51+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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118370.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/118370.html\",\"name\":\"Linux \u7ebf\u7a0b\u4e92\u65a5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-26T18:16:51+00:00\",\"dateModified\":\"2026-10-26T18:16:51+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/118370.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/118370.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118370.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u7ebf\u7a0b\u4e92\u65a5\"}]},{\"@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 \u7ebf\u7a0b\u4e92\u65a5 - \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\/118370.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u7ebf\u7a0b\u4e92\u65a5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7ebf\u7a0b\u540c\u6b65\u4e0e\u4e92\u65a5\u603b\u7ed3\u672c\u7ae0\u4e3b\u7ebf\u662f\u201c\u5148\u4e92\u65a5&#xff0c;\u518d\u540c\u6b65\u201d&#xff1a;\u90e8\u5206\u89e3\u51b3\u7684\u95ee\u9898\u624b\u6bb51. \u7ebf\u7a0b\u4e92\u65a5&#xff08;\u672c\u8282&#xff09;\u540c\u4e00\u65f6\u523b\u53ea\u80fd\u6709\u4e00\u4e2a\u6267\u884c\u6d41\u8fdb\u5165\u4e34\u754c\u533a\u4e92\u65a5\u91cf pthread_mutex_t2. \u7ebf\u7a0b\u540c\u6b65&#xff08;\u540e\u7eed&#xff09;\u6309\u7279\u5b9a\u987a\u5e8f\u8bbf\u95ee&#xff0c;\u907f\u514d\u9965\u997f\u6761\u4ef6\u53d8\u91cf\u3001\u4fe1\u53f7\u91cf\u8bfe\u4ef6\u672c\u8282\u56db\u4e2a\u76ee\u6807&#xff1a;1-1 \u80cc\u666f\u6982\u5ff5 \u2192 1-2 \u4e92\u65a5\u91cf mutex \u2192 1-3 \u5b9e\u73b0\u539f\u7406 \u2192 1-4 \u5c01\u88c5\u3002 1. \u4e94\u4e2a\u80cc\u666f\u6982\u5ff5\u6982\u5ff5\u542b\u4e49\u5171\u4eab\u8d44\u6e90\u591a","og_url":"https:\/\/www.wsisp.com\/helps\/118370.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-26T18:16:51+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/118370.html","url":"https:\/\/www.wsisp.com\/helps\/118370.html","name":"Linux \u7ebf\u7a0b\u4e92\u65a5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-26T18:16:51+00:00","dateModified":"2026-10-26T18:16:51+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/118370.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/118370.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/118370.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u7ebf\u7a0b\u4e92\u65a5"}]},{"@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\/118370","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=118370"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/118370\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=118370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=118370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=118370"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=118370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}