{"id":140,"date":"2015-07-31T16:46:04","date_gmt":"2015-07-31T16:46:04","guid":{"rendered":""},"modified":"2015-07-31T16:46:04","modified_gmt":"2015-07-31T16:46:04","slug":"","status":"publish","type":"post","link":"http:\/\/weizn.net\/?p=140","title":{"rendered":"[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790"},"content":{"rendered":"<p>\n\t<span style=\"font-size:16px;\"><strong>\u6ce8\uff1a\u81ea\u65cb\u9501\u5728\u5355\u6838\u5904\u7406\u5668\u4e0a\u65e0\u6027\u80fd\u63d0\u5347\u3002<\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\"><strong><br \/>\n<\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">\u8f6c\u81ea\uff1a<\/span><a href=\"http:\/\/www.parallellabs.com\/2010\/01\/31\/pthreads-programming-spin-lock-vs-mutex-performance-analysis\/\"><span style=\"font-size:16px;\">http:\/\/www.parallellabs.com\/2010\/01\/31\/pthreads-programming-spin-lock-vs-mutex-performance-analysis\/<\/span><\/a>\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">POSIX threads(\u7b80\u79f0Pthreads)\u662f\u5728\u591a\u6838\u5e73\u53f0\u4e0a\u8fdb\u884c\u5e76\u884c\u7f16\u7a0b\u7684\u4e00\u5957\u5e38\u7528\u7684API\u3002\u7ebf\u7a0b\u540c\u6b65(Thread Synchronization)\u662f\u5e76\u884c\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u901a\u8baf\u624b\u6bb5\uff0c\u5176\u4e2d\u6700\u5178\u578b\u7684\u5e94\u7528\u5c31\u662f\u7528Pthreads\u63d0\u4f9b\u7684\u9501\u673a\u5236(lock)\u6765\u5bf9\u591a\u4e2a\u7ebf\u7a0b\u4e4b\u95f4\u5171 \u4eab\u7684\u4e34\u754c\u533a(Critical Section)\u8fdb\u884c\u4fdd\u62a4(\u53e6\u4e00\u79cd\u5e38\u7528\u7684\u540c\u6b65\u673a\u5236\u662fbarrier)\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">Pthreads\u63d0\u4f9b\u4e86\u591a\u79cd\u9501\u673a\u5236\uff1a<\/span><br \/>\n<span style=\"font-size:16px;\">(1) Mutex\uff08\u4e92\u65a5\u91cf\uff09\uff1apthread_mutex_***<\/span><br \/>\n<span style=\"font-size:16px;\">(2) Spin lock\uff08\u81ea\u65cb\u9501\uff09\uff1apthread_spin_***<\/span><br \/>\n<span style=\"font-size:16px;\">(3) Condition Variable\uff08\u6761\u4ef6\u53d8\u91cf\uff09\uff1apthread_con_***<\/span><br \/>\n<span style=\"font-size:16px;\">(4) Read\/Write lock\uff08\u8bfb\u5199\u9501\uff09\uff1apthread_rwlock_***<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">Pthreads\u63d0\u4f9b\u7684Mutex\u9501\u64cd\u4f5c\u76f8\u5173\u7684API\u4e3b\u8981\u6709\uff1a<\/span><br \/>\n<span style=\"font-size:16px;\">pthread_mutex_lock (pthread_mutex_t *mutex);<\/span><br \/>\n<span style=\"font-size:16px;\">pthread_mutex_trylock (pthread_mutex_t *mutex);<\/span><br \/>\n<span style=\"font-size:16px;\">pthread_mutex_unlock (pthread_mutex_t *mutex);<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">Pthreads\u63d0\u4f9b\u7684\u4e0eSpin Lock\u9501\u64cd\u4f5c\u76f8\u5173\u7684API\u4e3b\u8981\u6709\uff1a<\/span><br \/>\n<span style=\"font-size:16px;\">pthread_spin_lock (pthread_spinlock_t *lock);<\/span><br \/>\n<span style=\"font-size:16px;\">pthread_spin_trylock (pthread_spinlock_t *lock);<\/span><br \/>\n<span style=\"font-size:16px;\">pthread_spin_unlock (pthread_spinlock_t *lock);<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">\u4ece\u5b9e\u73b0\u539f\u7406\u4e0a\u6765\u8bb2\uff0cMutex\u5c5e\u4e8esleep-waiting\u7c7b\u578b\u7684\u9501\u3002\u4f8b\u5982\u5728\u4e00\u4e2a\u53cc\u6838\u7684\u673a\u5668\u4e0a\u6709\u4e24\u4e2a\u7ebf\u7a0b(\u7ebf\u7a0bA\u548c\u7ebf\u7a0bB)\uff0c\u5b83\u4eec\u5206\u522b\u8fd0\u884c\u5728Core0\u548cCore1\u4e0a\u3002\u5047\u8bbe\u7ebf\u7a0bA\u60f3\u8981\u901a\u8fc7pthread_mutex_lock\u64cd\u4f5c\u53bb\u5f97\u5230\u4e00\u4e2a\u4e34\u754c\u533a\u7684\u9501\uff0c\u800c\u6b64\u65f6\u8fd9\u4e2a\u9501\u6b63\u88ab\u7ebf\u7a0bB\u6240\u6301\u6709\uff0c\u90a3\u4e48\u7ebf\u7a0bA\u5c31\u4f1a\u88ab\u963b\u585e(blocking)\uff0cCore0 \u4f1a\u5728\u6b64\u65f6\u8fdb\u884c\u4e0a\u4e0b\u6587\u5207\u6362(Context Switch)\u5c06\u7ebf\u7a0bA\u7f6e\u4e8e\u7b49\u5f85\u961f\u5217\u4e2d\uff0c\u6b64\u65f6Core0\u5c31\u53ef\u4ee5\u8fd0\u884c\u5176\u4ed6\u7684\u4efb\u52a1(\u4f8b\u5982\u53e6\u4e00\u4e2a\u7ebf\u7a0bC)\u800c\u4e0d\u5fc5\u8fdb\u884c\u5fd9\u7b49\u5f85\u3002\u800cSpin lock\u5219\u4e0d\u7136\uff0c\u5b83\u5c5e\u4e8ebusy-waiting\u7c7b\u578b\u7684\u9501\uff0c\u5982\u679c\u7ebf\u7a0bA\u662f\u4f7f\u7528pthread_spin_lock\u64cd\u4f5c\u53bb\u8bf7\u6c42\u9501\uff0c\u90a3\u4e48\u7ebf\u7a0bA\u5c31\u4f1a\u4e00\u76f4\u5728 Core0\u4e0a\u8fdb\u884c\u5fd9\u7b49\u5f85\u5e76\u4e0d\u505c\u7684\u8fdb\u884c\u9501\u8bf7\u6c42\uff0c\u76f4\u5230\u5f97\u5230\u8fd9\u4e2a\u9501\u4e3a\u6b62\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">\u5982\u679c\u5927\u5bb6\u53bb\u67e5\u9605Linux glibc\u4e2d\u5bf9pthreads API\u7684\u5b9e\u73b0NPTL(Native POSIX Thread Library) \u7684\u6e90\u7801\u7684\u8bdd(\u4f7f\u7528\u201dgetconf GNU_LIBPTHREAD_VERSION\u201d\u547d\u4ee4\u53ef\u4ee5\u5f97\u5230\u6211\u4eec\u7cfb\u7edf\u4e2dNPTL\u7684\u7248\u672c\u53f7)\uff0c\u5c31\u4f1a\u53d1\u73b0pthread_mutex_lock()\u64cd\u4f5c\u5982\u679c\u6ca1\u6709\u9501\u6210\u529f\u7684\u8bdd\u5c31\u4f1a\u8c03\u7528system_wait()\u7684\u7cfb\u7edf\u8c03\u7528\uff08\u73b0\u5728NPTL\u7684\u5b9e\u73b0\u91c7\u7528\u4e86\u7528\u6237\u7a7a\u95f4\u7684futex\uff0c\u4e0d\u9700\u8981\u9891\u7e41\u8fdb\u884c\u7cfb\u7edf\u8c03\u7528\uff0c\u6027\u80fd\u5df2\u7ecf\u5927\u6709\u6539\u5584\uff09\uff0c\u5e76\u5c06\u5f53\u524d\u7ebf\u7a0b\u52a0\u5165\u8be5mutex\u7684\u7b49\u5f85\u961f\u5217\u91cc\u3002\u800cspin lock\u5219\u53ef\u4ee5\u7406\u89e3\u4e3a\u5728\u4e00\u4e2awhile(1)\u5faa\u73af\u4e2d\u7528\u5185\u5d4c\u7684\u6c47\u7f16\u4ee3\u7801\u5b9e\u73b0\u7684\u9501\u64cd\u4f5c(\u5370\u8c61\u4e2d\u770b\u8fc7\u4e00\u7bc7\u8bba\u6587\u4ecb\u7ecd\u8bf4\u5728linux\u5185\u6838\u4e2dspin lock\u64cd\u4f5c\u53ea\u9700\u8981\u4e24\u6761CPU\u6307\u4ee4\uff0c\u89e3\u9501\u64cd\u4f5c\u53ea\u7528\u4e00\u6761\u6307\u4ee4\u5c31\u53ef\u4ee5\u5b8c\u6210)\u3002\u6709\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u53e6\u4e00\u4e2a\u540d\u4e3asanos\u7684\u5fae\u5185\u6838\u4e2dpthreds API\u7684\u5b9e\u73b0\uff1amutex.cspinlock.c\uff0c\u5c3d\u7ba1\u4e0eNPTL\u4e2d\u7684\u4ee3\u7801\u5b9e\u73b0\u4e0d\u5c3d\u76f8\u540c\uff0c\u4f46\u662f\u56e0\u4e3a\u5b83\u7684\u5b9e\u73b0\u975e\u5e38\u7b80\u5355\u6613\u61c2\uff0c\u5bf9\u6211\u4eec\u7406\u89e3spin lock\u548cmutex\u7684\u7279\u6027\u8fd8\u662f\u5f88\u6709\u5e2e\u52a9\u7684\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">\u53e6\u5916\u4e00\u4e2a\u503c\u5f97\u6ce8\u610f\u7684\u7ec6\u8282\u662fspin lock\u8017\u8d39\u4e86\u66f4\u591a\u7684user time\u3002\u8fd9\u5c31\u662f\u56e0\u4e3a\u4e24\u4e2a\u7ebf\u7a0b\u5206\u522b\u8fd0\u884c\u5728\u4e24\u4e2a\u6838\u4e0a\uff0c\u5927\u90e8\u5206\u65f6\u95f4\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u80fd\u62ff\u5230\u9501\uff0c\u6240\u4ee5\u53e6\u4e00\u4e2a\u7ebf\u7a0b\u5c31\u4e00\u76f4\u5728\u5b83\u8fd0\u884c\u7684core\u4e0a\u8fdb\u884c\u5fd9\u7b49\u5f85\uff0cCPU\u5360\u7528\u7387\u4e00\u76f4\u662f100%\uff1b\u800cmutex\u5219\u4e0d\u540c\uff0c\u5f53\u5bf9\u9501\u7684\u8bf7\u6c42\u5931\u8d25\u540e\u4e0a\u4e0b\u6587\u5207\u6362\u5c31\u4f1a\u53d1\u751f\uff0c\u8fd9\u6837\u5c31\u80fd\u7a7a\u51fa\u4e00\u4e2a\u6838\u6765\u8fdb\u884c\u522b\u7684\u8fd0\u7b97\u4efb\u52a1\u4e86\u3002\uff08\u5176\u5b9e\u8fd9\u79cd\u4e0a\u4e0b\u6587\u5207\u6362\u5bf9\u5df2\u7ecf\u62ff\u7740\u9501\u7684\u90a3\u4e2a\u7ebf\u7a0b\u6027\u80fd\u4e5f\u662f\u6709\u5f71\u54cd\u7684\uff0c\u56e0\u4e3a\u5f53\u8be5\u7ebf\u7a0b\u91ca\u653e\u8be5\u9501\u65f6\u5b83\u9700\u8981\u901a\u77e5\u64cd\u4f5c\u7cfb\u7edf\u53bb\u5524\u9192\u90a3\u4e9b\u88ab\u963b\u585e\u7684\u7ebf\u7a0b\uff0c\u8fd9\u4e5f\u662f\u989d\u5916\u7684\u5f00\u9500\uff09<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">\u603b\u7ed3<\/span><br \/>\n<span style=\"font-size:16px;\">\uff081\uff09Mutex\u9002\u5408\u5bf9\u9501\u64cd\u4f5c\u975e\u5e38\u9891\u7e41\u7684\u573a\u666f\uff0c\u5e76\u4e14\u5177\u6709\u66f4\u597d\u7684\u9002\u5e94\u6027\u3002\u5c3d\u7ba1\u76f8\u6bd4spin lock\u5b83\u4f1a\u82b1\u8d39\u66f4\u591a\u7684\u5f00\u9500\uff08\u4e3b\u8981\u662f\u4e0a\u4e0b\u6587\u5207\u6362\uff09\uff0c\u4f46\u662f\u5b83\u80fd\u9002\u5408\u5b9e\u9645\u5f00\u53d1\u4e2d\u590d\u6742\u7684\u5e94\u7528\u573a\u666f\uff0c\u5728\u4fdd\u8bc1\u4e00\u5b9a\u6027\u80fd\u7684\u524d\u63d0\u4e0b\u63d0\u4f9b\u66f4\u5927\u7684\u7075\u6d3b\u5ea6\u3002<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">\uff082\uff09spin lock\u7684lock\/unlock\u6027\u80fd\u66f4\u597d(\u82b1\u8d39\u66f4\u5c11\u7684cpu\u6307\u4ee4)\uff0c\u4f46\u662f\u5b83\u53ea\u9002\u5e94\u7528\u4e8e\u4e34\u754c\u533a\u8fd0\u884c\u65f6\u95f4\u5f88\u77ed\u7684\u573a\u666f\u3002\u800c\u5728\u5b9e\u9645\u8f6f\u4ef6\u5f00\u53d1\u4e2d\uff0c\u9664\u975e\u7a0b\u5e8f\u5458\u5bf9\u81ea\u5df1\u7684\u7a0b\u5e8f\u7684\u9501\u64cd\u4f5c\u884c\u4e3a\u975e\u5e38\u7684\u4e86\u89e3\uff0c\u5426\u5219\u4f7f\u7528spin lock\u4e0d\u662f\u4e00\u4e2a\u597d\u4e3b\u610f(\u901a\u5e38\u4e00\u4e2a\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u4e2d\u5bf9\u9501\u7684\u64cd\u4f5c\u6709\u6570\u4ee5\u4e07\u6b21\uff0c\u5982\u679c\u5931\u8d25\u7684\u9501\u64cd\u4f5c(contended lock requests)\u8fc7\u591a\u7684\u8bdd\u5c31\u4f1a\u6d6a\u8d39\u5f88\u591a\u7684\u65f6\u95f4\u8fdb\u884c\u7a7a\u7b49\u5f85)\u3002<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:16px;\">\uff083\uff09\u66f4\u4fdd\u9669\u7684\u65b9\u6cd5\u6216\u8bb8\u662f\u5148\uff08\u4fdd\u5b88\u7684\uff09\u4f7f\u7528 Mutex\uff0c\u7136\u540e\u5982\u679c\u5bf9\u6027\u80fd\u8fd8\u6709\u8fdb\u4e00\u6b65\u7684\u9700\u6c42\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528spin lock\u8fdb\u884c\u8c03\u4f18\u3002\u6bd5\u7adf\u6211\u4eec\u7684\u7a0b\u5e8f\u4e0d\u50cfLinux kernel\u90a3\u6837\u5bf9\u6027\u80fd\u9700\u6c42\u90a3\u4e48\u9ad8(Linux Kernel\u6700\u5e38\u7528\u7684\u9501\u64cd\u4f5c\u662fspin lock\u548crw lock)\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p style=\"border-bottom:0px;border-left:0px;padding-bottom:0px;widows:1;text-transform:none;background-color:#ffffff;text-indent:0px;margin:0px 0px 1.68em;outline-style:none;outline-color:invert;padding-left:0px;outline-width:0px;letter-spacing:normal;padding-right:0px;font:19px\/31px 'Noto Serif', serif;white-space:normal;color:#333333;vertical-align:baseline;border-top:0px;border-right:0px;word-spacing:0px;padding-top:0px;-webkit-text-stroke-width:0px;\">\n\t<span style=\"font-size:16px;\">\u8f6c\u81ea\uff1a<\/span><a href=\"http:\/\/www.parallellabs.com\/2010\/01\/31\/pthreads-programming-spin-lock-vs-mutex-performance-analysis\/\"><span style=\"font-size:16px;\">http:\/\/www.parallellabs.com\/2010\/01\/31\/pthreads-programming-spin-lock-vs-mutex-performance-analysis\/<\/span><\/a>\n<\/p>\n<p style=\"border-bottom:0px;border-left:0px;padding-bottom:0px;widows:1;text-transform:none;background-color:#ffffff;text-indent:0px;margin:0px 0px 1.68em;outline-style:none;outline-color:invert;padding-left:0px;outline-width:0px;letter-spacing:normal;padding-right:0px;font:19px\/31px 'Noto Serif', serif;white-space:normal;color:#333333;vertical-align:baseline;border-top:0px;border-right:0px;word-spacing:0px;padding-top:0px;-webkit-text-stroke-width:0px;\">\n\t<span style=\"font-size:16px;\">POSIX threads(\u7b80\u79f0Pthreads)\u662f\u5728\u591a\u6838\u5e73\u53f0\u4e0a\u8fdb\u884c\u5e76\u884c\u7f16\u7a0b\u7684\u4e00\u5957\u5e38\u7528\u7684API\u3002\u7ebf\u7a0b\u540c\u6b65(Thread Synchronization)\u662f\u5e76\u884c\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u901a\u8baf\u624b\u6bb5\uff0c\u5176\u4e2d\u6700\u5178\u578b&#8230;<\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[332],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790 - Wayne&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/weizn.net\/?p=140\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790 - Wayne&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"\u8f6c\u81ea\uff1ahttp:\/\/www.parallellabs.com\/2010\/01\/31\/pthreads-programming-spin-lock-vs-mutex-performance-analysis\/    POSIX threads(\u7b80\u79f0Pthreads)\u662f\u5728\u591a\u6838\u5e73\u53f0\u4e0a\u8fdb\u884c\u5e76\u884c\u7f16\u7a0b\u7684\u4e00\u5957\u5e38\u7528\u7684API\u3002\u7ebf\u7a0b\u540c\u6b65(Thread Synchronization)\u662f\u5e76\u884c\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u901a\u8baf\u624b\u6bb5\uff0c\u5176\u4e2d\u6700\u5178\u578b...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/weizn.net\/?p=140\" \/>\n<meta property=\"og:site_name\" content=\"Wayne&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-31T16:46:04+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"zinan\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/weizn.net\/#website\",\"url\":\"http:\/\/weizn.net\/\",\"name\":\"Wayne&#039;s Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/weizn.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/weizn.net\/?p=140#webpage\",\"url\":\"http:\/\/weizn.net\/?p=140\",\"name\":\"[\\u8f6c]Pthreads\\u5e76\\u884c\\u7f16\\u7a0b\\u4e4bspin lock\\u4e0emutex\\u6027\\u80fd\\u5bf9\\u6bd4\\u5206\\u6790 - Wayne&#039;s Blog\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/#website\"},\"datePublished\":\"2015-07-31T16:46:04+00:00\",\"dateModified\":\"2015-07-31T16:46:04+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/weizn.net\/?p=140#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/weizn.net\/?p=140\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/weizn.net\/?p=140#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\\u9996\\u9875\",\"item\":\"http:\/\/weizn.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[\\u8f6c]Pthreads\\u5e76\\u884c\\u7f16\\u7a0b\\u4e4bspin lock\\u4e0emutex\\u6027\\u80fd\\u5bf9\\u6bd4\\u5206\\u6790\"}]},{\"@type\":\"Article\",\"@id\":\"http:\/\/weizn.net\/?p=140#article\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/?p=140#webpage\"},\"author\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"headline\":\"[\\u8f6c]Pthreads\\u5e76\\u884c\\u7f16\\u7a0b\\u4e4bspin lock\\u4e0emutex\\u6027\\u80fd\\u5bf9\\u6bd4\\u5206\\u6790\",\"datePublished\":\"2015-07-31T16:46:04+00:00\",\"dateModified\":\"2015-07-31T16:46:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/weizn.net\/?p=140#webpage\"},\"wordCount\":192,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/weizn.net\/?p=140#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\",\"name\":\"zinan\",\"logo\":{\"@id\":\"http:\/\/weizn.net\/#personlogo\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790 - Wayne&#039;s Blog","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":"http:\/\/weizn.net\/?p=140","og_locale":"zh_CN","og_type":"article","og_title":"[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790 - Wayne&#039;s Blog","og_description":"\u8f6c\u81ea\uff1ahttp:\/\/www.parallellabs.com\/2010\/01\/31\/pthreads-programming-spin-lock-vs-mutex-performance-analysis\/    POSIX threads(\u7b80\u79f0Pthreads)\u662f\u5728\u591a\u6838\u5e73\u53f0\u4e0a\u8fdb\u884c\u5e76\u884c\u7f16\u7a0b\u7684\u4e00\u5957\u5e38\u7528\u7684API\u3002\u7ebf\u7a0b\u540c\u6b65(Thread Synchronization)\u662f\u5e76\u884c\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u901a\u8baf\u624b\u6bb5\uff0c\u5176\u4e2d\u6700\u5178\u578b...","og_url":"http:\/\/weizn.net\/?p=140","og_site_name":"Wayne&#039;s Blog","article_published_time":"2015-07-31T16:46:04+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"zinan","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/weizn.net\/#website","url":"http:\/\/weizn.net\/","name":"Wayne&#039;s Blog","description":"","publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/weizn.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/weizn.net\/?p=140#webpage","url":"http:\/\/weizn.net\/?p=140","name":"[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790 - Wayne&#039;s Blog","isPartOf":{"@id":"http:\/\/weizn.net\/#website"},"datePublished":"2015-07-31T16:46:04+00:00","dateModified":"2015-07-31T16:46:04+00:00","breadcrumb":{"@id":"http:\/\/weizn.net\/?p=140#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/weizn.net\/?p=140"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/weizn.net\/?p=140#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/weizn.net\/"},{"@type":"ListItem","position":2,"name":"[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790"}]},{"@type":"Article","@id":"http:\/\/weizn.net\/?p=140#article","isPartOf":{"@id":"http:\/\/weizn.net\/?p=140#webpage"},"author":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"headline":"[\u8f6c]Pthreads\u5e76\u884c\u7f16\u7a0b\u4e4bspin lock\u4e0emutex\u6027\u80fd\u5bf9\u6bd4\u5206\u6790","datePublished":"2015-07-31T16:46:04+00:00","dateModified":"2015-07-31T16:46:04+00:00","mainEntityOfPage":{"@id":"http:\/\/weizn.net\/?p=140#webpage"},"wordCount":192,"commentCount":0,"publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"articleSection":["Linux"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/weizn.net\/?p=140#respond"]}]},{"@type":["Person","Organization"],"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264","name":"zinan","logo":{"@id":"http:\/\/weizn.net\/#personlogo"}}]}},"_links":{"self":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=140"}],"version-history":[{"count":0,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"wp:attachment":[{"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}