linux pthread\u5934\u6587\u4ef6<\/strong>\uff0c\u7cfb\u7edf\u9884\u8bbe\u7684\u6807\u51c6\u4f4d\u7f6e\u65e0\u9700\u989d\u5916\u64cd\u4f5c\u5373\u53ef\u76f4\u63a5\u5f15\u7528\u3002\u7136\u800c\uff0c\u82e5\u91c7\u7528\u7279\u5b9a\u5b89\u88c5\u65b9\u5f0f\u6216\u8bbe\u5b9a\u4e86\u81ea\u5b9a\u4e49\u76ee\u5f55\uff0c\u7f16\u8bd1\u65f6\u4fbf\u9700\u660e\u786e\u6307\u51fa\u5305\u542b\u8def\u5f84\u3002\u8fd9\u6837\u505a\u6709\u52a9\u4e8e\u7f16\u8bd1\u5668\u7cbe\u786e\u5730\u5b9a\u4f4d\u5230pthread\u5934\u6587\u4ef6\u4e2d\u7684\u51fd\u6570\u58f0\u660e\u7b49\u76f8\u5173\u5185\u5bb9\u3002<\/p>\n\u7ebf\u7a0b\u5c5e\u6027\u8bbe\u7f6e<\/b><\/p>\n
pthread\u5934\u6587\u4ef6\u4e2d\uff0c\u6709\u5173\u4e8e\u7ebf\u7a0b\u5c5e\u6027\u7684\u8be6\u7ec6\u8bf4\u660e\u3002\u7ebf\u7a0b\u5c5e\u6027\u7684\u53ef\u914d\u7f6e\u9009\u9879\u76f8\u5f53\u4e30\u5bcc\u3002\u4f8b\u5982\uff0c\u7ebf\u7a0b\u7684\u4f18\u5148\u7ea7\u5c5e\u6027\uff0c\u6070\u5f53\u7684\u8c03\u6574\u80fd\u591f\u5f71\u54cd\u7ebf\u7a0b\u83b7\u53d6CPU\u8d44\u6e90\u7684\u673a\u4f1a\u3002\u5728\u9700\u8981\u9ad8\u5b9e\u65f6\u6027\u7684\u4efb\u52a1\u4e2d\uff0c\u8bbe\u7f6e\u8f83\u9ad8\u4f18\u5148\u7ea7\u7684\u7ebf\u7a0b\uff0c\u5b83\u4eec\u80fd\u591f\u66f4\u8fc5\u901f\u5730\u88ab\u6267\u884c\u3002<\/p>\n
\u53e6\u5916\u4e00\u70b9\u662f\u5173\u4e8e\u7ebf\u7a0b\u7684\u72ec\u7acb\u7279\u6027\u3002\u6211\u4eec\u53ef\u4ee5\u628a\u4e00\u4e2a\u7ebf\u7a0b\u8bbe\u5b9a\u4e3a\u72ec\u7acb\u6a21\u5f0f\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e2d\uff0c\u4e00\u65e6\u7ebf\u7a0b\u7ec8\u6b62\uff0c\u7cfb\u7edf\u4fbf\u4f1a\u81ea\u52a8\u5904\u7406\u8d44\u6e90\u7684\u56de\u6536\u5d4c\u5165\u5f0flinux\u57f9\u8bad\uff0c\u65e0\u9700\u5176\u4ed6\u7ebf\u7a0b\u901a\u8fc7\u8c03\u7528pthread_join\u6765\u624b\u52a8\u56de\u6536\u3002\u8fd9\u975e\u5e38\u9002\u5408\u90a3\u4e9b\u4e3b\u7ebf\u7a0b\u65e0\u9700\u5173\u6ce8\u5176\u7ed3\u675f\u72b6\u6001\u7684\u7ebf\u7a0b\u3002<\/p>\n
<\/p>\n
\u4e0e\u5176\u4ed6\u7cfb\u7edf\u8c03\u7528\u7684\u534f\u4f5c<\/b><\/p>\n
\u5728Linux\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u4f7f\u7528pthread\u5934\u6587\u4ef6\u4e2d\u7684\u51fd\u6570\u65f6\uff0c\u5f80\u5f80\u9700\u8981\u4e0e\u7cfb\u7edf\u8c03\u7528\u7684\u5176\u4ed6\u529f\u80fd\u76f8\u4e92\u914d\u5408\u3002\u4ee5\u4fe1\u53f7\u5904\u7406\u4e3a\u4f8b\uff0c\u7ebf\u7a0b\u53ef\u80fd\u4f1a\u9047\u5230\u5e76\u5904\u7406\u591a\u79cd\u4fe1\u53f7\u3002\u6bd4\u5982\uff0c\u5728\u67d0\u4e9b\u7279\u5b9a\u60c5\u5883\u4e0b\uff0c\u7ebf\u7a0b\u63a5\u6536\u5230\u67d0\u4e2a\u7279\u5b9a\u4fe1\u53f7\u540e\uff0c\u53ef\u80fd\u4f1a\u8c03\u6574\u81ea\u5df1\u7684\u6267\u884c\u8def\u5f84\u6216\u5904\u7406\u903b\u8f91\u3002\u8fd9\u65f6\uff0c\u5c31\u9700\u8981\u8003\u8651\u5982\u4f55\u4e0epthread\u51fd\u6570\u76f8\u4e92\u914d\u5408\u3002<\/p>\n
\u5728\u6587\u4ef6\u64cd\u4f5c\u8fd9\u5757\uff0c\u5f97\u6ce8\u610f\u4e86\u3002\u591a\u4e2a\u7ebf\u7a0b\u53ef\u80fd\u4f1a\u540c\u65f6\u5bf9\u8fd9\u4e2a\u6587\u4ef6\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5c31\u5f97\u628apthread\u5934\u6587\u4ef6\u91cc\u7684\u4e92\u65a5\u91cf\u7b49\u673a\u5236\u8ddf\u6587\u4ef6\u64cd\u4f5c\u7684\u7cfb\u7edf\u8c03\u7528\uff0c\u6bd4\u5982open\u3001write\u3001read\u7b49linux\u547d\u4ee4\u624b\u518c\uff0c\u7ed3\u5408\u8d77\u6765\u4f7f\u7528\u3002\u8fd9\u6837\u624d\u80fd\u4fdd\u8bc1\u6587\u4ef6\u64cd\u4f5c\u65e2\u6b63\u786e\u53c8\u5b8c\u6574\u3002<\/p>\n
<\/p>\n
\u9519\u8bef\u5904\u7406\u673a\u5236<\/b><\/p>\n
\u5728pthread\u5934\u6587\u4ef6\u4e2d\uff0c\u5f53\u51fd\u6570\u64cd\u4f5c\u4e0d\u6210\u529f\u65f6\uff0c\u4f1a\u8fd4\u56de\u4e00\u4e2a\u7279\u5b9a\u7684\u9519\u8bef\u7801\u3002\u901a\u8fc7\u8fd9\u4e9b\u9519\u8bef\u7801\u7684\u68c0\u67e5\uff0c\u6211\u4eec\u53ef\u4ee5\u7cbe\u786e\u5730\u8bc6\u522b\u51fa\u64cd\u4f5c\u5931\u8d25\u7684\u5177\u4f53\u539f\u56e0\u3002\u6bd4\u5982\uff0c\u7ebf\u7a0b\u521b\u5efa\u5931\u8d25\u53ef\u80fd\u662f\u7531\u4e8e\u7cfb\u7edf\u8d44\u6e90\u77ed\u7f3a\u7b49\u5176\u4ed6\u56e0\u7d20\u5bfc\u81f4\u7684\u3002<\/p>\n
\u5728\u7f16\u7a0b\u4e2d\uff0c\u9488\u5bf9\u5404\u79cd\u9519\u8bef\uff0c\u4e00\u4e2a\u4e0d\u9519\u7684\u4e60\u60ef\u662f\u5728\u51fd\u6570\u8c03\u7528\u5b8c\u6bd5\u540e\uff0c\u7acb\u523b\u5bf9\u8fd4\u56de\u7684\u7ed3\u679c\u8fdb\u884c\u6838\u5b9e\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u91c7\u53d6\u76f8\u5e94\u7684\u5e94\u5bf9\u63aa\u65bd\uff0c\u4f8b\u5982\uff0c\u5c55\u793a\u9519\u8bef\u4fe1\u606f\uff0c\u6216\u8005\u91ca\u653e\u90a3\u4e9b\u5df2\u7ecf\u5206\u914d\u7684\u8d44\u6e90\u3002<\/p>\n
<\/p>\n
\u5b9e\u9645\u5e94\u7528\u6848\u4f8b<\/b><\/p>\n
\u5728\u7f51\u7edc\u7f16\u7a0b\u9886\u57df\uff0cpthread\u5934\u6587\u4ef6\u662f\u5e38\u7528\u7684\u3002\u4f8b\u5982\uff0c\u5728\u591a\u7ebf\u7a0b\u670d\u52a1\u5668\u4e2d\uff0c\u5b83\u9700\u8981\u5e94\u5bf9\u591a\u4e2a\u5ba2\u6237\u7aef\u7684\u63a5\u5165\u3002\u8fd9\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u4e2a\u7ebf\u7a0b\u6765\u5e76\u884c\u5904\u7406\u6765\u81ea\u4e0d\u540c\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u3002\u800c\u8fd9\u4e9b\u7ebf\u7a0b\u7684\u5efa\u7acb\u4e0e\u7ef4\u62a4\uff0c\u6b63\u662f\u4f9d\u8d56\u4e8epthread\u5934\u6587\u4ef6\u6240\u63d0\u4f9b\u7684\u51fd\u6570\u3002<\/p>\n
\u56fe\u50cf\u5904\u7406\u8f6f\u4ef6\u4e2d\u4e5f\u53ef\u80fd\u4f1a\u6709\u5e94\u7528\u3002\u6bd4\u5982\uff0c\u53ef\u4ee5\u7ed9\u4e0d\u540c\u7684\u56fe\u50cf\u6a21\u5757\u5206\u914d\u5404\u81ea\u7684\u7ebf\u7a0b\uff0c\u7136\u540e\u901a\u8fc7\u8fd9\u4e9b\u7ebf\u7a0b\u5e76\u884c\u5904\u7406\u56fe\u50cf\u7684\u4e0d\u540c\u90e8\u5206\uff0c\u8fd0\u7b97\u6548\u7387\u5f97\u5230\u63d0\u5347\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u6574\u4f53\u7684\u5904\u7406\u65f6\u95f4\u5c31\u80fd\u76f8\u5e94\u51cf\u5c11\u3002<\/p>\n
\u6211\u60f3\u8bf7\u6559\u5404\u4f4d\uff0c\u5728\u4f7f\u7528pthread\u5934\u6587\u4ef6\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u4eec\u662f\u5426\u9047\u5230\u8fc7\u7279\u522b\u68d8\u624b\u7684\u95ee\u9898\uff1f\u671f\u5f85\u5927\u5bb6\u7684\u70b9\u8d5e\u548c\u8f6c\u53d1\uff0c\u4e5f\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u79ef\u6781\u53c2\u4e0e\u8ba8\u8bba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Linux\u7684pthread\u5934\u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u521b\u5efa\u7ebf\u7a0b\u7684\u51fd\u6570\uff0c\u4f8b\u5982pthread_create\u3002pthread\u5934\u6587\u4ef6\u4e2d\uff0c\u6709\u5173\u4e8e\u7ebf\u7a0b\u5c5e\u6027\u7684\u8be6\u7ec6\u8bf4\u660e\u3002\u5728\u7f51\u7edc\u7f16\u7a0b\u9886\u57df\uff0cpthread\u5934\u6587\u4ef6\u662f\u5e38\u7528\u7684\u3002\u800c\u8fd9\u4e9b\u7ebf\u7a0b\u7684\u5efa\u7acb\u4e0e\u7ef4\u62a4\uff0c\u6b63\u662f\u4f9d\u8d56\u4e8epthread\u5934\u6587\u4ef6\u6240\u63d0\u4f9b\u7684\u51fd\u6570\u3002<\/p>\n","protected":false},"author":1,"featured_media":293946,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[3850,3851,3849,1609,3852],"class_list":["post-293945","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-ptwj","tag-hssm","tag-dxcbcxl","tag-xtdy","tag-xcsx"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/293945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=293945"}],"version-history":[{"count":0,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/293945\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/293946"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=293945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=293945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=293945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}