{"id":52281,"date":"2024-12-03T17:39:22","date_gmt":"2024-12-03T09:39:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52281\/"},"modified":"2024-12-03T17:39:22","modified_gmt":"2024-12-03T09:39:22","slug":"linux%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%bc%96%e7%a8%8b%e7%9a%84%e7%9f%a5%e8%af%86%e7%82%b9%e6%9c%89%e5%93%aa%e4%ba%9b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52281\/","title":{"rendered":"linux\u591a\u7ebf\u7a0b\u7f16\u7a0b\u7684\u77e5\u8bc6\u70b9\u6709\u54ea\u4e9b"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>linux\u591a\u7ebf\u7a0b\u7f16\u7a0b\u7684\u77e5\u8bc6\u70b9\u6709\u54ea\u4e9b<\/h1>\n<p><span style=\"font-size: 15px\">\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300alinux\u591a\u7ebf\u7a0b\u7f16\u7a0b\u7684\u77e5\u8bc6\u70b9\u6709\u54ea\u4e9b\u300b<\/span>\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/span><\/p>\n<p>linux\u7ebf\u7a0b\u5206\u4e3a\u4e24\u7c7b\uff1a\u4e00\u662f\u6838\u5fc3\u7ea7\u652f\u6301\u7ebf\u7a0b\uff0c\u4e8c\u662f\u7528\u6237\u7ea7\u7684\u7ebf\u7a0b\u3002\u4e00\u822c\u90fd\u4e3a\u7528\u6237\u7ea7\u7684\u7ebf\u7a0b\u3002<\/p>\n<p>\u4e00\u3001\u591a\u7ebf\u7a0b\u7684\u51e0\u4e2a\u5e38\u89c1\u51fd\u6570<\/p>\n<p>\u8981\u521b\u5efa\u591a\u7ebf\u7a0b\u5fc5\u987b\u52a0\u8f7dpthread.h\u6587\u4ef6\uff0c\u5e93\u6587\u4ef6pthread\u3002\u7ebf\u7a0b\u7684\u6807\u8bc6\u7b26pthread_t\u5728\u5934\u6587\u4ef6\/usr\/include\/bits\/pthreadtypes.h\u4e2d\u5b9a\u4e49\uff1atypedef&nbsp; unsigned&nbsp; long&nbsp; int&nbsp; pthread_t<\/p>\n<p>1.\u521b\u5efa\u7ebf\u7a0b:<\/p>\n<p>int pthread_create(pthread_t *restrict thread,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const pthread_attr_t *restrict attr,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void *(*start_routine)(void*), void *restrict arg);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thread\u8f93\u51fa\u7ebf\u7a0bid<br \/>&nbsp;&nbsp;&nbsp;&nbsp; attr \u7ebf\u7a0b\u5c5e\u6027\uff0c \u9ed8\u8ba4null<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start_routine\u7ebf\u7a0b\u6267\u884c\u51fd\u6570<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arg\u7ebf\u7a0b\u6267\u884c\u53c2\u6570&nbsp;<br \/>note:\u51fd\u6570\u6210\u529f\u8fd4\u56de0 \u5426\u5219\u8fd4\u56de\u9519\u8bef\u7801<\/p>\n<p>2.\u7b49\u5f85\u6307\u5b9a\u7ebf\u7a0b\u7ed3\u675f:<\/p>\n<p>int pthread_join(pthread_t thread,void **value_ptr);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thread\u4e00\u4e2a\u6709\u6548\u7684\u7ebf\u7a0bid<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value_ptr \u63a5\u6536\u7ebf\u7a0b\u8fd4\u56de\u503c\u7684\u6307\u9488<br \/>note:\u8c03\u7528\u6b64\u51fd\u6570\u7684\u7ebf\u7a0b\u5728\u6307\u5b9a\u7684\u7ebf\u7a0b\u9000\u51fa\u524d\u5c06\u5904\u4e8e\u6302\u8d77\u72b6\u6001\u6216\u51fa\u73b0\u9519\u8bef\u800c\u76f4\u63a5\u8fd4\u56de\uff0c\u5982\u679cvalue_ptr\u975enull\u5219value_ptr\u6307\u5411\u7ebf\u7a0b\u8fd4\u56de\u503c\u7684\u6307\u9488\uff0c\u51fd\u6570\u6210\u529f\u540e\u6307\u5b9a\u7684\u7ebf\u7a0b\u4f7f\u7528\u7684\u8d44\u6e90\u5c06\u88ab\u91ca\u653e\u3002<\/p>\n<p>3.\u9000\u51fa\u7ebf\u7a0b:<\/p>\n<p>int pthread_exit(void * value_ptr);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value_ptr \u7ebf\u7a0b\u8fd4\u56de\u503c\u6307\u9488<br \/>note: ptrhead_exit()\u9000\u51fa\u8c03\u7528\u6b64\u51fd\u6570\u7684\u7ebf\u7a0b\u5e76\u91ca\u653e\u8be5\u7ebf\u7a0b\u5360\u7528\u7684\u8d44\u6e90\u3002<\/p>\n<p>4.\u83b7\u53d6\u5f53\u524d\u7ebf\u7a0bid:<\/p>\n<p>pthread_t pthread_self(void);<br \/>\u53c2\u6570:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>note:\u8fd4\u56de\u5f53\u524d\u51fd\u6570\u7684id<\/p>\n<p>5.\u4e92\u65a5<\/p>\n<p>\u521b\u5efa\u4e92\u65a5:<br \/>int pthread_mutex_init(pthread_mutex_t *restrict mutex,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const pthread_mutexattr_t *restrict attr);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mutex\u8f93\u51fa\u4e92\u65a5id<br \/>&nbsp;&nbsp;&nbsp;&nbsp; attr \u4e92\u65a5\u5c5e\u6027\uff0c \u9ed8\u8ba4null<br \/>note:\u51fd\u6570\u6210\u529f\u8fd4\u56de0 \u5426\u5219\u8fd4\u56de\u9519\u8bef\u7801<br \/>\u9501\u4f4f\u4e92\u65a5:<br \/>int pthread_mutex_lock(pthread_mutex_t *mutex);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mutex\u4e92\u65a5id<br \/>note:\u5982\u679c\u6307\u5b9a\u7684\u4e92\u65a5id\u5df2\u7ecf\u88ab\u9501\u4f4f\u90a3\u4e48\u547c\u53eb\u7ebf\u7a0b\u5728\u4e92\u65a5id\u5b8c\u5168\u89e3\u9501\u524d\u5c06\u4e00\u76f4\u5904\u4e8e\u6302\u8d77\u72b6\u6001,\u5426\u5219\u5c06\u9501\u4f4f\u4e92\u65a5\u4f53\u3002<br \/>int pthread_mutex_trylock(pthread_mutex_t *mutex);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mutex\u4e92\u65a5id<br \/>note:\u5982\u679c\u6307\u5b9a\u7684\u4e92\u65a5id\u5df2\u7ecf\u88ab\u9501\u4f4f\u90a3\u4e48\u5c06\u76f4\u63a5\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\uff0c\u901a\u8fc7\u5224\u65ad\u6b64\u9519\u8bef\u6765\u8fdb\u884c\u4e0d\u540c\u7684\u5904\u7406\u3002pthread_mutex_trylock\u548cpthread_mutex_lock\u76f8\u4f3c\uff0c\u4e0d\u540c\u7684\u662fpthread_mutex_trylock\u53ea\u6709\u5728\u4e92\u65a5\u88ab\u9501\u4f4f\u7684\u60c5\u51b5\u4e0b\u624d\u963b\u585e\u3002<br \/>\u89e3\u9501\u4e92\u65a5:<br \/>int pthread_mutex_unlock(pthread_mutex_t *mutex);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp; mutex\u4e92\u65a5id<br \/>note:\u5982\u679c\u6307\u5b9a\u7684\u4e92\u65a5id\u5df2\u7ecf\u88ab\u9501\u4f4f\u90a3\u4e48\u5bf9\u5176\u89e3\u9501<br \/>\u91ca\u653e\u4e92\u65a5:<br \/>int pthread_mutex_destroy(pthread_mutex_t *mutex);<br \/>\u53c2\u6570:<br \/>&nbsp;&nbsp;&nbsp;&nbsp; mutex\u4e92\u65a5id<br \/>note:\u91ca\u653e\u6307\u5b9a\u7684mutex\u5360\u7528\u7684\u8d44\u6e90\u3002<br \/>\u51fd\u6570pthread_mutex_init\u548cpthread_mutex_destroy\u5206\u522b\u662f\u4e92\u65a5\u9501\u7684\u6784\u9020\u51fd\u6570\u548c\u6790\u6784\u51fd\u6570\u3002<\/p>\n<p>&nbsp;\u4e8c\u3001\u591a\u7ebf\u7a0b\u540c\u6b65<\/p>\n<p>1.\u4e92\u65a5\u4f53<\/p>\n<p>\u4e92\u65a5\u91cf\uff08mutex\uff09\u76f8\u5f53\u4e8e\u4e00\u628a\u9501\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u4ee5\u4e0b\u4e09\u70b9\uff1a<br \/>\u25ce\u539f\u5b50\u6027\uff1a\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u9501\u5b9a\u4e00\u4e2a\u4e92\u65a5\u91cf\uff0c\u90a3\u4e48\u4e34\u754c\u533a\u5185\u7684\u64cd\u4f5c\u8981\u4e48\u5168\u90e8\u5b8c\u6210\uff0c\u8981\u4e48\u4e00\u4e2a\u4e5f\u4e0d\u6267\u884c\u3002<br \/>\u25ce\u60df\u4e00\u6027\uff1a\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u9501\u5b9a\u4e00\u4e2a\u4e92\u65a5\u91cf\uff0c\u90a3\u4e48\u5728\u5b83\u89e3\u9664\u9501\u5b9a\u4e4b\u524d\uff0c\u6ca1\u6709\u5176\u4ed6\u7ebf\u7a0b\u53ef\u4ee5\u9501\u5b9a\u8fd9\u4e2a\u4e92\u65a5\u91cf\u3002<br \/>\u25ce\u975e\u7e41\u5fd9\u7b49\u5f85\uff1a\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u5df2\u7ecf\u9501\u5b9a\u4e00\u4e2a\u4e92\u65a5\u91cf\uff0c\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b\u53c8\u8bd5\u56fe\u53bb\u9501\u5b9a\u8fd9\u4e2a\u4e92\u65a5\u91cf\uff0c\u5219\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b\u5c06\u88ab\u6302\u8d77\uff08\u4e0d\u5360\u7528\u4efb\u4f55cpu\u8d44\u6e90\uff09\uff0c\u76f4\u5230\u7b2c\u4e00\u4e2a\u7ebf\u7a0b\u89e3\u9664\u5bf9\u8fd9\u4e2a\u4e92\u65a5\u91cf\u7684\u9501\u5b9a\u4e3a\u6b62\u3002<\/p>\n<p>2.\u6761\u4ef6\u53d8\u91cf<\/p>\n<p>\u6761\u4ef6\u53d8\u91cf\u662f\u4e00\u79cd\u53ef\u4ee5\u4f7f\u7ebf\u7a0b\uff08\u4e0d\u6d88\u8017cpu\uff09\u7b49\u5f85\u67d0\u4e9b\u4e8b\u4ef6\u53d1\u751f\u7684\u673a\u5236\u3002\u67d0\u4e9b\u7ebf\u7a0b\u53ef\u80fd\u5b88\u5019\u7740\u4e00\u4e2a\u6761\u4ef6\u53d8\u91cf\uff0c\u76f4\u5230\u67d0\u4e2a\u5176\u4ed6\u7684\u7ebf\u7a0b\u7ed9\u8fd9\u4e2a\u6761\u4ef6\u53d8\u91cf\u53d1\u9001\u4e00\u4e2a\u4fe1\u53f7\uff0c\u8fd9\u65f6\u8fd9\u4e9b\u7ebf\u7a0b\u4e2d\u7684\u4e00\u4e2a\u7ebf\u7a0b\u5c31\u4f1a\u82cf\u9192\uff0c\u5904\u7406\u8fd9\u4e2a\u4e8b\u4ef6\u3002\u4f46\u6761\u4ef6\u53d8\u91cf\u4e0d\u63d0\u4f9b\u9501\u5b9a\uff0c\u6240\u4ee5\u5b83\u5fc5\u987b\u4e0e\u4e00\u4e2a\u4e92\u65a5\u91cf\u540c\u65f6\u4f7f\u7528\uff0c\u63d0\u4f9b\u8bbf\u95ee\u8fd9\u4e2a\u73af\u5883\u53d8\u91cf\u65f6\u5fc5\u8981\u7684\u9501\u5b9a\u3002<br \/>3.\u4fe1\u53f7\u91cf<br \/>dijkstra\u63d0\u51fa\u4e86\u4fe1\u53f7\u91cf\u7684\u6982\u5ff5\uff0c\u4fe1\u53f7\u91cf\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u53d8\u91cf\uff0c\u53ea\u53ef\u4ee5\u53d6\u6b63\u6574\u6570\u503c\uff0c\u5bf9\u8fd9\u4e2a\u6b63\u6574\u6570\u53ea\u80fd\u91c7\u53d6\u4e24\u79cd\u64cd\u4f5c\uff1ap\u64cd\u4f5c\uff08\u4ee3\u8868\u7b49\u5f85\uff0c\u5173\u64cd\u4f5c\uff09\u548cv\u64cd\u4f5c\uff08\u4ee3\u8868\u4fe1\u53f7\uff0c\u5f00\u64cd\u4f5c\uff09\u3002<br \/>p\/v\u64cd\u4f5c\u5b9a\u4e49\u5982\u4e0b\uff08\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u4fe1\u53f7\u91cfsem\uff09 \uff1a<br \/>p\uff08sem\uff09\uff1a\u5982\u679csem\u7684\u503c\u5927\u4e8e0\uff0c\u5219sem\u51cf1\uff1b\u5982\u679csem\u7684\u503c\u4e3a0\uff0c\u5219\u6302\u8d77\u8be5\u7ebf\u7a0b\u3002<br \/>v\uff08sem\uff09\uff1a\u5982\u679c\u6709\u5176\u5b83\u8fdb\u7a0b\u56e0\u7b49\u5f85sem\u800c\u6302\u8d77\uff0c\u5219\u8ba9\u5b83\u6062\u590d\u6267\u884c\uff1b\u5982\u679c\u6ca1\u6709\u7ebf\u7a0b\u7b49\u5f85sem\u800c\u88ab\u6302\u8d77\uff0c\u5219sem\u52a0\u4e0a1\u3002<br \/>\u4fe1\u53f7\u96c6\u7684\u521b\u5efa\u4e0e\u6253\u5f00<br \/>int semget(key_t key,int nsems,int flag);<br \/>\u5bf9\u4fe1\u53f7\u91cf\u7684\u64cd\u4f5c<br \/>int semop(int semid,struct sembuf semoparray[],size_t nops);<br \/>\u5bf9\u4fe1\u53f7\u91cf\u7684\u63a7\u5236<br \/>int semctl(int semid,int semnum int cmd,union semun arg);<br \/>\u9644\uff1a\u7ecf\u5178\u7684\u751f\u4ea7\u8005\uff0d\u6d88\u8d39\u8005\u95ee\u9898\uff08producer-costomer\uff09\u662f\u4e00\u4e2a\u8457\u540d\u7684\u540c\u6b65\u95ee\u9898\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300alinux\u591a\u7ebf\u7a0b\u7f16\u7a0b\u7684\u77e5\u8bc6\u70b9\u6709\u54ea\u4e9b\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux\u591a\u7ebf\u7a0b\u7f16\u7a0b\u7684\u77e5\u8bc6\u70b9\u6709\u54ea\u4e9b \u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60\u6587\u7ae0\uff0c\u90a3\u4e48\u672c\u6587\u300alinux\u591a\u7ebf\u7a0b\u7f16\u7a0b\u7684\u77e5\u8bc6\u70b9\u6709\u54ea\u4e9b\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~ linux\u7ebf\u7a0b\u5206\u4e3a\u4e24\u7c7b\uff1a\u4e00\u662f\u6838\u5fc3\u7ea7\u652f\u6301\u7ebf\u7a0b\uff0c\u4e8c\u662f\u7528\u6237\u7ea7\u7684\u7ebf\u7a0b\u3002\u4e00\u822c\u90fd\u4e3a\u7528\u6237\u7ea7\u7684\u7ebf\u7a0b\u3002 \u4e00\u3001\u591a\u7ebf\u7a0b\u7684\u51e0\u4e2a\u5e38\u89c1\u51fd\u6570 \u8981\u521b\u5efa\u591a\u7ebf\u7a0b\u5fc5\u987b\u52a0\u8f7dpthread.h\u6587\u4ef6\uff0c\u5e93\u6587\u4ef6pthread\u3002\u7ebf\u7a0b\u7684\u6807\u8bc6\u7b26pthread_t\u5728\u5934\u6587\u4ef6\/usr\/include\/bits\/pthreadtypes.h\u4e2d\u5b9a\u4e49\uff1atypedef&nbsp; unsigned&nbsp; long&nbsp; int&nbsp; pthread_t 1.\u521b\u5efa\u7ebf\u7a0b: int pthread_create(pthread_t *restrict thread,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const pthread_attr_t *restrict attr,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void *(*start_routine)(void*), void *restrict arg);\u53c2\u6570:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thread\u8f93\u51fa\u7ebf\u7a0bid&nbsp;&nbsp;&nbsp;&nbsp; attr \u7ebf\u7a0b\u5c5e\u6027\uff0c \u9ed8\u8ba4null&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start_routine\u7ebf\u7a0b\u6267\u884c\u51fd\u6570&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arg\u7ebf\u7a0b\u6267\u884c\u53c2\u6570&nbsp;note:\u51fd\u6570\u6210\u529f\u8fd4\u56de0 \u5426\u5219\u8fd4\u56de\u9519\u8bef\u7801 2.\u7b49\u5f85\u6307\u5b9a\u7ebf\u7a0b\u7ed3\u675f: int pthread_join(pthread_t thread,void **value_ptr);\u53c2\u6570:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thread\u4e00\u4e2a\u6709\u6548\u7684\u7ebf\u7a0bid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value_ptr \u63a5\u6536\u7ebf\u7a0b\u8fd4\u56de\u503c\u7684\u6307\u9488note:\u8c03\u7528\u6b64\u51fd\u6570\u7684\u7ebf\u7a0b\u5728\u6307\u5b9a\u7684\u7ebf\u7a0b\u9000\u51fa\u524d\u5c06\u5904\u4e8e\u6302\u8d77\u72b6\u6001\u6216\u51fa\u73b0\u9519\u8bef\u800c\u76f4\u63a5\u8fd4\u56de\uff0c\u5982\u679cvalue_ptr\u975enull\u5219value_ptr\u6307\u5411\u7ebf\u7a0b\u8fd4\u56de\u503c\u7684\u6307\u9488\uff0c\u51fd\u6570\u6210\u529f\u540e\u6307\u5b9a\u7684\u7ebf\u7a0b\u4f7f\u7528\u7684\u8d44\u6e90\u5c06\u88ab\u91ca\u653e\u3002 3.\u9000\u51fa\u7ebf\u7a0b: int pthread_exit(void * value_ptr);\u53c2\u6570:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value_ptr \u7ebf\u7a0b\u8fd4\u56de\u503c\u6307\u9488note: ptrhead_exit()\u9000\u51fa\u8c03\u7528\u6b64\u51fd\u6570\u7684\u7ebf\u7a0b\u5e76\u91ca\u653e\u8be5\u7ebf\u7a0b\u5360\u7528\u7684\u8d44\u6e90\u3002 4.\u83b7\u53d6\u5f53\u524d\u7ebf\u7a0bid: pthread_t pthread_self(void);\u53c2\u6570:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;note:\u8fd4\u56de\u5f53\u524d\u51fd\u6570\u7684id 5.\u4e92\u65a5 \u521b\u5efa\u4e92\u65a5:int pthread_mutex_init(pthread_mutex_t *restrict mutex,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-52281","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52281"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52281\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}