{"id":8454,"date":"2025-02-10T08:48:42","date_gmt":"2025-02-10T08:48:42","guid":{"rendered":"https:\/\/howtogeek.blog\/zh\/?p=8454"},"modified":"2025-02-10T08:48:42","modified_gmt":"2025-02-10T08:48:42","slug":"resolution-for-error-no-yield-performed-721-0x2d1-follow-these-4-step-guide","status":"publish","type":"post","link":"https:\/\/howtogeek.blog\/zh\/resolution-for-error-no-yield-performed-721-0x2d1-follow-these-4-step-guide\/","title":{"rendered":"\u89e3\u6c7a\u932f\u8aa4 No Yield Performed 721 (0x2D1)\uff1a\u8acb\u9075\u5faa\u4ee5\u4e0b 4 \u6b65\u9a5f\u6307\u5357"},"content":{"rendered":"<p><strong>ERROR_NO_YIELD_PERFORMED<\/strong>\u554f\u984c\u7d93\u5e38\u56f0\u64fe\u958b\u767c\u4eba\u54e1\uff0c\u64fe\u4e82\u4ed6\u5011\u7684\u7a0b\u5f0f\u78bc\u57f7\u884c\u6d41\u7a0b\u3002\u8b93\u6211\u5011\u6df1\u5165\u7814\u7a76\u6392\u9664\u6545\u969c\u4e26\u89e3\u6c7a\u6b64\u6280\u8853\u969c\u7919\u7684\u6709\u6548\u7b56\u7565\u3002\u4e86\u89e3\u6839\u672c\u539f\u56e0\u5c0d\u65bc\u6539\u5584 C++ \u4e2d\u7684\u57f7\u884c\u7dd2\u7ba1\u7406\u548c\u78ba\u4fdd\u9806\u66a2\u7684\u958b\u767c\u9ad4\u9a57\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<h2 id=\"h-how-can-i-fix-error-no-yield-performed\">\u5982\u4f55\u4fee\u5fa9 ERROR_NO_YIELD_PERFORMED<\/h2>\n<h3 id=\"h-1-check-thread-priority\">1.\u8a55\u4f30\u4e26\u8abf\u6574\u7dda\u7a0b\u512a\u5148\u7d1a<\/h3>\n<ul>\n<li>\u9996\u5148\u6aa2\u67e5\u7a0b\u5f0f\u78bc\u5eab\u4e2d\u7684\u57f7\u884c\u7dd2\u7ba1\u7406\u5be6\u4f5c\u3002<\/li>\n<li>\u5982\u679c\u60a8\u4f7f\u7528 Windows API\uff0c\u8acb\u8abf\u6574\u57f7\u884c\u7dd2\u512a\u5148\u6b0a\uff1a<br \/>\n<blockquote>\n<p> <code><strong>SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);<\/strong><\/code><\/p>\n<\/blockquote>\n<\/li>\n<li>\u5728\u9700\u8981\u66f4\u9ad8\u56de\u61c9\u80fd\u529b\u7684\u60c5\u6cc1\u4e0b\uff0c\u8acb\u8003\u616e\u63d0\u9ad8\u512a\u5148\u9806\u5e8f\uff1a<br \/>\n<blockquote>\n<p> <code><strong>SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL);<\/strong><\/code><\/p>\n<\/blockquote>\n<\/li>\n<li>\u59cb\u7d42\u6aa2\u67e5\u66f4\u6539\u57f7\u884c\u7dd2\u512a\u5148\u6b0a\u7684\u542b\u7fa9\uff0c\u56e0\u70ba\u9019\u6a23\u505a\u53ef\u80fd\u6703\u5f71\u97ff\u5176\u4ed6\u884c\u7a0b\u7684\u6548\u80fd\u3002<\/li>\n<\/ul>\n<h3 id=\"h-2-avoid-using-unnecessary-sleep-calls\">2.\u76e1\u91cf\u6e1b\u5c11\u4e0d\u5fc5\u8981\u7684\u7761\u7720\u96fb\u8a71<\/h3>\n<ul>\n<li>\u6253\u958b\u4f60\u7684\u4e3b\u4ee3\u78bc\u6bb5\u3002<\/li>\n<li>\u5c0b\u627e\u5be6\u4f8b<code><strong>Sleep(0);<\/strong><\/code>\u4e26\u5c07\u5176\u66ff\u63db\u70ba<strong>Sleep(1)\uff1b<\/strong><\/li>\n<li>\u660e\u667a\u5730\u5be6\u65bd<code><strong>SwitchToThread();<\/strong><\/code>\uff0c\u78ba\u4fdd\u4f7f\u7528\u5982\u4e0b\u7684\u5f8c\u5099\u6a5f\u5236\uff1a<br \/>\n<blockquote>\n<p> <code><strong>if (!SwitchToThread()) { Sleep(1); \/\/ Fallback if no threads are waiting }<\/strong><\/code><\/p>\n<\/blockquote>\n<\/li>\n<li>\u9032\u884c\u8abf\u6574\u5f8c\uff0c\u91cd\u65b0\u7de8\u8b6f\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u4ee5\u8a55\u4f30\u932f\u8aa4\u89e3\u6c7a\u60c5\u6cc1\u3002<\/li>\n<\/ul>\n<h3 id=\"h-3-verify-thread-availability\">3.\u78ba\u8a8d\u7dda\u7a0b\u53ef\u7528\u6027<\/h3>\n<ul>\n<li>\u9996\u5148\u6aa2\u67e5\u60a8\u7684\u7a0b\u5f0f\u78bc\u4f86\u8ffd\u8e64\u6240\u6709\u7dda\u7a0b\u7684\u4f7f\u7528\u60c5\u6cc1\u3002<\/li>\n<li>\u5982\u679c\u4f7f\u7528 C++ \u57f7\u884c\u7dd2\u6c60\uff0c\u8acb\u900f\u904e\u6aa2\u67e5\u78ba\u4fdd\u5176\u6c92\u6709\u8d85\u51fa\u5bb9\u91cf\uff1a<br \/>\n<blockquote>\n<p> <code><strong>std::thread::hardware_concurrency();<\/strong><\/code><\/p>\n<\/blockquote>\n<\/li>\n<li>\u5617\u8a66\u589e\u52a0\u53ef\u7528\u7dda\u7a0b\u7684\u6578\u91cf\u4e26\u8a55\u4f30\u6b64\u4fee\u6539\u662f\u5426\u80fd\u7de9\u89e3\u8a72\u554f\u984c\u3002<\/li>\n<\/ul>\n<h3 id=\"h-4-other-tips-to-try\">4.\u5176\u4ed6\u6545\u969c\u6392\u9664\u5efa\u8b70<\/h3>\n<ul>\n<li>\u78ba\u4fdd\u60a8\u7684\u4f5c\u696d\u7cfb\u7d71\u548c\u9a45\u52d5\u7a0b\u5f0f\u5df2\u66f4\u65b0\u81f3\u6700\u65b0\u7248\u672c\u3002<\/li>\n<li>\u900f\u904e\u4efb\u52d9\u7ba1\u7406\u5668\u5206\u6790\u8cc7\u6e90\u6d88\u8017\u3002\u900f\u904e\u95dc\u9589\u4e0d\u5fc5\u8981\u7684\u61c9\u7528\u7a0b\u5f0f\u4f86\u6e1b\u5c11\u5de5\u4f5c\u91cf\u53ef\u4ee5\u91cb\u653e\u91cd\u8981\u8cc7\u6e90\u3002<\/li>\n<li>\u5229\u7528<strong>\u884c\u7a0b\u8cc7\u6e90\u7ba1\u7406\u5668<\/strong>\u5c0d\u5361\u4f4f\u6216\u963b\u585e\u7684\u57f7\u884c\u7dd2\u9032\u884c\u6df1\u5165\u8a55\u4f30\u3002<\/li>\n<li>\u5229\u7528<strong>Windows \u6548\u80fd\u5206\u6790\u5668<\/strong>\u57f7\u884c\u8a73\u7d30\u8ffd\u8e64\u4e26\u8a55\u4f30 CPU \u8abf\u5ea6\u6548\u7387\u3002<\/li>\n<li>\u7d50\u5408<strong>GetLastError()<\/strong>\u4f86\u8a18\u9304\u554f\u984c\u4e26\u6536\u96c6\u932f\u8aa4\u5831\u544a\u7684\u66f4\u591a\u80cc\u666f\u8cc7\u8a0a\u3002<\/li>\n<\/ul>\n<p>\u7559\u610f<strong>ERROR_NO_YIELD_PERFORMED<\/strong>\u7a0b\u5f0f\u78bc\uff0c\u901a\u5e38\u7531\u985e\u4f3c\u300c721 (0x2D1) \u5df2\u57f7\u884c\u5c48\u670d\u57f7\u884c\u4e14\u6c92\u6709\u53ef\u904b\u884c\u7684\u57f7\u884c\u7dd2\u300d\u4e4b\u985e\u7684\u8a0a\u606f\u8868\u793a\u3002\u53ca\u6642\u89e3\u6c7a\u9019\u4e9b\u932f\u8aa4\u5c0d\u65bc\u63d0\u9ad8\u61c9\u7528\u7a0b\u5f0f\u7684\u6548\u80fd\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<h2>\u5e38\u898b\u554f\u984c<\/h2>\n<h3><strong>1. ERROR_NO_YIELD_PERFORMED\u8868\u793a\u4ec0\u9ebc\uff1f<\/strong><\/h3>\n<p>\u7576\u4e00\u500b\u57f7\u884c\u7dd2\u653e\u68c4\u57f7\u884c\u4f46\u6c92\u6709\u5176\u4ed6\u57f7\u884c\u7dd2\u53ef\u904b\u884c\u6642\uff0c\u6703\u767c\u751f<strong>ERROR_NO_YIELD_PERFORMED<\/strong>\uff0c\u9019\u8868\u793a\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u4e2d\u53ef\u80fd\u5b58\u5728\u8cc7\u6e90\u7ba1\u7406\u554f\u984c\u3002<\/p>\n<h3><strong>2.\u57f7\u884c\u7dd2\u512a\u5148\u6b0a\u5982\u4f55\u5f71\u97ff\u6211\u7684\u61c9\u7528\u7a0b\u5f0f\u7684\u6548\u80fd\uff1f<\/strong><\/h3>\n<p>\u57f7\u884c\u7dd2\u512a\u5148\u6b0a\u5f71\u97ff\u4f5c\u696d\u7cfb\u7d71\u5982\u4f55\u5728\u7af6\u722d\u57f7\u884c\u7dd2\u4e4b\u9593\u5206\u914d\u8cc7\u6e90\u3002\u8abf\u6574\u57f7\u884c\u7dd2\u512a\u5148\u6b0a\u53ef\u4ee5\u589e\u5f37\u95dc\u9375\u884c\u7a0b\u7684\u56de\u61c9\u80fd\u529b\uff0c\u4f46\u5fc5\u9808\u8b39\u614e\u7ba1\u7406\uff0c\u4ee5\u907f\u514d\u4f4e\u512a\u5148\u6b0a\u57f7\u884c\u7dd2\u6328\u9913\u3002<\/p>\n<h3><strong>3.\u4ec0\u9ebc\u6642\u5019\u61c9\u8a72\u4f7f\u7528 SwitchToThread() \u800c\u4e0d\u662f Sleep()\uff1f<\/strong><\/h3>\n<p>\u7576\u60a8\u60f3\u8981\u81ea\u9858\u5c07 CPU \u4ea4\u7d66\u5176\u4ed6\u8a08\u5283\u904b\u884c\u7684\u57f7\u884c\u7dd2\u6642\uff0c\u8acb\u4f7f\u7528<strong>SwitchToThread()<\/strong> \u3002\u76f8\u53cd\uff0c\u7576\u60a8\u60f3\u8981\u66ab\u505c\u76ee\u524d\u57f7\u884c\u7dd2\u6307\u5b9a\u7684\u6642\u9593\u6642\uff0c\u8acb\u4f7f\u7528<strong>Sleep()<\/strong> \u3002\u907f\u514d\u4f7f\u7528 Sleep(0)\uff0c\u56e0\u70ba\u5b83\u53ef\u80fd\u5c0e\u81f4\u4e0d\u5fc5\u8981\u7684\u4e0a\u4e0b\u6587\u5207\u63db\u3002<\/p>\n<p><a class=\"xiaomi\" href=\"https:\/\/windowsreport.com\/error-no-yield-performed\/\" rel=\"noopener noreferrer nofollow\" target=\"_blank\">\u4f86\u6e90\u548c\u5716\u7247<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ERROR_NO_YIELD_PERFORMED\u554f\u984c\u7d93\u5e38\u56f0\u64fe\u958b\u767c\u4eba\u54e1\uff0c\u64fe\u4e82\u4ed6\u5011\u7684\u7a0b\u5f0f\u78bc\u57f7\u884c\u6d41\u7a0b\u3002\u8b93\u6211\u5011\u6df1\u5165\u7814\u7a76\u6392\u9664\u6545\u969c\u4e26\u89e3\u6c7a\u6b64\u6280\u8853\u969c\u7919\u7684\u6709\u6548\u7b56\u7565\u3002\u4e86\u89e3\u6839\u672c\u539f\u56e0\u5c0d\u65bc\u6539\u5584 C++ \u4e2d\u7684\u57f7\u884c\u7dd2\u7ba1\u7406\u548c\u78ba\u4fdd\u9806\u66a2\u7684\u958b\u767c\u9ad4\u9a57\u81f3\u95dc\u91cd\u8981\u3002 \u5982\u4f55\u4fee\u5fa9 ERROR_NO_YIELD_PERFORMED 1.\u8a55\u4f30\u4e26\u8abf\u6574\u7dda\u7a0b\u512a\u5148\u7d1a \u9996\u5148\u6aa2\u67e5\u7a0b\u5f0f\u78bc\u5eab\u4e2d\u7684\u57f7\u884c\u7dd2\u7ba1\u7406\u5be6\u4f5c\u3002 \u5982\u679c\u60a8\u4f7f\u7528 Windows API\uff0c\u8acb\u8abf\u6574\u57f7\u884c\u7dd2\u512a\u5148\u6b0a\uff1a SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL); \u5728\u9700\u8981\u66f4\u9ad8\u56de\u61c9\u80fd\u529b\u7684\u60c5\u6cc1\u4e0b\uff0c\u8acb\u8003\u616e\u63d0\u9ad8\u512a\u5148\u9806\u5e8f\uff1a SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL); \u59cb\u7d42\u6aa2\u67e5\u66f4\u6539\u57f7\u884c\u7dd2\u512a\u5148\u6b0a\u7684\u542b\u7fa9\uff0c\u56e0\u70ba\u9019\u6a23\u505a\u53ef\u80fd\u6703\u5f71\u97ff\u5176\u4ed6\u884c\u7a0b\u7684\u6548\u80fd\u3002 2.\u76e1\u91cf\u6e1b\u5c11\u4e0d\u5fc5\u8981\u7684\u7761\u7720\u96fb\u8a71 \u6253\u958b\u4f60\u7684\u4e3b\u4ee3\u78bc\u6bb5\u3002 \u5c0b\u627e\u5be6\u4f8bSleep(0);\u4e26\u5c07\u5176\u66ff\u63db\u70baSleep(1)\uff1b \u660e\u667a\u5730\u5be6\u65bdSwitchToThread();\uff0c\u78ba\u4fdd\u4f7f\u7528\u5982\u4e0b\u7684\u5f8c\u5099\u6a5f\u5236\uff1a if (!SwitchToThread()) { Sleep(1); \/\/ Fallback if no threads are waiting } \u9032\u884c\u8abf\u6574\u5f8c\uff0c\u91cd\u65b0\u7de8\u8b6f\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u4ee5\u8a55\u4f30\u932f\u8aa4\u89e3\u6c7a\u60c5\u6cc1\u3002 3.\u78ba\u8a8d\u7dda\u7a0b\u53ef\u7528\u6027 \u9996\u5148\u6aa2\u67e5\u60a8\u7684\u7a0b\u5f0f\u78bc\u4f86\u8ffd\u8e64\u6240\u6709\u7dda\u7a0b\u7684\u4f7f\u7528\u60c5\u6cc1\u3002 \u5982\u679c\u4f7f\u7528 C++ \u57f7\u884c\u7dd2\u6c60\uff0c\u8acb\u900f\u904e\u6aa2\u67e5\u78ba\u4fdd\u5176\u6c92\u6709\u8d85\u51fa\u5bb9\u91cf\uff1a std::thread::hardware_concurrency(); \u5617\u8a66\u589e\u52a0\u53ef\u7528\u7dda\u7a0b\u7684\u6578\u91cf\u4e26\u8a55\u4f30\u6b64\u4fee\u6539\u662f\u5426\u80fd\u7de9\u89e3\u8a72\u554f\u984c\u3002 4.\u5176\u4ed6\u6545\u969c\u6392\u9664\u5efa\u8b70 \u78ba\u4fdd\u60a8\u7684\u4f5c\u696d\u7cfb\u7d71\u548c\u9a45\u52d5\u7a0b\u5f0f\u5df2\u66f4\u65b0\u81f3\u6700\u65b0\u7248\u672c\u3002 \u900f\u904e\u4efb\u52d9\u7ba1\u7406\u5668\u5206\u6790\u8cc7\u6e90\u6d88\u8017\u3002\u900f\u904e\u95dc\u9589\u4e0d\u5fc5\u8981\u7684\u61c9\u7528\u7a0b\u5f0f\u4f86\u6e1b\u5c11\u5de5\u4f5c\u91cf\u53ef\u4ee5\u91cb\u653e\u91cd\u8981\u8cc7\u6e90\u3002 \u5229\u7528\u884c\u7a0b\u8cc7\u6e90\u7ba1\u7406\u5668\u5c0d\u5361\u4f4f\u6216\u963b\u585e\u7684\u57f7\u884c\u7dd2\u9032\u884c\u6df1\u5165\u8a55\u4f30\u3002 \u5229\u7528Windows \u6548\u80fd\u5206\u6790\u5668\u57f7\u884c\u8a73\u7d30\u8ffd\u8e64\u4e26\u8a55\u4f30 CPU \u8abf\u5ea6\u6548\u7387\u3002 \u7d50\u5408GetLastError()\u4f86\u8a18\u9304\u554f\u984c\u4e26\u6536\u96c6\u932f\u8aa4\u5831\u544a\u7684\u66f4\u591a\u80cc\u666f\u8cc7\u8a0a\u3002 \u7559\u610fERROR_NO_YIELD_PERFORMED\u7a0b\u5f0f\u78bc\uff0c\u901a\u5e38\u7531\u985e\u4f3c\u300c721 (0x2D1) \u5df2\u57f7\u884c\u5c48\u670d\u57f7\u884c\u4e14\u6c92\u6709\u53ef\u904b\u884c\u7684\u57f7\u884c\u7dd2\u300d\u4e4b\u985e\u7684\u8a0a\u606f\u8868\u793a\u3002\u53ca\u6642\u89e3\u6c7a\u9019\u4e9b\u932f\u8aa4\u5c0d\u65bc\u63d0\u9ad8\u61c9\u7528\u7a0b\u5f0f\u7684\u6548\u80fd\u81f3\u95dc\u91cd\u8981\u3002 \u5e38\u898b\u554f\u984c 1. ERROR_NO_YIELD_PERFORMED\u8868\u793a\u4ec0\u9ebc\uff1f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6],"class_list":["post-8454","post","type-post","status-publish","format-standard","hentry","category-how-to","tag-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts\/8454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/comments?post=8454"}],"version-history":[{"count":1,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts\/8454\/revisions"}],"predecessor-version":[{"id":8455,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts\/8454\/revisions\/8455"}],"wp:attachment":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/media?parent=8454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/categories?post=8454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/tags?post=8454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}