{"id":115285,"date":"2026-10-11T19:56:55","date_gmt":"2026-10-11T11:56:55","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115285.html"},"modified":"2026-10-11T19:56:55","modified_gmt":"2026-10-11T11:56:55","slug":"freertos-%e4%bf%a1%e5%8f%b7%e9%87%8f%e3%80%81%e9%98%9f%e5%88%97%e4%b8%8e%e5%86%85%e5%ad%98%e5%88%86%e9%85%8d%e7%9a%84%e6%9c%ac%e8%b4%a8%e5%85%b3%e7%b3%bb-%e4%bb%8e%e5%a0%86%e5%8c%ba","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115285.html","title":{"rendered":"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790"},"content":{"rendered":"<h2>FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790<\/h2>\n<h3>\u5f15\u8a00<\/h3>\n<p>\u5982\u679c\u4f60\u5b66\u8fc7\u5355\u7247\u673a&#xff0c;\u5199\u8fc7 C \u8bed\u8a00&#xff0c;\u77e5\u9053\u4ec0\u4e48\u662f int\u3001\u4ec0\u4e48\u662f\u6307\u9488\u3001\u4ec0\u4e48\u662f\u7ed3\u6784\u4f53&#xff0c;\u4f46\u4e00\u542c\u5230&#034;RTOS&#034;\u201c\u4fe1\u53f7\u91cf\u201d\u201c\u5806\u533a\u201d&#034;\u9759\u6001\u521b\u5efa&#034;\u5c31\u6709\u70b9\u53d1\u6035\u2014\u2014\u8fd9\u7bc7\u6587\u7ae0\u5c31\u662f\u4e3a\u4f60\u5199\u7684\u3002<\/p>\n<p>\u6211\u4eec\u4e0d\u5806\u780c\u672f\u8bed&#xff0c;\u4e0d\u5047\u8bbe\u4f60\u61c2\u64cd\u4f5c\u7cfb\u7edf\u3002\u6211\u4eec\u4ece\u4f60\u6700\u719f\u6089\u7684 C \u8bed\u8a00\u548c\u5355\u7247\u673a\u5185\u5b58\u6a21\u578b\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u628a FreeRTOS \u91cc\u90a3\u4e9b&#034;\u542c\u8d77\u6765\u5f88\u7384&#034;\u7684\u6982\u5ff5&#xff0c;\u8fd8\u539f\u6210\u4f60\u65e9\u5c31\u77e5\u9053\u7684\u4e1c\u897f\u3002<\/p>\n<p>\u8bfb\u5b8c\u8fd9\u7bc7&#xff0c;\u4f60\u4f1a\u771f\u6b63\u7406\u89e3&#xff1a;<\/p>\n<ul>\n<li>\u4fe1\u53f7\u91cf\u5230\u5e95\u662f\u4e2a\u4ec0\u4e48\u4e1c\u897f&#xff1f;\u5b83\u4f4f\u5728\u5185\u5b58\u7684\u54ea\u91cc&#xff1f;<\/li>\n<li>\u4e3a\u4ec0\u4e48&#034;\u521b\u5efa&#034;\u7684\u65f6\u5019\u8981\u5206\u914d\u5185\u5b58&#xff0c;\u800c&#034;\u53d1\u9001\/\u63a5\u6536&#034;\u7684\u65f6\u5019\u5374\u4e0d\u7528&#xff1f;<\/li>\n<li>\u52a8\u6001\u521b\u5efa\u548c\u9759\u6001\u521b\u5efa\u5230\u5e95\u5dee\u5728\u54ea&#xff1f;\u6211\u8be5\u9009\u54ea\u4e2a&#xff1f;<\/li>\n<li>\u53e5\u67c4\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u968f\u4fbf\u653e&#xff1f;\u653e\u9519\u4e86\u4f1a\u51fa\u4ec0\u4e48\u4e8b&#xff1f;<\/li>\n<li>\u4e3a\u4ec0\u4e48\u6c7d\u8f66\u3001\u533b\u7597\u8fd9\u4e9b\u884c\u4e1a&#034;\u7981\u6b62\u7528\u5806&#034;&#xff1f;<\/li>\n<\/ul>\n<p>\u6211\u4eec\u5f00\u59cb\u3002<\/p>\n<h3>\u7b2c\u4e00\u90e8\u5206&#xff1a;\u5148\u56de\u5fc6\u4e00\u4e0b\u5355\u7247\u673a\u7684\u5185\u5b58\u957f\u4ec0\u4e48\u6837<\/h3>\n<p>\u5728\u5b66 C \u8bed\u8a00\u7684\u65f6\u5019&#xff0c;\u4f60\u53ef\u80fd\u542c\u8fc7\u8fd9\u51e0\u4e2a\u8bcd&#xff1a;\u6808\u533a\u3001\u5806\u533a\u3001\u5168\u5c40\u533a\u3001\u9759\u6001\u533a\u3001\u5e38\u91cf\u533a\u3001\u4ee3\u7801\u533a\u3002\u5982\u679c\u4f60\u7528\u7684\u662f STM32 \u8fd9\u7c7b\u5355\u7247\u673a&#xff0c;\u4f60\u7684\u7a0b\u5e8f\u70e7\u8fdb\u53bb\u4e4b\u540e&#xff0c;\u5185\u5b58\u5927\u6982\u662f\u8fd9\u6837\u5206\u5e03\u7684&#xff1a;<\/p>\n<p>\u9ad8\u5730\u5740<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502     \u6808\u533a Stack   \u2502  \u2190 \u5c40\u90e8\u53d8\u91cf\u3001\u51fd\u6570\u8c03\u7528\u73b0\u573a&#xff0c;\u5411\u4e0b\u751f\u957f<br \/>\n\u2502        \u2193         \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502        \u2191         \u2502<br \/>\n\u2502     \u5806\u533a Heap    \u2502  \u2190 malloc\/free \u4ece\u8fd9\u91cc\u8981\u5185\u5b58&#xff0c;\u5411\u4e0a\u751f\u957f<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502   .bss \u6bb5        \u2502  \u2190 \u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\/\u9759\u6001\u53d8\u91cf&#xff08;\u8fd0\u884c\u65f6\u6e05\u96f6&#xff09;<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502   .data \u6bb5       \u2502  \u2190 \u5df2\u521d\u59cb\u5316\u7684\u5168\u5c40\/\u9759\u6001\u53d8\u91cf<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502   .rodata \u6bb5     \u2502  \u2190 \u5e38\u91cf\u3001\u5b57\u7b26\u4e32\u5b57\u9762\u91cf<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502   .text \u6bb5       \u2502  \u2190 \u4f60\u7684\u4ee3\u7801<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n\u4f4e\u5730\u5740<\/p>\n<p>\u5173\u952e\u533a\u522b&#xff0c;\u4f60\u4e00\u5b9a\u8981\u8bb0\u4f4f&#xff1a;<\/p>\n<table>\n<tr>\u533a\u57df\u8c01\u5728\u7528\u751f\u547d\u5468\u671f\u5206\u914d\u65f6\u673a<\/tr>\n<tbody>\n<tr>\n<td>\u6808\u533a<\/td>\n<td>\u5c40\u90e8\u53d8\u91cf\u3001\u51fd\u6570\u53c2\u6570<\/td>\n<td>\u51fd\u6570\u9000\u51fa\u5c31\u6ca1\u4e86<\/td>\n<td>\u7f16\u8bd1\u671f\u786e\u5b9a&#xff0c;\u8fd0\u884c\u65f6\u81ea\u52a8<\/td>\n<\/tr>\n<tr>\n<td>\u5806\u533a<\/td>\n<td>malloc() \/ free()<\/td>\n<td>\u624b\u52a8\u63a7\u5236&#xff0c;free \u524d\u4e00\u76f4\u5728<\/td>\n<td>\u8fd0\u884c\u65f6\u52a8\u6001\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td>\u5168\u5c40\/\u9759\u6001\u533a<\/td>\n<td>\u5168\u5c40\u53d8\u91cf\u3001static \u53d8\u91cf<\/td>\n<td>\u6574\u4e2a\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4<\/td>\n<td>\u7f16\u8bd1\/\u94fe\u63a5\u671f\u5c31\u786e\u5b9a\u4e86<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e3a\u4ec0\u4e48\u8fd9\u4e2a\u533a\u522b\u5bf9 FreeRTOS \u5982\u6b64\u91cd\u8981&#xff1f;<\/p>\n<p>\u56e0\u4e3a FreeRTOS \u91cc\u6240\u6709&#034;\u521b\u5efa&#034;\u64cd\u4f5c\u2014\u2014\u521b\u5efa\u4efb\u52a1\u3001\u521b\u5efa\u4fe1\u53f7\u91cf\u3001\u521b\u5efa\u961f\u5217\u2014\u2014\u672c\u8d28\u4e0a\u90fd\u662f\u5728\u56de\u7b54\u4e00\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<p>\u8fd9\u4e2a\u5bf9\u8c61\u7684&#034;\u672c\u4f53&#034;&#xff08;\u7ed3\u6784\u4f53&#xff09;\u653e\u5728\u54ea\u4e2a\u533a&#xff1f;<\/p>\n<p>\u653e\u5728\u5806\u533a&#xff0c;\u5c31\u53eb\u52a8\u6001\u521b\u5efa&#xff1b;\u653e\u5728\u5168\u5c40\/\u9759\u6001\u533a&#xff08;\u7531\u4f60\u81ea\u5df1\u63d0\u4f9b\u53d8\u91cf&#xff09;&#xff0c;\u5c31\u53eb\u9759\u6001\u521b\u5efa\u3002<\/p>\n<p>\u5c31\u8fd9\u4e48\u7b80\u5355\u3002\u5269\u4e0b\u7684\u6240\u6709\u7ec6\u8282&#xff0c;\u90fd\u662f\u4ece\u8fd9\u4e2a\u6839\u4e0a\u957f\u51fa\u6765\u7684\u3002<\/p>\n<h3>\u7b2c\u4e8c\u90e8\u5206&#xff1a;\u4fe1\u53f7\u91cf\u3001\u961f\u5217\u548c\u5806\u533a\u5230\u5e95\u662f\u4ec0\u4e48\u5173\u7cfb&#xff1f;<\/h3>\n<h4>2.1 \u4e00\u4e2a\u5e38\u89c1\u7684\u8bef\u89e3<\/h4>\n<p>\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u60f3&#xff1a;\u4fe1\u53f7\u91cf\u561b&#xff0c;\u4e0d\u5c31\u662f\u4e2a\u8ba1\u6570\u5668\u5417&#xff1f;\u7ed9\u5b83\u4e00\u4e2a\u53d8\u91cf\u4e0d\u5c31\u884c\u4e86&#xff1f;<\/p>\n<p><span class=\"token keyword\">int<\/span> semaphore <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u5929\u771f\u5730\u4ee5\u4e3a\u4fe1\u53f7\u91cf\u5c31\u662f\u8fd9\u6837<\/span><\/p>\n<p>\u5927\u9519\u7279\u9519\u3002<\/p>\n<p>\u5982\u679c\u4f60\u53ea\u7528\u4e00\u4e2a int \u5f53\u4fe1\u53f7\u91cf&#xff0c;\u4f1a\u51fa\u73b0\u4ec0\u4e48\u95ee\u9898&#xff1f;\u8003\u8651\u4e24\u4e2a\u4efb\u52a1\u540c\u65f6\u64cd\u4f5c\u5b83&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u4efb\u52a1A&#xff1a;\u7ed9\u51fa\u4fe1\u53f7\u91cf<\/span><br \/>\nsemaphore<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u8fd9\u4e0d\u662f\u539f\u5b50\u64cd\u4f5c&#xff01;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u4efb\u52a1B&#xff1a;\u83b7\u53d6\u4fe1\u53f7\u91cf<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>semaphore <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    semaphore<span class=\"token operator\">&#8212;<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u8fd9\u4e5f\u4e0d\u662f\u539f\u5b50\u64cd\u4f5c&#xff01;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u62ff\u5230\u4fe1\u53f7\u91cf&#xff0c;\u5e72\u6d3b<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u6ca1\u62ff\u5230&#xff0c;\u600e\u4e48\u529e&#xff1f;\u4e00\u76f4\u5faa\u73af\u7b49&#xff1f;\u90a3CPU\u5c31\u767d\u70e7\u4e86<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u95ee\u9898\u4e00\u5927\u5806&#xff1a;<\/p>\n<li>semaphore&#043;&#043; \u4e0d\u662f\u539f\u5b50\u64cd\u4f5c\u2014\u2014\u7f16\u8bd1\u51fa\u6765\u53ef\u80fd\u662f&#034;\u8bfb-\u6539-\u5199&#034;\u4e09\u6761\u6307\u4ee4&#xff0c;\u4e2d\u95f4\u53ef\u80fd\u88ab\u4e2d\u65ad\u6253\u65ad\u3002<\/li>\n<li>\u6ca1\u62ff\u5230\u4fe1\u53f7\u91cf\u600e\u4e48\u529e&#xff1f; \u4f60\u4e0d\u80fd\u8ba9\u4efb\u52a1\u6b7b\u5faa\u73af\u7b49&#xff08;\u53eb&#034;\u5fd9\u7b49\u5f85&#034;&#xff09;&#xff0c;\u90a3\u4f1a\u767d\u767d\u6d6a\u8d39 CPU\u3002\u4f60\u5e0c\u671b\u4efb\u52a1\u80fd\u7761\u8fc7\u53bb&#xff0c;\u7b49\u4fe1\u53f7\u91cf\u6765\u4e86\u518d\u88ab\u5524\u9192\u3002<\/li>\n<li>\u591a\u4e2a\u4efb\u52a1\u540c\u65f6\u7b49\u600e\u4e48\u529e&#xff1f; \u8c01\u5148\u9192&#xff1f;\u4f18\u5148\u7ea7\u9ad8\u7684\u5148\u9192\u5417&#xff1f;<\/li>\n<p>\u8fd9\u4e9b\u95ee\u9898\u7684\u7b54\u6848&#xff0c;\u4e0d\u662f\u51e0\u4e2a\u53d8\u91cf\u80fd\u88c5\u4e0b\u7684\u3002\u4f60\u9700\u8981\u4e00\u4e2a\u7ed3\u6784\u4f53&#xff0c;\u91cc\u9762\u88c5\u7740&#xff1a;<\/p>\n<ul>\n<li>\u8ba1\u6570\u503c&#xff08;\u73b0\u5728\u6709\u51e0\u4e2a\u4fe1\u53f7\u91cf&#xff09;<\/li>\n<li>\u7b49\u5f85\u4efb\u52a1\u94fe\u8868&#xff08;\u54ea\u4e9b\u4efb\u52a1\u5728\u7b49\u8fd9\u4e2a\u4fe1\u53f7\u91cf&#xff09;<\/li>\n<li>\u64cd\u4f5c\u8fd9\u4e2a\u7ed3\u6784\u4f53\u7684\u539f\u5b50\u6027\u4fdd\u62a4\u673a\u5236<\/li>\n<li>\u5524\u9192\u54ea\u4e2a\u4efb\u52a1\u7684\u8c03\u5ea6\u903b\u8f91<\/li>\n<\/ul>\n<h4>2.2 \u4fe1\u53f7\u91cf\u7684\u771f\u8eab&#xff1a;\u4e00\u4e2a\u7ed3\u6784\u4f53<\/h4>\n<p>\u5728 FreeRTOS \u6e90\u7801\u91cc&#xff0c;\u4fe1\u53f7\u91cf\u3001\u961f\u5217\u3001\u4e92\u65a5\u91cf&#xff0c;\u672c\u8d28\u4e0a\u90fd\u662f\u540c\u4e00\u4e2a\u7ed3\u6784\u4f53 Queue_t&#xff1a;<\/p>\n<p><span class=\"token keyword\">typedef<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">QueueDefinition<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">int8_t<\/span> <span class=\"token operator\">*<\/span>pcHead<span class=\"token punctuation\">;<\/span>              <span class=\"token comment\">\/\/ \u5b58\u50a8\u533a\u8d77\u59cb\u5730\u5740<\/span><br \/>\n    <span class=\"token class-name\">int8_t<\/span> <span class=\"token operator\">*<\/span>pcTail<span class=\"token punctuation\">;<\/span>              <span class=\"token comment\">\/\/ \u5b58\u50a8\u533a\u7ed3\u675f\u5730\u5740<\/span><br \/>\n    <span class=\"token class-name\">int8_t<\/span> <span class=\"token operator\">*<\/span>pcWriteTo<span class=\"token punctuation\">;<\/span>           <span class=\"token comment\">\/\/ \u4e0b\u4e00\u4e2a\u8981\u5199\u5165\u7684\u4f4d\u7f6e<\/span><\/p>\n<p>    <span class=\"token keyword\">union<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        Queue_t <span class=\"token operator\">*<\/span>pxQueue<span class=\"token punctuation\">;<\/span><br \/>\n        StaticQueue_t <span class=\"token operator\">*<\/span>pxStaticQueue<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> u<span class=\"token punctuation\">;<\/span><\/p>\n<p>    UBaseType_t uxMessagesWaiting<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u2605 \u4fe1\u53f7\u91cf\u7684&#034;\u8ba1\u6570\u503c&#034;\u5c31\u5728\u8fd9\u91cc<\/span><br \/>\n    UBaseType_t uxLength<span class=\"token punctuation\">;<\/span>           <span class=\"token comment\">\/\/ \u961f\u5217\u957f\u5ea6&#xff08;\u4fe1\u53f7\u91cf\u5c31\u662f1&#xff09;<\/span><br \/>\n    UBaseType_t uxItemSize<span class=\"token punctuation\">;<\/span>         <span class=\"token comment\">\/\/ \u6bcf\u9879\u5927\u5c0f&#xff08;\u4fe1\u53f7\u91cf\u662f0&#xff09;<\/span><\/p>\n<p>    List_t xTasksWaitingToSend<span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/ \u7b49\u53d1\u9001\u7684\u4efb\u52a1\u94fe\u8868<\/span><br \/>\n    List_t xTasksWaitingToReceive<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u7b49\u63a5\u6536\u7684\u4efb\u52a1\u94fe\u8868<\/span><br \/>\n    <span class=\"token comment\">\/\/ &#8230; \u5176\u4ed6\u5b57\u6bb5<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> Queue_t<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u5c31\u662f&#034;\u5185\u6838\u5bf9\u8c61&#034;\u7684\u542b\u4e49\u3002 \u4fe1\u53f7\u91cf\u4e0d\u662f\u4e00\u4e2a int&#xff0c;\u800c\u662f\u4e00\u6574\u4e2a\u7ed3\u6784\u4f53&#xff0c;\u91cc\u9762\u88c5\u7740\u8ba1\u6570\u503c\u3001\u7b49\u5f85\u94fe\u8868\u3001\u5404\u79cd\u5143\u6570\u636e\u3002<\/p>\n<p>\u5173\u952e\u70b9\u6765\u4e86&#xff1a;\u8fd9\u4e2a\u7ed3\u6784\u4f53\u672c\u8eab&#xff0c;\u4ee5\u53ca\u5b83\u8981\u7528\u7684\u5b58\u50a8\u533a&#xff0c;\u4ece\u54ea\u91cc\u6765&#xff1f;<\/p>\n<p>\u7b54\u6848\u5c31\u662f&#xff1a;\u521b\u5efa\u7684\u65f6\u5019&#xff0c;\u4ece\u5806\u533a\u5206\u914d\u3002<\/p>\n<h4>2.3 &#034;\u521b\u5efa&#034;\u65f6\u5206\u914d&#xff0c;&#034;\u8fd0\u884c\u65f6&#034;\u4e0d\u78b0\u5806<\/h4>\n<p>\u770b\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u52a8\u6001\u521b\u5efa&#xff1a;<\/p>\n<p>SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinary<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u4e00\u884c\u80cc\u540e&#xff0c;FreeRTOS \u5e72\u4e86\u4ec0\u4e48&#xff1f;<\/p>\n<li>\u8c03\u7528 pvPortMalloc(sizeof(Queue_t)) \u2014\u2014 \u4ece FreeRTOS \u7684\u5806\u91cc\u5206\u914d\u4e00\u4e2a Queue_t \u7ed3\u6784\u4f53\u3002<\/li>\n<li>\u5bf9\u4e8e\u666e\u901a\u961f\u5217&#xff0c;\u8fd8\u4f1a\u518d\u5206\u914d\u4e00\u5757\u5b58\u50a8\u533a&#xff08;\u5b58\u653e\u5b9e\u9645\u6570\u636e\u7684\u7f13\u51b2\u533a&#xff09;\u3002<\/li>\n<li>\u521d\u59cb\u5316\u8fd9\u4e2a\u7ed3\u6784\u4f53&#xff1a;\u8ba1\u6570\u503c\u6e05\u96f6\u3001\u7b49\u5f85\u94fe\u8868\u6e05\u7a7a\u3001\u957f\u5ea6\u548c\u9879\u5927\u5c0f\u586b\u597d\u3002<\/li>\n<li>\u8fd4\u56de\u4e00\u4e2a\u6307\u9488\u2014\u2014\u8fd9\u5c31\u662f\u6240\u8c13\u7684\u53e5\u67c4&#xff08;Handle&#xff09;\u3002<\/li>\n<p>\u6b64\u540e&#xff0c;\u4f60\u8c03\u7528 xSemaphoreGive() \u548c xSemaphoreTake()&#xff0c;\u8fd9\u4e9b\u51fd\u6570\u53ea\u5728\u5df2\u7ecf\u5206\u914d\u597d\u7684\u7ed3\u6784\u4f53\u4e0a\u64cd\u4f5c&#xff0c;\u4e0d\u518d\u8c03\u7528 pvPortMalloc()\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u7b14\u8bb0\u91cc\u90a3\u53e5\u8bdd\u7684\u542b\u4e49&#xff1a;<\/p>\n<p>\u961f\u5217\/\u4fe1\u53f7\u91cf&#034;\u521b\u5efa\u65f6&#034;\u4ece\u5806\u533a\u5206\u914d\u672c\u4f53&#xff08;\u63a7\u5236\u5757&#xff0c;\u961f\u5217\u8fd8\u542b\u5b58\u50a8\u533a&#xff09;&#xff0c;&#034;\u8fd0\u884c\u65f6&#034;\u6536\u53d1\u4e0d\u518d\u78b0\u5806\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8fd9\u4e00\u70b9\u6781\u5176\u91cd\u8981&#xff1f;<\/p>\n<p>\u56e0\u4e3a\u5b9e\u65f6\u7cfb\u7edf\u6700\u6015\u7684\u5c31\u662f&#034;\u8fd0\u884c\u65f6\u7684\u4e0d\u53ef\u9884\u6d4b&#034;\u3002\u5982\u679c\u6bcf\u6b21\u53d1\u4fe1\u53f7\u90fd\u8981 malloc&#xff0c;\u90a3\u4e48&#xff1a;<\/p>\n<ul>\n<li>\u8fd9\u6b21\u53d1\u4fe1\u53f7\u53ef\u80fd\u82b1 1 \u5fae\u79d2&#xff0c;\u4e0b\u6b21\u53ef\u80fd\u56e0\u4e3a\u5806\u788e\u7247\u82b1 100 \u5fae\u79d2\u3002<\/li>\n<li>\u6781\u7aef\u60c5\u51b5\u4e0b malloc \u5931\u8d25&#xff0c;\u53d1\u4fe1\u53f7\u76f4\u63a5\u5d29\u6e83\u3002<\/li>\n<\/ul>\n<p>\u800c&#034;\u521b\u5efa\u65f6\u5206\u914d\u3001\u8fd0\u884c\u65f6\u96f6\u5806&#034;\u7684\u8bbe\u8ba1&#xff0c;\u628a\u4e0d\u786e\u5b9a\u6027\u96c6\u4e2d\u5230\u4e86\u521d\u59cb\u5316\u9636\u6bb5\u3002\u4e00\u65e6\u7cfb\u7edf\u521d\u59cb\u5316\u5b8c\u6210\u3001\u6240\u6709\u5bf9\u8c61\u521b\u5efa\u6210\u529f&#xff0c;\u8fd0\u884c\u65f6\u7684\u884c\u4e3a\u5c31\u662f\u5b8c\u5168\u53ef\u9884\u6d4b\u7684\u3002<\/p>\n<h4>2.4 \u961f\u5217\u6bd4\u4fe1\u53f7\u91cf\u591a\u5206\u914d\u4e86\u4ec0\u4e48&#xff1f;<\/h4>\n<p>\u4fe1\u53f7\u91cf\u662f&#034;\u957f\u5ea6\u4e3a 1\u3001\u9879\u5927\u5c0f\u4e3a 0&#034;\u7684\u7279\u6b8a\u961f\u5217\u3002\u56e0\u4e3a\u9879\u5927\u5c0f\u4e3a 0&#xff0c;\u6240\u4ee5\u5b83\u4e0d\u9700\u8981\u5b58\u50a8\u533a\u2014\u2014\u53ea\u5206\u914d\u63a7\u5236\u5757\u3002<\/p>\n<p>\u666e\u901a\u961f\u5217\u5219\u4e0d\u540c&#xff1a;<\/p>\n<p>QueueHandle_t xQueue <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xQueueCreate<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint32_t<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u91cc\u9700\u8981&#xff1a;<\/p>\n<ul>\n<li>1 \u4e2a Queue_t \u63a7\u5236\u5757&#xff08;\u653e\u5143\u6570\u636e&#xff09;<\/li>\n<li>1 \u5757\u5b58\u50a8\u533a&#xff0c;\u5927\u5c0f &#061; 10 \u00d7 4 &#061; 40 \u5b57\u8282&#xff08;\u653e\u5b9e\u9645\u6570\u636e&#xff09;<\/li>\n<\/ul>\n<p>\u5f53\u4f60 xQueueSend() \u65f6&#xff0c;FreeRTOS \u4f1a\u628a\u4f60\u7684\u6570\u636e\u62f7\u8d1d\u5230\u8fd9\u5757\u5b58\u50a8\u533a\u91cc&#xff1b;xQueueReceive() \u65f6\u518d\u62f7\u8d1d\u51fa\u6765\u3002\u6240\u4ee5\u961f\u5217\u4f20\u7684\u662f\u503c\u62f7\u8d1d&#xff0c;\u4e0d\u662f\u6307\u9488\u3002<\/p>\n<h3>\u7b2c\u4e09\u90e8\u5206&#xff1a;\u52a8\u6001\u521b\u5efa vs \u9759\u6001\u521b\u5efa\u2014\u2014\u4e00\u4e2a\u7528\u5806&#xff0c;\u4e00\u4e2a\u4e0d\u7528\u5806<\/h3>\n<h4>3.1 \u52a8\u6001\u521b\u5efa&#xff1a;\u65b9\u4fbf&#xff0c;\u4f46\u6709\u4ee3\u4ef7<\/h4>\n<p>\u52a8\u6001\u521b\u5efa\u5c31\u662f\u4e0a\u9762\u90a3\u79cd\u65b9\u5f0f&#xff1a;<\/p>\n<p>SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinary<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nQueueHandle_t xQueue <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xQueueCreate<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint32_t<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nTaskHandle_t xTask<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTaskFunction<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;TaskName&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>xTask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>xTaskCreate \u5185\u90e8\u4e5f\u4f1a\u4e3a\u4efb\u52a1\u7684\u6808\u548c**\u4efb\u52a1\u63a7\u5236\u5757&#xff08;TCB&#xff09;**\u4ece\u5806\u91cc\u5206\u914d\u5185\u5b58\u3002<\/p>\n<p>\u4f18\u70b9&#xff1a;<\/p>\n<ul>\n<li>API \u7b80\u6d01&#xff0c;\u4e00\u884c\u641e\u5b9a\u3002<\/li>\n<li>\u9700\u8981\u591a\u5c11\u5206\u914d\u591a\u5c11&#xff0c;RAM \u4f7f\u7528\u7075\u6d3b\u3002<\/li>\n<li>\u6559\u7a0b\u3001\u793a\u4f8b\u3001\u7b2c\u4e09\u65b9\u5e93\u9ed8\u8ba4\u90fd\u7528\u8fd9\u4e2a&#xff0c;\u8d44\u6599\u6700\u591a\u3002<\/li>\n<\/ul>\n<p>\u7f3a\u70b9&#xff08;\u5176\u5b9e\u662f&#034;\u98ce\u9669&#034;&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u98ce\u9669\u5177\u4f53\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u5206\u914d\u53ef\u80fd\u5931\u8d25<\/td>\n<td>\u5806\u4e0d\u591f\u4e86&#xff0c;xSemaphoreCreateBinary() \u8fd4\u56de NULL\u3002\u5982\u679c\u4f60\u4e0d\u68c0\u67e5&#xff0c;\u540e\u9762\u7528\u5c31\u5d29\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u788e\u7247<\/td>\n<td>\u53cd\u590d\u521b\u5efa\u5220\u9664\u4e0d\u540c\u5927\u5c0f\u7684\u5bf9\u8c61&#xff0c;\u5806\u91cc\u4f1a\u51fa\u73b0&#034;\u603b\u7a7a\u95f2\u591f\u5927\u3001\u4f46\u8fde\u7eed\u7a7a\u95f4\u4e0d\u591f&#034;\u7684\u60c5\u51b5\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6267\u884c\u65f6\u95f4\u4e0d\u786e\u5b9a<\/td>\n<td>pvPortMalloc \u8017\u65f6\u53d6\u51b3\u4e8e\u5806\u72b6\u6001&#xff0c;\u4e0d\u6ee1\u8db3\u786c\u5b9e\u65f6\u8981\u6c42\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6cc4\u6f0f<\/td>\n<td>\u5fd8\u8bb0 vSemaphoreDelete()&#xff0c;\u5806\u91cc\u90a3\u5757\u5185\u5b58\u5c31\u6c38\u8fdc\u627e\u4e0d\u56de\u6765\u4e86\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6808\u6ea2\u51fa\u66f4\u96be\u67e5<\/td>\n<td>\u4efb\u52a1\u6808\u662f\u4ece\u5806\u91cc\u5207\u7684&#xff0c;\u6ea2\u51fa\u53ef\u80fd\u8e29\u5230\u522b\u7684\u5bf9\u8c61&#xff0c;\u73b0\u8c61\u8be1\u5f02\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3.2 \u9759\u6001\u521b\u5efa&#xff1a;\u9ebb\u70e6&#xff0c;\u4f46\u786e\u5b9a<\/h4>\n<p>\u9759\u6001\u521b\u5efa\u7684\u6838\u5fc3\u601d\u60f3&#xff1a;&#034;\u672c\u4f53&#034;\u53d8\u91cf\u7531\u4f60\u81ea\u5df1\u63d0\u4f9b&#xff0c;FreeRTOS \u53ea\u8d1f\u8d23\u521d\u59cb\u5316\u5b83&#xff0c;\u4e0d\u78b0\u5806\u3002<\/p>\n<p>\u4ee5\u961f\u5217\u4e3a\u4f8b&#xff0c;\u5b8c\u6574\u7684\u4e09\u6b65\u8d70&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">QUEUE_LENGTH<\/span>    <span class=\"token expression\"><span class=\"token number\">10<\/span><\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">ITEM_SIZE<\/span>       <span class=\"token expression\"><span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint32_t<\/span><span class=\"token punctuation\">)<\/span><\/span><\/span><\/p>\n<p><span class=\"token comment\">\/* \u7b2c 1 \u6b65&#xff1a;\u58f0\u660e\u63a7\u5236\u5757&#xff08;\u5fc5\u987b\u662f\u5168\u5c40\u6216 static&#xff09; *\/<\/span><br \/>\n<span class=\"token keyword\">static<\/span> StaticQueue_t xQueueControlBlock<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/* \u7b2c 2 \u6b65&#xff1a;\u58f0\u660e\u5b58\u50a8\u533a&#xff08;\u5927\u5c0f &#061; \u957f\u5ea6 \u00d7 \u9879\u5927\u5c0f&#xff09; *\/<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token class-name\">uint8_t<\/span> ucQueueStorageArea<span class=\"token punctuation\">[<\/span>QUEUE_LENGTH <span class=\"token operator\">*<\/span> ITEM_SIZE<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vInitFunction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    QueueHandle_t xQueue<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/* \u7b2c 3 \u6b65&#xff1a;\u521b\u5efa\u2014\u2014\u4f20\u5165\u4f60\u81ea\u5df1\u51c6\u5907\u597d\u7684\u5185\u5b58 *\/<\/span><br \/>\n    xQueue <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xQueueCreateStatic<\/span><span class=\"token punctuation\">(<\/span><br \/>\n        QUEUE_LENGTH<span class=\"token punctuation\">,<\/span>                    <span class=\"token comment\">\/\/ \u961f\u5217\u957f\u5ea6<\/span><br \/>\n        ITEM_SIZE<span class=\"token punctuation\">,<\/span>                       <span class=\"token comment\">\/\/ \u6bcf\u9879\u5927\u5c0f<\/span><br \/>\n        ucQueueStorageArea<span class=\"token punctuation\">,<\/span>              <span class=\"token comment\">\/\/ \u4f60\u63d0\u4f9b\u7684\u5b58\u50a8\u533a<\/span><br \/>\n        <span class=\"token operator\">&amp;<\/span>xQueueControlBlock              <span class=\"token comment\">\/\/ \u4f60\u63d0\u4f9b\u7684\u63a7\u5236\u5757<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/* \u9759\u6001\u521b\u5efa\u53ea\u8981\u53c2\u6570\u6709\u6548\u5c31\u4e0d\u4f1a\u5931\u8d25&#xff0c;\u4f46\u6700\u597d\u8fd8\u662f\u65ad\u8a00\u4e00\u4e0b *\/<\/span><br \/>\n    <span class=\"token function\">configASSERT<\/span><span class=\"token punctuation\">(<\/span>xQueue <span class=\"token operator\">!&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u9759\u6001\u521b\u5efa\u4fe1\u53f7\u91cf&#xff1a;<\/p>\n<p><span class=\"token keyword\">static<\/span> StaticSemaphore_t xSemControlBlock<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vInitFunction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinaryStatic<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>xSemControlBlock<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">configASSERT<\/span><span class=\"token punctuation\">(<\/span>xSem <span class=\"token operator\">!&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u9759\u6001\u521b\u5efa\u4efb\u52a1&#xff08;\u7a0d\u5fae\u7279\u6b8a&#xff09;&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">TASK_STACK_SIZE<\/span>  <span class=\"token expression\"><span class=\"token number\">128<\/span>   <\/span><span class=\"token comment\">\/\/ \u5355\u4f4d\u662f&#034;\u5b57&#034;&#xff0c;\u4e0d\u662f\u5b57\u8282&#xff01;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> StackType_t  xTaskStack<span class=\"token punctuation\">[<\/span>TASK_STACK_SIZE<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u4efb\u52a1\u6808<\/span><br \/>\n<span class=\"token keyword\">static<\/span> StaticTask_t xTaskTCB<span class=\"token punctuation\">;<\/span>                      <span class=\"token comment\">\/\/ \u4efb\u52a1\u63a7\u5236\u5757<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vInitFunction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    TaskHandle_t xTask <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xTaskCreateStatic<\/span><span class=\"token punctuation\">(<\/span><br \/>\n        vTaskFunction<span class=\"token punctuation\">,<\/span>        <span class=\"token comment\">\/\/ \u4efb\u52a1\u51fd\u6570<\/span><br \/>\n        <span class=\"token string\">&#034;MyTask&#034;<\/span><span class=\"token punctuation\">,<\/span>             <span class=\"token comment\">\/\/ \u4efb\u52a1\u540d<\/span><br \/>\n        TASK_STACK_SIZE<span class=\"token punctuation\">,<\/span>      <span class=\"token comment\">\/\/ \u6808\u5927\u5c0f&#xff08;\u5b57\u6570&#xff09;<\/span><br \/>\n        <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span>                 <span class=\"token comment\">\/\/ \u4f20\u7ed9\u4efb\u52a1\u7684\u53c2\u6570<\/span><br \/>\n        <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span>                    <span class=\"token comment\">\/\/ \u4f18\u5148\u7ea7<\/span><br \/>\n        xTaskStack<span class=\"token punctuation\">,<\/span>           <span class=\"token comment\">\/\/ \u4f60\u63d0\u4f9b\u7684\u6808<\/span><br \/>\n        <span class=\"token operator\">&amp;<\/span>xTaskTCB             <span class=\"token comment\">\/\/ \u4f60\u63d0\u4f9b\u7684 TCB<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">configASSERT<\/span><span class=\"token punctuation\">(<\/span>xTask <span class=\"token operator\">!&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u6ce8\u610f&#xff1a;\u9759\u6001\u521b\u5efa\u4efb\u52a1\u65f6&#xff0c;usStackDepth \u7684\u5355\u4f4d\u662f&#034;\u5b57&#034;&#xff08;StackType_t \u7684\u4e2a\u6570&#xff09;&#xff0c;\u4e0d\u662f\u5b57\u8282\u3002 \u5728 32 \u4f4d MCU \u4e0a&#xff0c;1 \u4e2a\u5b57 &#061; 4 \u5b57\u8282\u3002\u6240\u4ee5 128 \u5b57\u7684\u6808 &#061; 512 \u5b57\u8282\u3002\u8fd9\u4e00\u70b9\u7ecf\u5e38\u6709\u4eba\u641e\u6df7\u3002<\/p>\n<h4>3.3 \u5173\u952e\u533a\u522b\u4e00\u89c8\u8868<\/h4>\n<table>\n<tr>\u5bf9\u6bd4\u9879\u52a8\u6001\u521b\u5efa\u9759\u6001\u521b\u5efa<\/tr>\n<tbody>\n<tr>\n<td>\u5185\u5b58\u5728\u54ea<\/td>\n<td>FreeRTOS \u5806\u533a<\/td>\n<td>\u5168\u5c40\/\u9759\u6001\u533a&#xff08;\u4f60\u63d0\u4f9b&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u8c01\u5206\u914d<\/td>\n<td>pvPortMalloc \u81ea\u52a8<\/td>\n<td>\u7f16\u8bd1\u5668\u5728\u94fe\u63a5\u671f\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td>\u4f1a\u5931\u8d25\u5417<\/td>\n<td>\u53ef\u80fd&#xff08;\u8fd4\u56de NULL&#xff09;<\/td>\n<td>\u53c2\u6570\u6709\u6548\u5c31\u4e0d\u4f1a<\/td>\n<\/tr>\n<tr>\n<td>\u6267\u884c\u65f6\u95f4\u786e\u5b9a\u5417<\/td>\n<td>\u4e0d\u786e\u5b9a<\/td>\n<td>\u786e\u5b9a&#xff08;\u94fe\u63a5\u671f\u5df2\u5b9a&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4f1a\u788e\u7247\u5417<\/td>\n<td>\u4f1a<\/td>\n<td>\u4e0d\u4f1a<\/td>\n<\/tr>\n<tr>\n<td>\u80fd\u5220\u9664\u5417<\/td>\n<td>\u80fd&#xff08;vSemaphoreDelete&#xff09;<\/td>\n<td>\u4e0d\u80fd&#xff08;\u5185\u5b58\u8fd8\u5728&#xff0c;\u53ea\u662f\u4e0d\u7528\u4e86&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9700\u8981\u989d\u5916\u914d\u7f6e\u5417<\/td>\n<td>\u4e0d\u9700\u8981<\/td>\n<td>\u9700\u8981 configSUPPORT_STATIC_ALLOCATION &#061; 1<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u7801\u91cf<\/td>\n<td>\u5c11<\/td>\n<td>\u591a&#xff08;\u8981\u81ea\u5df1\u58f0\u660e\u53d8\u91cf&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u5408\u573a\u666f<\/td>\n<td>\u666e\u901a\u5e94\u7528\u3001\u5feb\u901f\u539f\u578b<\/td>\n<td>\u5b89\u5168\u5173\u952e\u3001\u786c\u5b9e\u65f6\u3001\u957f\u671f\u8fd0\u884c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6700\u91cd\u8981\u7684\u4e00\u70b9&#xff1a;\u9759\u6001\u521b\u5efa\u65f6&#xff0c;\u4f60\u7684&#034;\u672c\u4f53\u53d8\u91cf&#034;&#xff08;StaticQueue_t\u3001StaticSemaphore_t\u3001\u6808\u6570\u7ec4\u3001TCB&#xff09;\u7edd\u5bf9\u4e0d\u80fd\u653e\u5728\u6808\u4e0a&#xff01; \u5fc5\u987b\u662f\u5168\u5c40\u53d8\u91cf\u6216 static \u53d8\u91cf&#xff0c;\u4fdd\u8bc1\u5b83\u4eec\u7684\u751f\u547d\u5468\u671f\u548c\u7a0b\u5e8f\u4e00\u6837\u957f\u3002\u539f\u56e0\u5728\u4e0b\u4e00\u90e8\u5206\u4f1a\u8be6\u7ec6\u8bb2\u3002<\/p>\n<h3>\u7b2c\u56db\u90e8\u5206&#xff1a;\u53e5\u67c4\u2014\u2014\u90a3\u4e2a\u6700\u5bb9\u6613\u8e29\u5751\u7684\u6307\u9488<\/h3>\n<h4>4.1 \u53e5\u67c4\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;<\/h4>\n<p>\u53e5\u67c4&#xff08;Handle&#xff09;\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u4e2a\u6307\u9488&#xff0c;\u6307\u5411\u5bf9\u8c61\u7684&#034;\u672c\u4f53&#034;\u3002<\/p>\n<p><span class=\"token keyword\">typedef<\/span> Queue_t <span class=\"token operator\">*<\/span> QueueHandle_t<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">typedef<\/span> Queue_t <span class=\"token operator\">*<\/span> SemaphoreHandle_t<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5f53\u4f60\u5199&#xff1a;<\/p>\n<p>SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinary<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>xSem \u5c31\u662f\u4e00\u4e2a\u6307\u9488&#xff0c;\u6307\u5411\u5806\u91cc\u90a3\u4e2a Queue_t \u7ed3\u6784\u4f53\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u4e2a\u8d85\u7ea7\u5e38\u89c1\u7684\u8bef\u89e3&#xff1a;\u5f88\u591a\u4eba\u4ee5\u4e3a&#034;\u53e5\u67c4&#034;\u662f\u4e2a\u5168\u5c40\u53d8\u91cf&#xff0c;\u6216\u8005\u4ee5\u4e3a\u53e5\u67c4\u5c31\u662f\u4fe1\u53f7\u91cf\u672c\u8eab\u3002<\/p>\n<p>\u90fd\u4e0d\u5bf9\u3002 \u53e5\u67c4\u53ea\u662f\u4e00\u4e2a&#034;\u9065\u63a7\u5668&#034;&#xff0c;\u771f\u6b63\u5e72\u6d3b\u7684&#034;\u7535\u89c6\u673a&#034;&#xff08;\u4fe1\u53f7\u91cf\u672c\u4f53&#xff09;\u5728\u5806\u91cc&#xff08;\u52a8\u6001&#xff09;\u6216\u5168\u5c40\u533a&#xff08;\u9759\u6001&#xff09;\u3002<\/p>\n<h4>4.2 \u53e5\u67c4\u653e\u54ea&#xff1f;\u4e00\u6761\u94c1\u5f8b<\/h4>\n<p>\u7b14\u8bb0\u91cc\u7ed9\u51fa\u4e86\u6700\u6838\u5fc3\u7684\u89c4\u5219&#xff1a;<\/p>\n<p>\u53e5\u67c4\u751f\u547d\u5468\u671f \u2265 \u4f7f\u7528\u5b83\u7684\u4ee3\u7801\u751f\u547d\u5468\u671f<\/p>\n<p>\u7ffb\u8bd1\u6210\u4eba\u8bdd&#xff1a;\u53e5\u67c4\u5728\u54ea\u91cc&#xff0c;\u4e0d\u91cd\u8981&#xff1b;\u53e5\u67c4\u6307\u5411\u7684\u672c\u4f53\u6d3b\u591a\u4e45&#xff0c;\u4e5f\u4e0d\u91cd\u8981&#xff1b;\u91cd\u8981\u7684\u662f\u2014\u2014\u8c01\u7528\u8fd9\u4e2a\u53e5\u67c4&#xff0c;\u7528\u7684\u65f6\u5019\u53e5\u67c4\u5fc5\u987b\u8fd8\u6709\u6548\u3002<\/p>\n<p>\u770b\u51e0\u4e2a\u573a\u666f&#xff1a;<\/p>\n<p>\u573a\u666f 1&#xff1a;\u51fd\u6570\u5185\u5373\u7528\u5373\u5220<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vDoSomething<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinary<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u53e5\u67c4\u5728\u6808\u4e0a<\/span><br \/>\n    <span class=\"token function\">xSemaphoreGive<\/span><span class=\"token punctuation\">(<\/span>xSem<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xSemaphoreTake<\/span><span class=\"token punctuation\">(<\/span>xSem<span class=\"token punctuation\">,<\/span> portMAX_DELAY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">vSemaphoreDelete<\/span><span class=\"token punctuation\">(<\/span>xSem<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u51fd\u6570\u9000\u51fa&#xff0c;\u53e5\u67c4\u6d88\u5931&#xff0c;\u672c\u4f53\u4e5f\u88ab\u5220\u4e86\u2014\u2014\u6ca1\u95ee\u9898<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u2705 \u53ef\u4ee5\u3002\u53e5\u67c4\u548c\u672c\u4f53\u751f\u547d\u5468\u671f\u4e00\u81f4&#xff0c;\u90fd\u5728\u51fd\u6570\u5185\u3002<\/p>\n<p>\u573a\u666f 2&#xff1a;\u53e5\u67c4\u5efa\u5728\u6808\u4e0a&#xff0c;\u5730\u5740\u4f20\u7ed9\u4efb\u52a1<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vCreateTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinary<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u6808\u4e0a<\/span><br \/>\n    <span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTask<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Task&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>xSem<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u4f20\u4e86\u53e5\u67c4\u7684\u5730\u5740<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>  <span class=\"token comment\">\/\/ \u2190 \u51fd\u6570\u9000\u51fa&#xff0c;xSem \u8fd9\u4e2a\u53d8\u91cf\u6ca1\u4e86&#xff01;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>pvParameters<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t <span class=\"token operator\">*<\/span>pxSem <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>SemaphoreHandle_t <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>pvParameters<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xSemaphoreTake<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span>pxSem<span class=\"token punctuation\">,<\/span> portMAX_DELAY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u2605 \u91ce\u6307\u9488&#xff01;xSem \u53d8\u91cf\u5df2\u7ecf\u4e0d\u5b58\u5728\u4e86<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u274c \u5927\u9519&#xff01; xSem \u53d8\u91cf\u5728\u6808\u4e0a&#xff0c;\u51fd\u6570\u9000\u51fa\u540e\u6808\u88ab\u56de\u6536&#xff0c;\u4efb\u52a1\u62ff\u5230\u7684\u662f\u4e00\u4e2a\u5931\u6548\u7684\u5730\u5740\u3002<\/p>\n<p>\u6b63\u786e\u505a\u6cd5 1&#xff1a;\u53e5\u67c4\u653e\u5168\u5c40\/\u9759\u6001\u533a\u3002<\/p>\n<p><span class=\"token keyword\">static<\/span> SemaphoreHandle_t xSem<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u5168\u5c40\/\u9759\u6001\u533a&#xff0c;\u751f\u547d\u5468\u671f\u548c\u7a0b\u5e8f\u4e00\u6837\u957f<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vCreateTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinary<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTask<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Task&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u4e0d\u4f20\u53c2&#xff0c;\u4efb\u52a1\u76f4\u63a5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u6b63\u786e\u505a\u6cd5 2&#xff1a;\u76f4\u63a5\u4f20\u53e5\u67c4\u503c&#xff08;\u56e0\u4e3a\u53e5\u67c4\u672c\u8eab\u5c31\u662f\u6307\u9488&#xff09;\u3002<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vCreateTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinary<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u53e5\u67c4\u672c\u8eab\u662f\u6307\u9488&#xff0c;\u76f4\u63a5\u5f53 void* \u4f20<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4f46\u6ce8\u610f&#xff1a;xSem \u8fd9\u4e2a\u53d8\u91cf\u672c\u8eab\u8fd8\u662f\u5728\u6808\u4e0a&#xff0c;\u51fd\u6570\u9000\u51fa\u540e\u53d8\u91cf\u6d88\u5931&#xff0c;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4f46\u4efb\u52a1\u6536\u5230\u7684\u662f&#034;\u6307\u9488\u7684\u503c&#034;&#xff08;\u6307\u5411\u5806\u91cc\u7684\u672c\u4f53&#xff09;&#xff0c;\u672c\u4f53\u8fd8\u5728&#xff0c;\u6240\u4ee5\u6709\u6548&#xff01;<\/span><br \/>\n    <span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTask<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Task&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>xSem<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><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 punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>pvParameters<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>SemaphoreHandle_t<span class=\"token punctuation\">)<\/span>pvParameters<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xSemaphoreTake<\/span><span class=\"token punctuation\">(<\/span>xSem<span class=\"token punctuation\">,<\/span> portMAX_DELAY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u2705 \u6709\u6548&#xff0c;\u56e0\u4e3a\u672c\u4f53\u5728\u5806\u91cc\u6d3b\u7740<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u7b49\u7b49&#xff0c;\u8fd9\u91cc\u6709\u4e2a\u5fae\u5999\u4e4b\u5904&#xff1a;xSem \u8fd9\u4e2a\u53d8\u91cf\u5728\u6808\u4e0a&#xff0c;\u51fd\u6570\u9000\u51fa\u540e\u53d8\u91cf\u6ca1\u4e86&#xff1b;\u4f46 xSem \u7684\u503c&#xff08;\u4e00\u4e2a\u6307\u5411\u5806\u91cc\u7ed3\u6784\u4f53\u7684\u6307\u9488&#xff09;\u88ab\u62f7\u8d1d\u4f20\u7ed9\u4e86\u4efb\u52a1\u3002\u4efb\u52a1\u62ff\u5230\u7684\u6307\u9488\u6307\u5411\u7684\u5806\u5185\u5b58\u8fd8\u5728&#xff08;\u56e0\u4e3a\u662f\u52a8\u6001\u521b\u5efa\u7684&#xff09;&#xff0c;\u6240\u4ee5\u6709\u6548\u3002<\/p>\n<p>\u4f46\u5982\u679c\u662f\u9759\u6001\u521b\u5efa\u5462&#xff1f;<\/p>\n<p><span class=\"token keyword\">static<\/span> StaticSemaphore_t xSemBody<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u672c\u4f53\u5728\u5168\u5c40\u533a<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vCreateTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinaryStatic<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>xSemBody<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTask<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Task&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>xSem<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><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 punctuation\">}<\/span><\/p>\n<p>\u8fd9\u91cc xSem \u53d8\u91cf\u5728\u6808\u4e0a&#xff0c;\u503c\u6307\u5411 xSemBody&#xff08;\u5168\u5c40\u533a&#xff09;\u3002\u51fd\u6570\u9000\u51fa\u540e xSem \u53d8\u91cf\u6ca1\u4e86&#xff0c;\u4f46 xSemBody \u8fd8\u5728\u5168\u5c40\u533a&#xff0c;\u4efb\u52a1\u62ff\u5230\u7684\u6307\u9488\u4f9d\u7136\u6709\u6548\u3002\u2705<\/p>\n<p>\u6240\u4ee5\u5173\u952e\u4e0d\u662f&#034;\u53e5\u67c4\u53d8\u91cf\u5728\u54ea&#034;&#xff0c;\u800c\u662f&#034;\u53e5\u67c4\u6307\u5411\u7684\u672c\u4f53\u5728\u54ea\u3001\u6d3b\u591a\u4e45&#034;\u3002<\/p>\n<h4>4.3 \u4f20\u53c2\u7684\u4e24\u4e2a\u5751<\/h4>\n<p>\u5751 1&#xff1a;\u591a\u4f20\u4e86\u4e00\u5c42\u5730\u5740<\/p>\n<p><span class=\"token comment\">\/\/ \u274c \u9519\u8bef<\/span><br \/>\n<span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTask<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Task&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>xSem<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>pvParameters<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t <span class=\"token operator\">*<\/span>pxSem <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>SemaphoreHandle_t <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>pvParameters<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xSemaphoreTake<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span>pxSem<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>  <span class=\"token comment\">\/\/ \u591a\u4e86\u4e00\u6b21\u89e3\u5f15\u7528&#xff0c;\u800c\u4e14 pxSem \u6307\u5411\u7684\u6808\u5730\u5740\u53ef\u80fd\u5df2\u5931\u6548<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>SemaphoreHandle_t \u672c\u8eab\u5df2\u7ecf\u662f\u6307\u9488\u4e86\u3002\u76f4\u63a5\u4f20\u503c\u5c31\u884c&#xff0c;\u4e0d\u8981\u4f20\u5b83\u7684\u5730\u5740\u3002<\/p>\n<p><span class=\"token comment\">\/\/ \u2705 \u6b63\u786e<\/span><br \/>\n<span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTask<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Task&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>xSem<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>pvParameters<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>SemaphoreHandle_t<span class=\"token punctuation\">)<\/span>pvParameters<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xSemaphoreTake<\/span><span class=\"token punctuation\">(<\/span>xSem<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><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5751 2&#xff1a;\u628a\u6808\u4e0a\u7684\u672c\u4f53\u53d8\u91cf\u4f20\u51fa\u53bb<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vCreateTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    StaticSemaphore_t xSemBody<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u274c \u5728\u6808\u4e0a&#xff01;<\/span><br \/>\n    SemaphoreHandle_t xSem <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">xSemaphoreCreateBinaryStatic<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>xSemBody<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">xTaskCreate<\/span><span class=\"token punctuation\">(<\/span>vTask<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Task&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>xSem<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><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 punctuation\">}<\/span>  <span class=\"token comment\">\/\/ \u51fd\u6570\u9000\u51fa&#xff0c;xSemBody \u6240\u5728\u7684\u6808\u88ab\u56de\u6536<\/span><\/p>\n<p>\u4efb\u52a1\u62ff\u5230\u7684\u6307\u9488\u6307\u5411\u7684\u662f\u4e00\u5757\u5df2\u7ecf\u88ab\u56de\u6536\u7684\u6808\u5185\u5b58&#xff0c;\u91cc\u9762\u7684\u6570\u636e\u968f\u65f6\u53ef\u80fd\u88ab\u5176\u4ed6\u51fd\u6570\u8c03\u7528\u8986\u76d6\u3002\u8fd9\u662f\u5178\u578b\u7684\u91ce\u6307\u9488\u3002<\/p>\n<p>\u9759\u6001\u521b\u5efa\u65f6&#xff0c;\u672c\u4f53\u53d8\u91cf\u5fc5\u987b\u662f\u5168\u5c40\u6216 static\u3002<\/p>\n<h3>\u7b2c\u4e94\u90e8\u5206&#xff1a;\u5b89\u5168\u5173\u952e\u9886\u57df\u4e3a\u4ec0\u4e48&#034;\u7981\u6b62\u7528\u5806&#034;<\/h3>\n<h4>5.1 MISRA\u3001AUTOSAR\u3001NASA \u7684\u89c4\u5b9a<\/h4>\n<p>\u5982\u679c\u4f60\u5728\u6c7d\u8f66\u3001\u533b\u7597\u3001\u822a\u7a7a\u884c\u4e1a\u5199\u4ee3\u7801&#xff0c;\u4e0b\u9762\u8fd9\u4e9b\u89c4\u5219\u4f60\u4e00\u5b9a\u4f1a\u9047\u5230&#xff1a;<\/p>\n<ul>\n<li>MISRA C&#043;&#043; Rule 18-4-1&#xff1a;\u201cDynamic heap memory allocation shall not be used.\u201d&#xff08;\u7981\u6b62\u4f7f\u7528\u52a8\u6001\u5806\u5206\u914d&#xff09;<\/li>\n<li>NASA JPL Rule 3&#xff1a;\u201cAvoid heap memory allocation.\u201d&#xff08;\u907f\u514d\u5806\u5206\u914d&#xff09;<\/li>\n<li>AUTOSAR&#xff1a;\u5141\u8bb8\u521d\u59cb\u5316\u9636\u6bb5\u4f7f\u7528 malloc()&#xff0c;\u4f46\u7981\u6b62\u540e\u7eed\u7684 realloc() \u548c free()&#xff0c;\u4e14\u7981\u6b62\u521d\u59cb\u5316\u540e\u7ee7\u7eed\u52a8\u6001\u5206\u914d\u3002<\/li>\n<\/ul>\n<p>\u4e3a\u4ec0\u4e48\u8fd9\u4e9b\u884c\u4e1a\u5bf9\u5806\u5982\u6b64\u8b66\u60d5&#xff1f;<\/p>\n<h4>5.2 \u5806\u7684&#034;\u539f\u7f6a&#034;<\/h4>\n<p>\u539f\u56e0 1&#xff1a;\u6267\u884c\u65f6\u95f4\u4e0d\u786e\u5b9a<\/p>\n<p>malloc() \u7684\u6267\u884c\u65f6\u95f4\u53d6\u51b3\u4e8e\u5806\u7684\u5f53\u524d\u72b6\u6001\u3002\u5806\u7a7a\u7684\u65f6\u5019\u53ef\u80fd\u5f88\u5feb&#xff0c;\u5806\u788e\u4e86\u4e4b\u540e\u53ef\u80fd\u8981\u904d\u5386\u5f88\u957f\u7684\u7a7a\u95f2\u94fe\u8868\u3002\u5728\u786c\u5b9e\u65f6\u7cfb\u7edf\u91cc&#xff0c;\u6700\u574f\u60c5\u51b5\u6267\u884c\u65f6\u95f4&#xff08;WCET&#xff09;\u5fc5\u987b\u53ef\u5206\u6790&#xff0c;\u800c malloc \u7684 WCET \u51e0\u4e4e\u65e0\u6cd5\u7ed9\u51fa\u6709\u610f\u4e49\u7684\u754c\u3002<\/p>\n<p>\u539f\u56e0 2&#xff1a;\u53ef\u80fd\u5931\u8d25<\/p>\n<p>malloc \u8fd4\u56de NULL \u65f6&#xff0c;\u5982\u679c\u4f60\u6ca1\u68c0\u67e5&#xff0c;\u540e\u9762\u5c31\u662f\u7a7a\u6307\u9488\u89e3\u5f15\u7528\u2014\u2014\u5728\u6c7d\u8f66\u91cc\u53ef\u80fd\u662f\u5239\u8f66\u5931\u7075&#xff0c;\u5728\u533b\u7597\u8bbe\u5907\u91cc\u53ef\u80fd\u662f\u8f93\u6db2\u6cf5\u5931\u63a7\u3002<\/p>\n<p>\u539f\u56e0 3&#xff1a;\u788e\u7247\u5316<\/p>\n<p>\u5047\u8bbe\u5806\u603b\u5171 10KB&#xff0c;\u4f60\u53cd\u590d\u521b\u5efa\u5220\u9664 1KB\u30012KB\u30013KB \u7684\u5bf9\u8c61\u3002\u8dd1\u51e0\u5929\u540e&#xff0c;\u5806\u91cc\u53ef\u80fd\u5168\u662f 100 \u5b57\u8282\u7684\u5c0f\u788e\u7247&#xff0c;\u603b\u7a7a\u95f2 5KB \u4f46\u6ca1\u6709\u4e00\u4e2a\u8fde\u7eed\u5757\u80fd\u653e\u4e0b 1KB\u3002\u8fd9\u79cd\u95ee\u9898\u5728\u5b9e\u9a8c\u5ba4\u91cc\u5f88\u96be\u590d\u73b0&#xff0c;\u4f46\u5728\u73b0\u573a\u8fd0\u884c\u51e0\u4e2a\u6708\u540e\u5c31\u4f1a\u7206\u53d1\u3002<\/p>\n<p>\u539f\u56e0 4&#xff1a;\u5b89\u5168\u6f0f\u6d1e<\/p>\n<p>Use-after-free\u3001double-free \u662f\u653b\u51fb\u8005\u6700\u559c\u6b22\u7684\u6f0f\u6d1e\u7c7b\u578b\u3002\u5806\u5185\u5b58\u88ab\u91ca\u653e\u540e\u5982\u679c\u8fd8\u88ab\u5f15\u7528&#xff0c;\u653b\u51fb\u8005\u53ef\u4ee5\u7cbe\u5fc3\u5e03\u5c40&#xff0c;\u8ba9\u8fd9\u5757\u5185\u5b58\u88ab\u91cd\u65b0\u5206\u914d\u6210\u5173\u952e\u6570\u636e\u7ed3\u6784&#xff0c;\u7136\u540e\u901a\u8fc7\u91ce\u6307\u9488\u7be1\u6539\u5b83\u3002<\/p>\n<h4>5.3 \u9759\u6001\u521b\u5efa\u662f\u552f\u4e00\u5408\u89c4\u9009\u9879<\/h4>\n<p>\u5728\u5b89\u5168\u5173\u952e\u9879\u76ee\u91cc&#xff0c;\u6240\u6709 RTOS \u5bf9\u8c61\u5fc5\u987b\u9759\u6001\u521b\u5efa&#xff1a;<\/p>\n<p><span class=\"token comment\">\/* FreeRTOSConfig.h *\/<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">configSUPPORT_STATIC_ALLOCATION<\/span>     <span class=\"token expression\"><span class=\"token number\">1<\/span><\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">configSUPPORT_DYNAMIC_ALLOCATION<\/span>    <span class=\"token expression\"><span class=\"token number\">0<\/span>   <\/span><span class=\"token comment\">\/\/ \u5f7b\u5e95\u7981\u7528\u52a8\u6001\u5206\u914d<\/span><\/span><\/p>\n<p>\u5f53 configSUPPORT_DYNAMIC_ALLOCATION &#061; 0 \u65f6&#xff0c;xSemaphoreCreateBinary() \u8fd9\u7c7b\u52a8\u6001 API \u6839\u672c\u4e0d\u4f1a\u88ab\u7f16\u8bd1\u8fdb\u53bb&#xff0c;\u4f60\u53ea\u80fd\u7528 xSemaphoreCreateBinaryStatic()\u3002<\/p>\n<p>\u4f46\u6709\u4e00\u4e2a\u5751&#xff1a;FreeRTOS \u7684\u7a7a\u95f2\u4efb\u52a1&#xff08;Idle Task&#xff09;\u548c\u5b9a\u65f6\u5668\u4efb\u52a1&#xff08;Timer Task&#xff09;\u9ed8\u8ba4\u662f\u52a8\u6001\u521b\u5efa\u7684\u3002\u5f53\u4f60\u7981\u7528\u52a8\u6001\u5206\u914d\u65f6&#xff0c;\u5fc5\u987b\u81ea\u5df1\u63d0\u4f9b\u5b83\u4eec\u7684\u5185\u5b58&#xff1a;<\/p>\n<p><span class=\"token comment\">\/* \u5fc5\u987b\u5b9e\u73b0\u8fd9\u4e24\u4e2a\u56de\u8c03\u51fd\u6570 *\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">vApplicationGetIdleTaskMemory<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    StaticTask_t <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>ppxIdleTaskTCBBuffer<span class=\"token punctuation\">,<\/span><br \/>\n    StackType_t <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>ppxIdleTaskStackBuffer<span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token class-name\">uint32_t<\/span> <span class=\"token operator\">*<\/span>pulIdleTaskStackSize<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">static<\/span> StaticTask_t xIdleTaskTCB<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">static<\/span> StackType_t  xIdleTaskStack<span class=\"token punctuation\">[<\/span>configMINIMAL_STACK_SIZE<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token operator\">*<\/span>ppxIdleTaskTCBBuffer   <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&amp;<\/span>xIdleTaskTCB<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token operator\">*<\/span>ppxIdleTaskStackBuffer <span class=\"token operator\">&#061;<\/span> xIdleTaskStack<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token operator\">*<\/span>pulIdleTaskStackSize   <span class=\"token operator\">&#061;<\/span> configMINIMAL_STACK_SIZE<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">vApplicationGetTimerTaskMemory<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    StaticTask_t <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>ppxTimerTaskTCBBuffer<span class=\"token punctuation\">,<\/span><br \/>\n    StackType_t <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>ppxTimerTaskStackBuffer<span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token class-name\">uint32_t<\/span> <span class=\"token operator\">*<\/span>pulTimerTaskStackSize<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">static<\/span> StaticTask_t xTimerTaskTCB<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">static<\/span> StackType_t  xTimerTaskStack<span class=\"token punctuation\">[<\/span>configTIMER_TASK_STACK_DEPTH<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token operator\">*<\/span>ppxTimerTaskTCBBuffer   <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&amp;<\/span>xTimerTaskTCB<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token operator\">*<\/span>ppxTimerTaskStackBuffer <span class=\"token operator\">&#061;<\/span> xTimerTaskStack<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token operator\">*<\/span>pulTimerTaskStackSize   <span class=\"token operator\">&#061;<\/span> configTIMER_TASK_STACK_DEPTH<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e0d\u5b9e\u73b0&#xff0c;\u94fe\u63a5\u65f6\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u989d\u5916\u7684\u786e\u5b9a\u6027\u4f18\u52bf&#xff1a;\u9759\u6001\u521b\u5efa\u540e&#xff0c;\u6240\u6709\u5185\u5b58\u90fd\u5728\u94fe\u63a5\u671f\u786e\u5b9a\u3002\u4f60\u53ef\u4ee5\u76f4\u63a5\u4ece .map \u6587\u4ef6\u91cc\u770b\u5230\u6bcf\u4e2a\u5bf9\u8c61\u5360\u4e86\u591a\u5c11 RAM&#xff0c;\u6574\u4e2a\u7cfb\u7edf\u7684 RAM \u4f7f\u7528\u4e00\u76ee\u4e86\u7136\u3002\u6ca1\u6709\u8fd0\u884c\u65f6\u60ca\u559c\u3002<\/p>\n<h3>\u7b2c\u516d\u90e8\u5206&#xff1a;\u5b9e\u6218\u600e\u4e48\u9009&#xff1f;\u4e00\u53e5\u8bdd\u51b3\u7b56\u8868<\/h3>\n<table>\n<tr>\u4f60\u7684\u573a\u666f\u63a8\u8350\u65b9\u6848\u7406\u7531<\/tr>\n<tbody>\n<tr>\n<td>\u5b66\u4e60\u3001\u505a\u5c0f\u9879\u76ee\u3001\u5feb\u901f\u539f\u578b<\/td>\n<td>\u52a8\u6001\u521b\u5efa &#043; \u5168\u5c40\u53e5\u67c4<\/td>\n<td>\u4ee3\u7801\u6700\u5c11&#xff0c;\u6559\u7a0b\u6700\u591a&#xff0c;\u51fa\u95ee\u9898\u597d\u67e5<\/td>\n<\/tr>\n<tr>\n<td>\u6a21\u5757\u5316\u8bbe\u8ba1&#xff0c;\u540c\u4e00\u4efb\u52a1\u6a21\u677f\u670d\u52a1\u591a\u5957\u8d44\u6e90<\/td>\n<td>\u52a8\u6001\/\u9759\u6001\u521b\u5efa &#043; \u53e5\u67c4\u4f20\u53c2<\/td>\n<td>\u4ee3\u7801\u89e3\u8026&#xff0c;\u4e0d\u4f9d\u8d56\u5168\u5c40\u53d8\u91cf<\/td>\n<\/tr>\n<tr>\n<td>\u5927\u9879\u76ee\u91cc\u7684\u9a71\u52a8\u6a21\u5757\u5185\u90e8<\/td>\n<td>\u6587\u4ef6\u7ea7 static \u53e5\u67c4<\/td>\n<td>\u6a21\u5757\u5185\u805a&#xff0c;\u5916\u90e8\u65e0\u611f\u77e5&#xff0c;\u6700\u7b80\u5355<\/td>\n<\/tr>\n<tr>\n<td>\u6c7d\u8f66 ASIL\u3001\u533b\u7597\u3001\u822a\u7a7a<\/td>\n<td>\u5f3a\u5236\u9759\u6001\u521b\u5efa<\/td>\n<td>\u5408\u89c4\u8981\u6c42&#xff0c;\u786e\u5b9a\u6027\u7b2c\u4e00<\/td>\n<\/tr>\n<tr>\n<td>\u957f\u671f\u8fd0\u884c\u3001\u4e0d\u80fd\u91cd\u542f\u7684\u8bbe\u5907<\/td>\n<td>\u9759\u6001\u521b\u5efa<\/td>\n<td>\u907f\u514d\u788e\u7247\u548c\u6cc4\u6f0f\u7d2f\u79ef<\/td>\n<\/tr>\n<tr>\n<td>RAM \u6781\u5ea6\u7d27\u5f20&#xff0c;\u9700\u8981\u7cbe\u7ec6\u63a7\u5236<\/td>\n<td>\u9759\u6001\u521b\u5efa<\/td>\n<td>\u94fe\u63a5\u671f\u786e\u5b9a&#xff0c;\u4e0d\u6d6a\u8d39\u5806\u7ba1\u7406\u5f00\u9500<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u53e5\u8bdd\u603b\u7ed3&#xff1a;<\/p>\n<p>\u666e\u901a\u5e94\u7528&#xff1a;\u52a8\u6001\u521b\u5efa &#043; \u5168\u5c40\u53e5\u67c4\u662f\u6700\u5e38\u89c1\u8d77\u624b\u5f0f&#xff1b;\u6a21\u5757\u5316\u6216\u590d\u7528\u573a\u666f&#xff1a;\u53c2\u6570\u4f20\u9012\u66f4\u5e72\u51c0&#xff1b;\u5b89\u5168\u5173\u952e&#xff1a;\u5f3a\u5236\u9759\u6001\u521b\u5efa\u3002\u9009\u54ea\u79cd&#xff0c;\u53d6\u51b3\u4e8e\u9879\u76ee\u5bf9\u786e\u5b9a\u6027\u548c\u4ee3\u7801\u6574\u6d01\u5ea6\u7684\u8981\u6c42\u3002<\/p>\n<h3>\u7b2c\u4e03\u90e8\u5206&#xff1a;\u51e0\u4e2a\u5bb9\u6613\u6df7\u6dc6\u7684\u70b9&#xff0c;\u4e00\u6b21\u8bf4\u6e05<\/h3>\n<h4>7.1 \u201c\u4fe1\u53f7\u91cf\u662f\u5168\u5c40\u53d8\u91cf\u5417&#xff1f;\u201d<\/h4>\n<p>\u4e0d\u662f\u3002 \u5168\u5c40\u7684\u5f80\u5f80\u53ea\u662f\u53e5\u67c4&#xff08;\u4e00\u4e2a\u6307\u9488&#xff09;\u3002\u4fe1\u53f7\u91cf\u7684\u672c\u4f53\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53&#xff0c;\u52a8\u6001\u521b\u5efa\u65f6\u5728\u5806\u91cc&#xff0c;\u9759\u6001\u521b\u5efa\u65f6\u5728\u5168\u5c40\/\u9759\u6001\u533a&#xff08;\u7531\u4f60\u63d0\u4f9b\u7684 StaticSemaphore_t \u53d8\u91cf&#xff09;\u3002<\/p>\n<h4>7.2 \u201c\u52a8\u6001\u521b\u5efa\u540e\u5fd8\u8bb0\u5220\u9664&#xff0c;\u4f1a\u600e\u6837&#xff1f;\u201d<\/h4>\n<p>\u5185\u5b58\u6cc4\u6f0f\u3002 \u5806\u91cc\u90a3\u5757 Queue_t \u7ed3\u6784\u4f53\u6c38\u8fdc\u627e\u4e0d\u56de\u6765\u4e86\u3002\u5982\u679c\u53cd\u590d\u521b\u5efa\u4e0d\u5220\u9664&#xff0c;\u5806\u6700\u7ec8\u4f1a\u8017\u5c3d\u3002\u9759\u6001\u521b\u5efa\u4e0d\u5b58\u5728\u8fd9\u4e2a\u95ee\u9898\u2014\u2014\u672c\u4f53\u53d8\u91cf\u4e00\u76f4\u5728\u5168\u5c40\u533a&#xff0c;\u53ea\u662f\u4f60\u4e0d\u7528\u4e86\u800c\u5df2&#xff0c;\u4e0d\u4f1a&#034;\u6cc4\u6f0f&#034;&#xff08;\u4f46\u4e5f\u4e0d\u4f1a\u88ab\u56de\u6536&#xff09;\u3002<\/p>\n<h4>7.3 \u201c\u9759\u6001\u521b\u5efa\u7684\u5bf9\u8c61\u80fd\u5220\u9664\u5417&#xff1f;\u201d<\/h4>\n<p>\u6ca1\u6709 vSemaphoreDeleteStatic() \u8fd9\u79cd API\u3002 \u9759\u6001\u521b\u5efa\u7684\u5bf9\u8c61\u4e0d\u9700\u8981\u5220\u9664\u2014\u2014\u5185\u5b58\u662f\u7f16\u8bd1\u5668\u5206\u914d\u7684&#xff0c;\u4f60\u65e0\u6cd5&#034;\u91ca\u653e&#034;\u5b83\u3002\u5982\u679c\u4f60\u4e0d\u60f3\u7528\u4e86&#xff0c;\u76f4\u63a5\u4e0d\u518d\u5f15\u7528\u5b83\u5c31\u884c\u3002<\/p>\n<h4>7.4 \u201c\u53e5\u67c4\u4e22\u4e86&#xff0c;\u672c\u4f53\u8fd8\u5728\u5417&#xff1f;\u201d<\/h4>\n<ul>\n<li>\u52a8\u6001\u521b\u5efa&#xff1a;\u53e5\u67c4\u4e22\u4e86&#xff0c;\u672c\u4f53\u8fd8\u5728\u5806\u91cc&#xff0c;\u4f46\u6ca1\u4eba\u80fd\u5f15\u7528\u5b83 \u2192 \u6cc4\u6f0f\u3002<\/li>\n<li>\u9759\u6001\u521b\u5efa&#xff1a;\u53e5\u67c4\u4e22\u4e86&#xff0c;\u672c\u4f53\u8fd8\u5728\u5168\u5c40\u533a&#xff0c;\u7a0b\u5e8f\u7ed3\u675f\u524d\u4e00\u76f4\u5360\u7740 \u2192 \u4e0d\u7b97\u6cc4\u6f0f&#xff0c;\u4f46\u6d6a\u8d39\u3002<\/li>\n<\/ul>\n<h4>7.5 \u201c\u4e3a\u4ec0\u4e48\u9759\u6001\u521b\u5efa\u4efb\u52a1\u65f6&#xff0c;\u6808\u5927\u5c0f\u5355\u4f4d\u662f\u5b57\u4e0d\u662f\u5b57\u8282&#xff1f;\u201d<\/h4>\n<p>\u8fd9\u662f FreeRTOS \u7684\u5386\u53f2\u8bbe\u8ba1\u3002usStackDepth \u8868\u793a&#034;\u6808\u80fd\u5bb9\u7eb3\u591a\u5c11\u4e2a StackType_t&#034;\u3002\u5728 32 \u4f4d MCU \u4e0a&#xff0c;StackType_t \u662f uint32_t&#xff0c;\u6240\u4ee5 128 \u5b57\u7684\u6808 &#061; 512 \u5b57\u8282\u3002\u5199\u4ee3\u7801\u65f6\u4e00\u5b9a\u8981\u6ce8\u610f\u8fd9\u4e2a\u5355\u4f4d&#xff0c;\u5426\u5219\u6808\u53ef\u80fd\u5f00\u5c0f\u4e86\u4e00\u534a\u3002<\/p>\n<h3>\u7ed3\u8bed&#xff1a;\u4ece&#034;\u4f1a\u7528&#034;\u5230&#034;\u7528\u597d&#034;<\/h3>\n<p>FreeRTOS \u7684&#034;\u521b\u5efa&#034;\u4e8c\u5b57&#xff0c;\u8fdc\u4e0d\u6b62\u8c03\u7528\u4e00\u4e2a API \u90a3\u4e48\u7b80\u5355\u3002\u5b83\u80cc\u540e\u662f&#xff1a;<\/p>\n<ul>\n<li>\u5806\u4e0e\u9759\u6001\u533a\u7684\u5185\u5b58\u6289\u62e9\u2014\u2014\u4f60\u7684\u5bf9\u8c61\u4f4f\u5728\u54ea&#xff0c;\u51b3\u5b9a\u4e86\u5b83\u7684\u786e\u5b9a\u6027\u548c\u751f\u547d\u5468\u671f\u3002<\/li>\n<li>\u53e5\u67c4\u751f\u547d\u5468\u671f\u4e0e\u4f5c\u7528\u57df\u7684\u7cbe\u5bc6\u8bbe\u8ba1\u2014\u2014\u53e5\u67c4\u6d3b\u591a\u4e45&#xff0c;\u5fc5\u987b\u8986\u76d6\u7528\u5b83\u7684\u4ee3\u7801\u6d3b\u591a\u4e45\u3002<\/li>\n<li>\u5b9e\u65f6\u7cfb\u7edf\u5bf9\u786e\u5b9a\u6027\u7684\u4e0d\u61c8\u8ffd\u6c42\u2014\u2014\u5b89\u5168\u5173\u952e\u9886\u57df&#034;\u4e0d\u78b0\u5806&#034;&#xff0c;\u4e0d\u662f\u5efa\u8bae&#xff0c;\u662f\u94c1\u5f8b\u3002<\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u53ea\u8bb0\u4f4f\u4e09\u53e5\u8bdd&#xff0c;\u8bf7\u8bb0\u4f4f&#xff1a;<\/p>\n<li>\u521b\u5efa\u65f6\u5206\u914d&#xff0c;\u8fd0\u884c\u65f6\u96f6\u5806\u2014\u2014\u4e0d\u786e\u5b9a\u6027\u96c6\u4e2d\u5728\u521d\u59cb\u5316\u9636\u6bb5\u3002<\/li>\n<li>\u53e5\u67c4\u751f\u547d\u5468\u671f \u2265 \u4f7f\u7528\u5b83\u7684\u4ee3\u7801\u751f\u547d\u5468\u671f\u2014\u2014\u653e\u9519\u4e86\u5c31\u662f\u91ce\u6307\u9488\u3002<\/li>\n<li>\u5b89\u5168\u5173\u952e\u9886\u57df&#xff0c;\u9759\u6001\u521b\u5efa\u662f\u552f\u4e00\u5408\u89c4\u9009\u9879\u2014\u2014\u786e\u5b9a\u6027\u6bd4\u4fbf\u5229\u66f4\u91cd\u8981\u3002<\/li>\n<p>\u4ece&#034;\u4f1a\u7528 FreeRTOS&#034;\u5230&#034;\u7528\u597d FreeRTOS&#034;&#xff0c;\u5206\u6c34\u5cad\u5c31\u5728\u8fd9\u4e9b\u5185\u5b58\u7ec6\u8282\u91cc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790<br \/>\n\u5f15\u8a00<br \/>\n\u5982\u679c\u4f60\u5b66\u8fc7\u5355\u7247\u673a&#xff0c;\u5199\u8fc7 C \u8bed\u8a00&#xff0c;\u77e5\u9053\u4ec0\u4e48\u662f int\u3001\u4ec0\u4e48\u662f\u6307\u9488\u3001\u4ec0\u4e48\u662f\u7ed3\u6784\u4f53&#xff0c;\u4f46\u4e00\u542c\u5230\\&#8221;RTOS\\&#8221;\u201c\u4fe1\u53f7\u91cf\u201d\u201c\u5806\u533a\u201d\\&#8221;\u9759\u6001\u521b\u5efa\\&#8221;\u5c31\u6709\u70b9\u53d1\u6035\u2014\u2014\u8fd9\u7bc7\u6587\u7ae0\u5c31\u662f\u4e3a\u4f60\u5199\u7684\u3002<br \/>\n\u6211\u4eec\u4e0d\u5806\u780c\u672f\u8bed&#xff0c;\u4e0d\u5047\u8bbe\u4f60\u61c2\u64cd\u4f5c\u7cfb\u7edf\u3002\u6211\u4eec\u4ece\u4f60\u6700\u719f\u6089\u7684 C \u8bed\u8a00\u548c\u5355\u7247\u673a\u5185\u5b58\u6a21\u578b\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u628a FreeRTOS \u91cc\u90a3\u4e9b\\&#8221;\u542c\u8d77\u6765\u5f88\u7384\\&#8221;\u7684\u6982\u5ff5&#xff0c;<\/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":[174,220],"topic":[],"class_list":["post-115285","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-220"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 - \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\/115285.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 \u5f15\u8a00 \u5982\u679c\u4f60\u5b66\u8fc7\u5355\u7247\u673a&#xff0c;\u5199\u8fc7 C \u8bed\u8a00&#xff0c;\u77e5\u9053\u4ec0\u4e48\u662f int\u3001\u4ec0\u4e48\u662f\u6307\u9488\u3001\u4ec0\u4e48\u662f\u7ed3\u6784\u4f53&#xff0c;\u4f46\u4e00\u542c\u5230&quot;RTOS&quot;\u201c\u4fe1\u53f7\u91cf\u201d\u201c\u5806\u533a\u201d&quot;\u9759\u6001\u521b\u5efa&quot;\u5c31\u6709\u70b9\u53d1\u6035\u2014\u2014\u8fd9\u7bc7\u6587\u7ae0\u5c31\u662f\u4e3a\u4f60\u5199\u7684\u3002 \u6211\u4eec\u4e0d\u5806\u780c\u672f\u8bed&#xff0c;\u4e0d\u5047\u8bbe\u4f60\u61c2\u64cd\u4f5c\u7cfb\u7edf\u3002\u6211\u4eec\u4ece\u4f60\u6700\u719f\u6089\u7684 C \u8bed\u8a00\u548c\u5355\u7247\u673a\u5185\u5b58\u6a21\u578b\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u628a FreeRTOS \u91cc\u90a3\u4e9b&quot;\u542c\u8d77\u6765\u5f88\u7384&quot;\u7684\u6982\u5ff5&#xff0c;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115285.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-11T11:56:55+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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115285.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115285.html\",\"name\":\"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-11T11:56:55+00:00\",\"dateModified\":\"2026-10-11T11:56:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115285.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115285.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115285.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790\"}]},{\"@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":"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 - \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\/115285.html","og_locale":"zh_CN","og_type":"article","og_title":"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 \u5f15\u8a00 \u5982\u679c\u4f60\u5b66\u8fc7\u5355\u7247\u673a&#xff0c;\u5199\u8fc7 C \u8bed\u8a00&#xff0c;\u77e5\u9053\u4ec0\u4e48\u662f int\u3001\u4ec0\u4e48\u662f\u6307\u9488\u3001\u4ec0\u4e48\u662f\u7ed3\u6784\u4f53&#xff0c;\u4f46\u4e00\u542c\u5230\"RTOS\"\u201c\u4fe1\u53f7\u91cf\u201d\u201c\u5806\u533a\u201d\"\u9759\u6001\u521b\u5efa\"\u5c31\u6709\u70b9\u53d1\u6035\u2014\u2014\u8fd9\u7bc7\u6587\u7ae0\u5c31\u662f\u4e3a\u4f60\u5199\u7684\u3002 \u6211\u4eec\u4e0d\u5806\u780c\u672f\u8bed&#xff0c;\u4e0d\u5047\u8bbe\u4f60\u61c2\u64cd\u4f5c\u7cfb\u7edf\u3002\u6211\u4eec\u4ece\u4f60\u6700\u719f\u6089\u7684 C \u8bed\u8a00\u548c\u5355\u7247\u673a\u5185\u5b58\u6a21\u578b\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u628a FreeRTOS \u91cc\u90a3\u4e9b\"\u542c\u8d77\u6765\u5f88\u7384\"\u7684\u6982\u5ff5&#xff0c;","og_url":"https:\/\/www.wsisp.com\/helps\/115285.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-11T11:56:55+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115285.html","url":"https:\/\/www.wsisp.com\/helps\/115285.html","name":"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-11T11:56:55+00:00","dateModified":"2026-10-11T11:56:55+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115285.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115285.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115285.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"FreeRTOS \u4fe1\u53f7\u91cf\u3001\u961f\u5217\u4e0e\u5185\u5b58\u5206\u914d\u7684\u672c\u8d28\u5173\u7cfb\u2014\u2014\u4ece\u5806\u533a\u5230\u9759\u6001\u521b\u5efa\u7684\u6df1\u5ea6\u5256\u6790"}]},{"@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\/115285","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=115285"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115285\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115285"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}