]> git.sur5r.net Git - freertos/commitdiff
Core kernel code:
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 29 Aug 2014 13:53:58 +0000 (13:53 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 29 Aug 2014 13:53:58 +0000 (13:53 +0000)
- Re-introduce the ability to give a mutex from an ISR.

Common demo code:
- Add additional tests into the GenQTest files for priority inheritance and using a mutex from an ISR.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2294 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

13 files changed:
FreeRTOS/Demo/CORTEX_A5_SAMA5D3x_Xplained_IAR/settings/RTOSDemo.dbgdt
FreeRTOS/Demo/CORTEX_A5_SAMA5D3x_Xplained_IAR/settings/RTOSDemo.dni
FreeRTOS/Demo/CORTEX_A5_SAMA5D3x_Xplained_IAR/settings/RTOSDemo.wsdt
FreeRTOS/Demo/Common/Minimal/GenQTest.c
FreeRTOS/Demo/Common/Minimal/TimerDemo.c
FreeRTOS/Demo/Common/include/GenQTest.h
FreeRTOS/Demo/WIN32-MSVC/main.c
FreeRTOS/Demo/WIN32-MSVC/main_full.c
FreeRTOS/Source/include/projdefs.h
FreeRTOS/Source/include/task.h
FreeRTOS/Source/list.c
FreeRTOS/Source/queue.c
FreeRTOS/Source/tasks.c

index d3d797e57f9770f947ddb3d5d50b7b40df69fdf9..4e6cebfa947958ebead90979d42151f064e073bc 100644 (file)
         \r
         \r
       <PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><ShowCodeCoverage>1</ShowCodeCoverage><ShowInstrProfiling>1</ShowInstrProfiling></Disassembly>\r
-    <Register><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Register><WATCH_1><expressions><item></item></expressions><col-names><item>Expression</item><item>Location</item><item>Type</item><item>Value</item></col-names><col-widths><item>207</item><item>150</item><item>100</item><item>294</item></col-widths><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></WATCH_1><CallStack><PreferedWindows><Position>1</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Frame</item><item>_I0</item></col-names><col-widths><item>400</item><item>20</item></col-widths></CallStack><Breakpoints><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Breakpoint</item><item>_I0</item></col-names><col-widths><item>500</item><item>35</item></col-widths></Breakpoints><Find-in-Files><ColumnWidth0>497</ColumnWidth0><ColumnWidth1>82</ColumnWidth1><ColumnWidth2>746</ColumnWidth2><ColumnWidth3>331</ColumnWidth3><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows><Window><Factory>Debug-Log</Factory></Window><Window><Factory>Build</Factory></Window></Windows></PreferedWindows></Find-in-Files><QuickWatch><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Expression</item><item>Location</item><item>Type</item><item>Value</item></col-names><col-widths><item>100</item><item>150</item><item>100</item><item>100</item></col-widths><QWatchHistory><item>TC0</item><item>TC0-&gt;TC_CHANNEL[ tmrTC0_CHANNEL_0 ].TC_RC</item></QWatchHistory></QuickWatch><Memory><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><FindDirection>1</FindDirection><FindAsHex>0</FindAsHex></Memory><TASKVIEW><Column0>200</Column0><Column1>100</Column1><Column2>100</Column2><Column3>100</Column3><Column4>100</Column4><Column5>100</Column5><Column6>100</Column6><Column7>100</Column7><Column8>150</Column8></TASKVIEW><QUEUEVIEW><Column0>200</Column0><Column1>100</Column1><Column2>100</Column2><Column3>100</Column3><Column4>100</Column4><Column5>100</Column5><Column6>100</Column6></QUEUEVIEW></Static>\r
+    <Register><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Register><WATCH_1><expressions><item/></expressions><col-names><item>Expression</item><item>Location</item><item>Type</item><item>Value</item></col-names><col-widths><item>207</item><item>150</item><item>100</item><item>294</item></col-widths><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></WATCH_1><CallStack><PreferedWindows><Position>1</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Frame</item><item>_I0</item></col-names><col-widths><item>400</item><item>20</item></col-widths></CallStack><Breakpoints><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Breakpoint</item><item>_I0</item></col-names><col-widths><item>500</item><item>35</item></col-widths></Breakpoints><Find-in-Files><ColumnWidth0>497</ColumnWidth0><ColumnWidth1>82</ColumnWidth1><ColumnWidth2>746</ColumnWidth2><ColumnWidth3>331</ColumnWidth3><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows><Window><Factory>Debug-Log</Factory></Window><Window><Factory>Build</Factory></Window></Windows></PreferedWindows></Find-in-Files><QuickWatch><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Expression</item><item>Location</item><item>Type</item><item>Value</item></col-names><col-widths><item>100</item><item>150</item><item>100</item><item>100</item></col-widths><QWatchHistory><item>TC0</item><item>TC0-&gt;TC_CHANNEL[ tmrTC0_CHANNEL_0 ].TC_RC</item></QWatchHistory></QuickWatch><Memory><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><FindDirection>1</FindDirection><FindAsHex>0</FindAsHex></Memory><TASKVIEW><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><Column0>200</Column0><Column1>100</Column1><Column2>100</Column2><Column3>100</Column3><Column4>100</Column4><Column5>100</Column5><Column6>100</Column6><Column7>100</Column7><Column8>150</Column8></TASKVIEW><QUEUEVIEW><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><Column0>300</Column0><Column1>100</Column1><Column2>100</Column2><Column3>100</Column3><Column4>100</Column4><Column5>100</Column5><Column6>100</Column6></QUEUEVIEW></Static>\r
     <Windows>\r
       \r
       \r
       \r
-    <Wnd1>\r
+    <Wnd0>\r
         <Tabs>\r
           <Tab>\r
             <Identity>TabID-24673-23877</Identity>\r
           </Tab>\r
         </Tabs>\r
         \r
-      <SelectedTab>0</SelectedTab></Wnd1><Wnd2><Tabs><Tab><Identity>TabID-22902-32031</Identity><TabName>Tasks</TabName><Factory>TASKVIEW</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd2><Wnd3><Tabs><Tab><Identity>TabID-22379-32041</Identity><TabName>Queues</TabName><Factory>QUEUEVIEW</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd3></Windows>\r
+      <SelectedTab>0</SelectedTab></Wnd0><Wnd5><Tabs><Tab><Identity>TabID-31713-7906</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd5></Windows>\r
     <Editor>\r
       \r
       \r
       \r
       \r
-    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>140</YPos2><SelStart2>7249</SelStart2><SelEnd2>7249</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\blinky_demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>1373</SelStart2><SelEnd2>1373</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\portASM.s</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>73</YPos2><SelStart2>3799</SelStart2><SelEnd2>3799</SelEnd2></Tab><ActiveTab>3</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
+    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>127</YPos2><SelStart2>6411</SelStart2><SelEnd2>6411</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\blinky_demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>1373</SelStart2><SelEnd2>1373</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Common\Minimal\GenQTest.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>796</YPos2><SelStart2>27238</SelStart2><SelEnd2>27238</SelEnd2></Tab><ActiveTab>3</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
     <Positions>\r
       \r
       \r
       \r
       \r
       \r
-    <Top><Row0><Sizes><Toolbar-0111A108><key>iaridepm.enu1</key></Toolbar-0111A108></Sizes></Row0><Row1><Sizes><Toolbar-222ED2A8><key>debuggergui.enu1</key></Toolbar-222ED2A8></Sizes></Row1></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>520</Bottom><Right>332</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>198810</sizeVertCX><sizeVertCY>530488</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd2></Sizes></Row0><Row1><Sizes><Wnd3><Rect><Top>196</Top><Left>-2</Left><Bottom>396</Bottom><Right>1682</Right><x>-2</x><y>196</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd3></Sizes></Row1></Bottom><Float><Sizes/></Float></Positions>\r
+    <Top><Row0><Sizes><Toolbar-011172A8><key>iaridepm.enu1</key></Toolbar-011172A8></Sizes></Row0><Row1><Sizes><Toolbar-07251300><key>debuggergui.enu1</key></Toolbar-07251300></Sizes></Row1></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>332</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>198810</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd5><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd5></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
   </Desktop>\r
 </Project>\r
 \r
index e66f27a2b9c029cd60130722c3d31d9dca86d9d7..b4bbf9110df9e7391869d46d65b0a9b6393f3a3f 100644 (file)
@@ -14,7 +14,7 @@ Watch0=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0
 Watch1=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0\r
 CStepIntDis=_ 0\r
 [DebugChecksum]\r
-Checksum=-666464609\r
+Checksum=-1280642381\r
 [Exceptions]\r
 StopOnUncaught=_ 0\r
 StopOnThrow=_ 0\r
@@ -42,7 +42,7 @@ Exclusions=
 [Disassemble mode]\r
 mode=0\r
 [Breakpoints2]\r
-Bp0=_ 1 "EMUL_CODE" "{$PROJ_DIR$\main.c}.218.24" 0 0 1 "" 0 "" 0\r
+Bp0=_ 1 "EMUL_CODE" "{$PROJ_DIR$\main.c}.221.2" 0 0 1 "" 0 "" 0\r
 Count=1\r
 [Aliases]\r
 Count=0\r
index a7cc6f063d115b41bc4d7507a6fe2412b00cbc09..76656626fc233d6f87a2b09da4a2415ca3b6d7e8 100644 (file)
@@ -36,7 +36,7 @@
     <Windows>\r
       \r
       \r
-    <Wnd1>\r
+    <Wnd0>\r
         <Tabs>\r
           <Tab>\r
             <Identity>TabID-22351-19008</Identity>\r
@@ -48,7 +48,7 @@
           </Tab>\r
         </Tabs>\r
         \r
-      <SelectedTab>0</SelectedTab></Wnd1><Wnd4>\r
+      <SelectedTab>0</SelectedTab></Wnd0><Wnd2>\r
         <Tabs>\r
           <Tab>\r
             <Identity>TabID-21076-19237</Identity>\r
           </Tab>\r
         <Tab><Identity>TabID-23502-23081</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab><Tab><Identity>TabID-24431-23894</Identity><TabName>Ambiguous Definitions</TabName><Factory>Select-Ambiguous-Definitions</Factory><Session/></Tab><Tab><Identity>TabID-9033-6116</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs>\r
         \r
-      <SelectedTab>0</SelectedTab></Wnd4></Windows>\r
+      <SelectedTab>0</SelectedTab></Wnd2></Windows>\r
     <Editor>\r
       \r
       \r
       \r
       \r
-    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>59</YPos2><SelStart2>7249</SelStart2><SelEnd2>7249</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\blinky_demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>1373</SelStart2><SelEnd2>1373</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
+    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>5074</SelStart2><SelEnd2>5074</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\blinky_demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>1373</SelStart2><SelEnd2>1373</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
     <Positions>\r
       \r
       \r
       \r
       \r
       \r
-    <Top><Row0><Sizes><Toolbar-0111A108><key>iaridepm.enu1</key></Toolbar-0111A108></Sizes></Row0></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>668</Bottom><Right>352</Right><x>-2</x><y>-2</y><xscreen>190</xscreen><yscreen>170</yscreen><sizeHorzCX>113095</sizeHorzCX><sizeHorzCY>172764</sizeHorzCY><sizeVertCX>210714</sizeVertCX><sizeVertCY>680894</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd4><Rect><Top>-2</Top><Left>-2</Left><Bottom>272</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>274</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>278455</sizeHorzCY><sizeVertCX>113095</sizeVertCX><sizeVertCY>172764</sizeVertCY></Rect></Wnd4></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
+    <Top><Row0><Sizes><Toolbar-011172A8><key>iaridepm.enu1</key></Toolbar-011172A8></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>668</Bottom><Right>352</Right><x>-2</x><y>-2</y><xscreen>190</xscreen><yscreen>170</yscreen><sizeHorzCX>113095</sizeHorzCX><sizeHorzCY>172764</sizeHorzCY><sizeVertCX>210714</sizeVertCX><sizeVertCY>680894</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>272</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>274</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>278455</sizeHorzCY><sizeVertCX>113095</sizeVertCX><sizeVertCY>172764</sizeVertCY></Rect></Wnd2></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
   </Desktop>\r
 </Workspace>\r
 \r
index 59e176b1695ef4d330a2ba41e46046acea1ecdee..bd5bbba91a7288ad87d757cfa10d08070772aa3f 100644 (file)
@@ -93,6 +93,7 @@
 #define genqMUTEX_MEDIUM_PRIORITY      ( tskIDLE_PRIORITY + 2 )\r
 #define genqMUTEX_HIGH_PRIORITY                ( tskIDLE_PRIORITY + 3 )\r
 \r
+#define genqINTERRUPT_MUTEX_GIVE_PERIOD_MS ( 100 )\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -121,6 +122,28 @@ static void prvLowPriorityMutexTask( void *pvParameters );
 static void prvMediumPriorityMutexTask( void *pvParameters );\r
 static void prvHighPriorityMutexTask( void *pvParameters );\r
 \r
+/*\r
+ * Exercises the priority inheritance when a task takes two mutexes, returning\r
+ * them in a different order to which they were taken.\r
+ */\r
+static void prvTakeTwoMutexesReturnInDifferentOrder( SemaphoreHandle_t xMutex, SemaphoreHandle_t xLocalMutex );\r
+\r
+/*\r
+ * Exercises the priority inheritance when a task takes two mutexes, returning\r
+ * them in the same order in which they were taken.\r
+ */\r
+static void prvTakeTwoMutexesReturnInSameOrder( SemaphoreHandle_t xMutex, SemaphoreHandle_t xLocalMutex );\r
+\r
+/*\r
+ * Task that receives an a mutex that is given from an interrupt - although\r
+ * generally mutexes should not be used given in interrupts (and definitely\r
+ * never taken in an interrupt) there are some circumstances when it may be\r
+ * desirable.  NOTE:  This function is not declared static to prevent compiler\r
+ * warnings being generated in demos where the function is declared but not\r
+ * used.\r
+ */\r
+void vInterruptMutexTask( void *pvParameters );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Flag that will be latched to pdTRUE should any unexpected behaviour be\r
@@ -139,6 +162,11 @@ static volatile uint32_t ulGuardedVariable = 0;
 priority mutex test tasks. */\r
 static TaskHandle_t xHighPriorityMutexTask, xMediumPriorityMutexTask;\r
 \r
+/* A mutex which is given from an interrupt - although generally mutexes should\r
+not be used given in interrupts (and definitely never taken in an interrupt)\r
+there are some circumstances when it may be desirable. */\r
+static SemaphoreHandle_t xISRMutex = NULL;\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 void vStartGenericQueueTasks( UBaseType_t uxPriority )\r
@@ -146,6 +174,9 @@ void vStartGenericQueueTasks( UBaseType_t uxPriority )
 QueueHandle_t xQueue;\r
 SemaphoreHandle_t xMutex;\r
 \r
+       xISRMutex = xSemaphoreCreateMutex();\r
+       configASSERT( xISRMutex );\r
+\r
        /* Create the queue that we are going to use for the\r
        prvSendFrontAndBackTest demo. */\r
        xQueue = xQueueCreate( genqQUEUE_LENGTH, sizeof( uint32_t ) );\r
@@ -180,6 +211,14 @@ SemaphoreHandle_t xMutex;
        xTaskCreate( prvLowPriorityMutexTask, "MuLow", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_LOW_PRIORITY, NULL );\r
        xTaskCreate( prvMediumPriorityMutexTask, "MuMed", configMINIMAL_STACK_SIZE, NULL, genqMUTEX_MEDIUM_PRIORITY, &xMediumPriorityMutexTask );\r
        xTaskCreate( prvHighPriorityMutexTask, "MuHigh", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_HIGH_PRIORITY, &xHighPriorityMutexTask );\r
+\r
+       /* Only when the windows simulator is being used - create the task that\r
+       receives a mutex from an interrupt. */\r
+       #ifdef _WINDOWS_\r
+       {\r
+               xTaskCreate( vInterruptMutexTask, "IntMu", configMINIMAL_STACK_SIZE, NULL, genqMUTEX_MEDIUM_PRIORITY, NULL );\r
+       }\r
+       #endif /* __WINDOWS__ */\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -411,150 +450,286 @@ QueueHandle_t xQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvLowPriorityMutexTask( void *pvParameters )\r
+static void prvTakeTwoMutexesReturnInDifferentOrder( SemaphoreHandle_t xMutex, SemaphoreHandle_t xLocalMutex )\r
 {\r
-SemaphoreHandle_t xMutex = ( SemaphoreHandle_t ) pvParameters, xLocalMutex;\r
+       /* Take the mutex.  It should be available now. */\r
+       if( xSemaphoreTake( xMutex, genqNO_BLOCK ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-       #ifdef USE_STDIO\r
-       void vPrintDisplayMessage( const char * const * ppcMessageToSend );\r
+       /* Set the guarded variable to a known start value. */\r
+       ulGuardedVariable = 0;\r
 \r
-               const char * const pcTaskStartMsg = "Mutex with priority inheritance test started.\r\n";\r
+       /* This task's priority should be as per that assigned when the task was\r
+       created. */\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* Queue a message for printing to say the task has started. */\r
-               vPrintDisplayMessage( &pcTaskStartMsg );\r
+       /* Now unsuspend the high priority task.  This will attempt to take the\r
+       mutex, and block when it finds it cannot obtain it. */\r
+       vTaskResume( xHighPriorityMutexTask );\r
+\r
+       #if configUSE_PREEMPTION == 0\r
+               taskYIELD();\r
        #endif\r
 \r
-       /* The local mutex is used to check the 'mutexs held' count. */\r
-       xLocalMutex = xSemaphoreCreateMutex();\r
-       configASSERT( xLocalMutex );\r
+       /* Ensure the task is reporting its priority as blocked and not\r
+       suspended (as it would have done in versions up to V7.5.3). */\r
+       #if( INCLUDE_eTaskGetState == 1 )\r
+       {\r
+               configASSERT( eTaskGetState( xHighPriorityMutexTask ) == eBlocked );\r
+       }\r
+       #endif /* INCLUDE_eTaskGetState */\r
 \r
-       for( ;; )\r
+       /* The priority of the high priority task should now have been inherited\r
+       as by now it will have attempted to get the mutex. */\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
        {\r
-               /* Take the mutex.  It should be available now. */\r
-               if( xSemaphoreTake( xMutex, genqNO_BLOCK ) != pdPASS )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* Set the guarded variable to a known start value. */\r
-               ulGuardedVariable = 0;\r
+       /* Attempt to set the priority of this task to the test priority -\r
+       between the     idle priority and the medium/high test priorities, but the\r
+       actual priority should remain at the high priority. */\r
+       vTaskPrioritySet( NULL, genqMUTEX_TEST_PRIORITY );\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* This task's priority should be as per that assigned when the task was\r
-               created. */\r
-               if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       /* Now unsuspend the medium priority task.  This should not run as the\r
+       inherited priority of this task is above that of the medium priority\r
+       task. */\r
+       vTaskResume( xMediumPriorityMutexTask );\r
 \r
-               /* Now unsuspend the high priority task.  This will attempt to take the\r
-               mutex, and block when it finds it cannot obtain it. */\r
-               vTaskResume( xHighPriorityMutexTask );\r
+       /* If the medium priority task did run then it will have incremented the\r
+       guarded variable. */\r
+       if( ulGuardedVariable != 0 )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               #if configUSE_PREEMPTION == 0\r
-                       taskYIELD();\r
-               #endif\r
+       /* Take the local mutex too, so two mutexes are now held. */\r
+       if( xSemaphoreTake( xLocalMutex, genqNO_BLOCK ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* Ensure the task is reporting its priority as blocked and not\r
-               suspended (as it would have done in versions up to V7.5.3). */\r
-               #if( INCLUDE_eTaskGetState == 1 )\r
-               {\r
-                       configASSERT( eTaskGetState( xHighPriorityMutexTask ) == eBlocked );\r
-               }\r
-               #endif /* INCLUDE_eTaskGetState */\r
+       /* When the semaphore is given back the priority of this task should not\r
+       yet be disinherited because the local mutex is still held.  This is a\r
+       simplification to allow FreeRTOS to be integrated with middleware that\r
+       attempts to hold multiple mutexes without bloating the code with complex\r
+       algorithms.  It is possible that the high priority mutex task will\r
+       execute as it shares a priority with this task. */\r
+       if( xSemaphoreGive( xMutex ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* The priority of the high priority task should now have been inherited\r
-               as by now it will have attempted to get the mutex. */\r
-               if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       #if configUSE_PREEMPTION == 0\r
+               taskYIELD();\r
+       #endif\r
 \r
-               /* Attempt to set the priority of this task to the test priority -\r
-               between the     idle priority and the medium/high test priorities, but the\r
-               actual priority should remain at the high priority. */\r
-               vTaskPrioritySet( NULL, genqMUTEX_TEST_PRIORITY );\r
-               if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       /* The guarded variable is only incremented by the medium priority task,\r
+       which still should not have executed as this task should remain at the\r
+       higher priority, ensure this is the case. */\r
+       if( ulGuardedVariable != 0 )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* Now unsuspend the medium priority task.  This should not run as the\r
-               inherited priority of this task is above that of the medium priority\r
-               task. */\r
-               vTaskResume( xMediumPriorityMutexTask );\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* If the medium priority task did run then it will have incremented the \r
-               guarded variable. */\r
-               if( ulGuardedVariable != 0 )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       /* Now also give back the local mutex, taking the held count back to 0.\r
+       This time the priority of this task should be disinherited back to the\r
+       priority to which it was set while the mutex was held.  This means\r
+       the medium priority task should execute and increment the guarded\r
+       variable.   When this task next runs both the high and medium priority\r
+       tasks will have been suspended again. */\r
+       if( xSemaphoreGive( xLocalMutex ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* Take the local mutex too, so two mutexes are now held. */\r
-               if( xSemaphoreTake( xLocalMutex, genqNO_BLOCK ) != pdPASS )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       #if configUSE_PREEMPTION == 0\r
+               taskYIELD();\r
+       #endif\r
 \r
-               /* When the semaphore is given back the priority of this task should not\r
-               yet be disinherited because the local mutex is still held.  This is a\r
-               simplification to allow FreeRTOS to be integrated with middleware that\r
-               attempts to hold multiple mutexes without bloating the code with complex\r
-               algorithms.  It is possible that the high priority mutex task will\r
-               execute as it shares a priority with this task. */\r
-               if( xSemaphoreGive( xMutex ) != pdPASS )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       /* Check the guarded variable did indeed increment... */\r
+       if( ulGuardedVariable != 1 )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               #if configUSE_PREEMPTION == 0\r
-                       taskYIELD();\r
-               #endif\r
+       /* ... and that the priority of this task has been disinherited to\r
+       genqMUTEX_TEST_PRIORITY. */\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_TEST_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* The guarded variable is only incremented by the medium priority task,\r
-               which still should not have executed as this task should remain at the\r
-               higher priority, ensure this is the case. */\r
-               if( ulGuardedVariable != 0 )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       /* Set the priority of this task back to its original value, ready for\r
+       the next loop around this test. */\r
+       vTaskPrioritySet( NULL, genqMUTEX_LOW_PRIORITY );\r
+}\r
+/*-----------------------------------------------------------*/\r
 \r
-               if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+static void prvTakeTwoMutexesReturnInSameOrder( SemaphoreHandle_t xMutex, SemaphoreHandle_t xLocalMutex )\r
+{\r
+       /* Take the mutex.  It should be available now. */\r
+       if( xSemaphoreTake( xMutex, genqNO_BLOCK ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
 \r
-               /* Now also give back the local mutex, taking the held count back to 0.\r
-               This time the priority of this task should be disinherited back to the\r
-               priority to which it was set while the mutex was held.  This means\r
-               the medium priority task should execute and increment the guarded \r
-               variable.   When this task next runs both the high and medium priority \r
-               tasks will have been suspended again. */\r
-               if( xSemaphoreGive( xLocalMutex ) != pdPASS )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
+       /* Set the guarded variable to a known start value. */\r
+       ulGuardedVariable = 0;\r
+\r
+       /* This task's priority should be as per that assigned when the task was\r
+       created. */\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       /* Now unsuspend the high priority task.  This will attempt to take the\r
+       mutex, and block when it finds it cannot obtain it. */\r
+       vTaskResume( xHighPriorityMutexTask );\r
+\r
+       #if configUSE_PREEMPTION == 0\r
+               taskYIELD();\r
+       #endif\r
+\r
+       /* Ensure the task is reporting its priority as blocked and not\r
+       suspended (as it would have done in versions up to V7.5.3). */\r
+       #if( INCLUDE_eTaskGetState == 1 )\r
+       {\r
+               configASSERT( eTaskGetState( xHighPriorityMutexTask ) == eBlocked );\r
+       }\r
+       #endif /* INCLUDE_eTaskGetState */\r
+\r
+       /* The priority of the high priority task should now have been inherited\r
+       as by now it will have attempted to get the mutex. */\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       /* Now unsuspend the medium priority task.  This should not run as the\r
+       inherited priority of this task is above that of the medium priority\r
+       task. */\r
+       vTaskResume( xMediumPriorityMutexTask );\r
+\r
+       /* If the medium priority task did run then it will have incremented the\r
+       guarded variable. */\r
+       if( ulGuardedVariable != 0 )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       /* Take the local mutex too, so two mutexes are now held. */\r
+       if( xSemaphoreTake( xLocalMutex, genqNO_BLOCK ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       /* When the local semaphore is given back the priority of this task should\r
+       not     yet be disinherited because the shared mutex is still held.  This is a\r
+       simplification to allow FreeRTOS to be integrated with middleware that\r
+       attempts to hold multiple mutexes without bloating the code with complex\r
+       algorithms.  It is possible that the high priority mutex task will\r
+       execute as it shares a priority with this task. */\r
+       if( xSemaphoreGive( xLocalMutex ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       #if configUSE_PREEMPTION == 0\r
+               taskYIELD();\r
+       #endif\r
+\r
+       /* The guarded variable is only incremented by the medium priority task,\r
+       which still should not have executed as this task should remain at the\r
+       higher priority, ensure this is the case. */\r
+       if( ulGuardedVariable != 0 )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       /* Now also give back the shared mutex, taking the held count back to 0.\r
+       This time the priority of this task should be disinherited back to the\r
+       priority at which it was created.  This means the medium priority task\r
+       should execute and increment the guarded variable.  When this task next runs\r
+       both the high and medium priority tasks will have been suspended again. */\r
+       if( xSemaphoreGive( xMutex ) != pdPASS )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       #if configUSE_PREEMPTION == 0\r
+               taskYIELD();\r
+       #endif\r
+\r
+       /* Check the guarded variable did indeed increment... */\r
+       if( ulGuardedVariable != 1 )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+\r
+       /* ... and that the priority of this task has been disinherited to\r
+       genqMUTEX_LOW_PRIORITY. */\r
+       if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )\r
+       {\r
+               xErrorDetected = pdTRUE;\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvLowPriorityMutexTask( void *pvParameters )\r
+{\r
+SemaphoreHandle_t xMutex = ( SemaphoreHandle_t ) pvParameters, xLocalMutex;\r
+\r
+       #ifdef USE_STDIO\r
+       void vPrintDisplayMessage( const char * const * ppcMessageToSend );\r
+\r
+               const char * const pcTaskStartMsg = "Mutex with priority inheritance test started.\r\n";\r
+\r
+               /* Queue a message for printing to say the task has started. */\r
+               vPrintDisplayMessage( &pcTaskStartMsg );\r
+       #endif\r
+\r
+       /* The local mutex is used to check the 'mutexs held' count. */\r
+       xLocalMutex = xSemaphoreCreateMutex();\r
+       configASSERT( xLocalMutex );\r
+\r
+       for( ;; )\r
+       {\r
+               /* The first tests exercise the priority inheritance when two mutexes\r
+               are taken then returned in a different order to which they were\r
+               taken. */\r
+               prvTakeTwoMutexesReturnInDifferentOrder( xMutex, xLocalMutex );\r
+\r
+               /* Just to show this task is still running. */\r
+               ulLoopCounter2++;\r
 \r
                #if configUSE_PREEMPTION == 0\r
                        taskYIELD();\r
                #endif\r
 \r
-               /* Check the guarded variable did indeed increment... */\r
-               if( ulGuardedVariable != 1 )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
-\r
-               /* ... and that the priority of this task has been disinherited to\r
-               genqMUTEX_TEST_PRIORITY. */\r
-               if( uxTaskPriorityGet( NULL ) != genqMUTEX_TEST_PRIORITY )\r
-               {\r
-                       xErrorDetected = pdTRUE;\r
-               }\r
-\r
-               /* Set the priority of this task back to its original value, ready for\r
-               the next loop around this test. */\r
-               vTaskPrioritySet( NULL, genqMUTEX_LOW_PRIORITY );\r
+               /* The second tests exercise the priority inheritance when two mutexes\r
+               are taken then returned in the same order in which they were taken. */\r
+               prvTakeTwoMutexesReturnInSameOrder( xMutex, xLocalMutex );\r
 \r
                /* Just to show this task is still running. */\r
                ulLoopCounter2++;\r
@@ -612,12 +787,53 @@ SemaphoreHandle_t xMutex = ( SemaphoreHandle_t ) pvParameters;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+/* NOTE: This function is not declared static to prevent compiler warnings in\r
+demos where the function is declared but not used. */\r
+void vInterruptMutexTask( void *pvParameters )\r
+{\r
+const TickType_t xInterruptGivePeriod = pdMS_TO_TICKS( genqINTERRUPT_MUTEX_GIVE_PERIOD_MS );\r
+volatile uint32_t ulLoops = 0;\r
+\r
+       /* Just to avoid compiler warnings. */\r
+       ( void ) pvParameters;\r
+\r
+       for( ;; )\r
+       {\r
+               /* Has to wait longer than the time between gives to make sure it\r
+               should definitely have received the mutex. */\r
+               if( xSemaphoreTake( xISRMutex, ( xInterruptGivePeriod * 2 ) ) != pdPASS )\r
+               {\r
+                       xErrorDetected = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       ulLoops++;\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vMutexISRInteractionTest( void )\r
+{\r
+static TickType_t xLastGiveTime = 0;\r
+TickType_t xTimeNow;\r
+\r
+       xTimeNow = xTaskGetTickCountFromISR();\r
+       if( ( xTimeNow - xLastGiveTime ) >= pdMS_TO_TICKS( genqINTERRUPT_MUTEX_GIVE_PERIOD_MS ) )\r
+       {\r
+               configASSERT( xISRMutex );\r
+               xSemaphoreGiveFromISR( xISRMutex, NULL );\r
+               xLastGiveTime = xTimeNow;\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 /* This is called to check that all the created tasks are still running. */\r
 BaseType_t xAreGenericQueueTasksStillRunning( void )\r
 {\r
 static uint32_t ulLastLoopCounter = 0, ulLastLoopCounter2 = 0;\r
 \r
-       /* If the demo task is still running then we expect the loopcounters to\r
+       /* If the demo task is still running then we expect the loop counters to\r
        have incremented since this function was last called. */\r
        if( ulLastLoopCounter == ulLoopCounter )\r
        {\r
index f600ac97f69a290f57b9ea445b32326335a17dc6..35afdc1afec46e0e33b239bacc19aeb345431916 100644 (file)
@@ -741,7 +741,12 @@ static TickType_t uxTick = ( TickType_t ) -1;
        as well as late timer expiries. */\r
        const TickType_t xMargin = 6;\r
 #else\r
-       const TickType_t xMargin = 3;\r
+       #ifdef _WINDOWS_\r
+               /* Windows is not real real time. */\r
+               const TickType_t xMargin = 8;\r
+       #else\r
+               const TickType_t xMargin = 4;\r
+       #endif /* _WINDOWS_ */\r
 #endif\r
 \r
 \r
index 804eaab9f921b99ca70137d7feecf1b7968fd5cd..ef63920d12f12453386e408db432234aadff0a4b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V8.1.0 - Copyright (C) 2014 Real Time Engineers Ltd. \r
+    FreeRTOS V8.1.0 - Copyright (C) 2014 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -68,6 +68,7 @@
 \r
 void vStartGenericQueueTasks( UBaseType_t uxPriority );\r
 BaseType_t xAreGenericQueueTasksStillRunning( void );\r
+void vMutexISRInteractionTest( void );\r
 \r
 #endif /* GEN_Q_TEST_H */\r
 \r
index 917f642dc149bd2282edd26c23bf49a4e73d9c8f..948a3f6a5b65253dffc3e5c299e70982ca7c3f48 100644 (file)
@@ -297,7 +297,7 @@ volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;
        ( void ) ulLine;\r
        ( void ) pcFileName;\r
 \r
-       taskENTER_CRITICAL();\r
+       taskENTER_CRITICAL();\r
        {\r
                /* Stop the trace recording. */\r
                if( xPrinted == pdFALSE )\r
index 30e93f303e326381adce24fc09604eccd45da2bc..85b6f14e300e2444609952617a9a9795470b4cc0 100644 (file)
@@ -162,7 +162,7 @@ static void prvTestTask( void *pvParameters );
 static void prvDemonstrateTaskStateAndHandleGetFunctions( void );\r
 \r
 /*\r
- * Called from the idle task hook function to demonstrate the use of \r
+ * Called from the idle task hook function to demonstrate the use of\r
  * xTimerPendFunctionCall() as xTimerPendFunctionCall() is not demonstrated by\r
  * any of the standard demo tasks.\r
  */\r
@@ -401,6 +401,9 @@ void vFullDemoTickHookFunction( void )
 \r
        /* Exercise event groups from interrupts. */\r
        vPeriodicEventGroupsProcessing();\r
+\r
+       /* Exercise giving mutexes from an interrupt. */\r
+       vMutexISRInteractionTest();\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index f7b9a0e3e0bf1b341a2f64193f6f5cb2db3c2910..22c810b400a2623b714a692550c628a329df33fd 100644 (file)
@@ -73,7 +73,7 @@
 typedef void (*TaskFunction_t)( void * );\r
 \r
 /* Converts a time in milliseconds to a time in ticks. */\r
-#define pdMS_TO_TICKS( xTimeInMs ) ( ( ( TickType_t ) xTimeInMs * configTICK_RATE_HZ ) / ( TickType_t ) 1000 )\r
+#define pdMS_TO_TICKS( xTimeInMs ) ( ( ( TickType_t ) ( xTimeInMs ) * configTICK_RATE_HZ ) / ( TickType_t ) 1000 )\r
 \r
 #define pdFALSE                        ( ( BaseType_t ) 0 )\r
 #define pdTRUE                 ( ( BaseType_t ) 1 )\r
index bdc60598ff3c319d4a876a5398509c91e4422235..8186a93faffcaca654c8e14c2da5054847753611 100644 (file)
@@ -1554,12 +1554,9 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
 \r
 /*\r
  * For internal use only.  Increment the mutex held count when a mutex is\r
- * taken and decrement the mutex held count when the mutex is given back\r
- * respectively.  The mutex held count is used to know when it is safe to\r
- * disinherit a priority.\r
+ * taken and return the handle of the task that has taken the mutex.\r
  */\r
-void vTaskIncrementMutexHeldCount( void );\r
-void vTaskDecrementMutexHeldCount( void );\r
+void *pvTaskIncrementMutexHeldCount( void );\r
 \r
 #ifdef __cplusplus\r
 }\r
index 941dafef23808e0126ccbaf0784a8d81bd74db66..388143aaf23ad7f1260420240c383b343767a57b 100644 (file)
@@ -144,7 +144,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
                           see http://www.freertos.org/Stacks-and-stack-overflow-checking.html\r
                        2) Incorrect interrupt priority assignment, especially on Cortex-M3\r
                           parts where numerically high priority values denote low actual\r
-                          interrupt priories, which can seem counter intuitive.  See\r
+                          interrupt priorities, which can seem counter intuitive.  See\r
                           configMAX_SYSCALL_INTERRUPT_PRIORITY on http://www.freertos.org/a00110.html\r
                        3) Calling an API function from within a critical section or when\r
                           the scheduler is suspended, or calling an API function that does\r
index f9e00375985fd1b89b7d72d3182209612de3cf96..0e5bc9e3a83c731a1f46efd708a5f69e382b313e 100644 (file)
@@ -421,10 +421,7 @@ QueueHandle_t xReturn = NULL;
 \r
                        traceCREATE_MUTEX( pxNewQueue );\r
 \r
-                       /* Start with the semaphore in the expected state.  Preload the\r
-                        mutex held count as calling xQueueGenericSend() will decrement the\r
-                        count back to 0. */\r
-                       vTaskIncrementMutexHeldCount();\r
+                       /* Start with the semaphore in the expected state. */\r
                        ( void ) xQueueGenericSend( pxNewQueue, NULL, ( TickType_t ) 0U, queueSEND_TO_BACK );\r
                }\r
                else\r
@@ -702,7 +699,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                                                the mutexes were given back in an order that is\r
                                                different to that in which they were taken. */\r
                                                queueYIELD_IF_USING_PREEMPTION();\r
-                                       }                                       \r
+                                       }\r
                                        else\r
                                        {\r
                                                mtCOVERAGE_TEST_MARKER();\r
@@ -1125,8 +1122,8 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                                                {\r
                                                        if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                                        {\r
-                                                               /* The task waiting has a higher priority so record that a\r
-                                                               context switch is required. */\r
+                                                               /* The task waiting has a higher priority so \r
+                                                               record that a context switch is required. */\r
                                                                if( pxHigherPriorityTaskWoken != NULL )\r
                                                                {\r
                                                                        *pxHigherPriorityTaskWoken = pdTRUE;\r
@@ -1243,7 +1240,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                                                {\r
                                                        /* Record the information required to implement\r
                                                        priority inheritance should it become necessary. */\r
-                                                       pxQueue->pxMutexHolder = ( int8_t * ) xTaskGetCurrentTaskHandle(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */\r
+                                                       pxQueue->pxMutexHolder = ( int8_t * ) pvTaskIncrementMutexHeldCount(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */\r
                                                }\r
                                                else\r
                                                {\r
@@ -1633,7 +1630,6 @@ BaseType_t xReturn = pdFALSE;
                        if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
                        {\r
                                /* The mutex is no longer being held. */\r
-                               vTaskDecrementMutexHeldCount();\r
                                xReturn = xTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder );\r
                                pxQueue->pxMutexHolder = NULL;\r
                        }\r
@@ -1699,7 +1695,7 @@ BaseType_t xReturn = pdFALSE;
 \r
 static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer )\r
 {\r
-       if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX )\r
+       if( pxQueue->uxItemSize != 0 )\r
        {\r
                pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
                if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */\r
@@ -1712,11 +1708,6 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer
                }\r
                ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports.  Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. */\r
        }\r
-       else\r
-       {\r
-               /* A mutex was taken. */\r
-               vTaskIncrementMutexHeldCount();\r
-       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 5300d09a9a92ac1672d15016d457e13274d60282..28d1c96326c9c765fbbc6679faed28a2768350ee 100644 (file)
@@ -553,14 +553,14 @@ TCB_t * pxNewTCB;
                        pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK  ) ); /*lint !e923 MISRA exception.  Avoiding casts between pointers and integers is not practical.  Size differences accounted for using portPOINTER_SIZE_TYPE type. */\r
 \r
                        /* Check the alignment of the calculated top of stack is correct. */\r
-                       configASSERT( ( ( ( uint32_t ) pxTopOfStack & ( uint32_t ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
+                       configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
                }\r
                #else /* portSTACK_GROWTH */\r
                {\r
                        pxTopOfStack = pxNewTCB->pxStack;\r
 \r
                        /* Check the alignment of the stack buffer is correct. */\r
-                       configASSERT( ( ( ( uint32_t ) pxNewTCB->pxStack & ( uint32_t ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
+                       configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
 \r
                        /* If we want to use stack checking on architectures that use\r
                        a positive stack growth direction then we also need to store the\r
@@ -3246,6 +3246,9 @@ TCB_t *pxTCB;
 \r
                if( pxMutexHolder != NULL )\r
                {\r
+                       configASSERT( pxTCB->uxMutexesHeld );\r
+                       ( pxTCB->uxMutexesHeld )--;\r
+\r
                        if( pxTCB->uxPriority != pxTCB->uxBasePriority )\r
                        {\r
                                /* Only disinherit if no other mutexes are held. */\r
@@ -3584,7 +3587,7 @@ TickType_t uxReturn;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vTaskIncrementMutexHeldCount( void )\r
+void *pvTaskIncrementMutexHeldCount( void )\r
 {\r
        #if ( configUSE_MUTEXES == 1 )\r
        {\r
@@ -3594,25 +3597,12 @@ void vTaskIncrementMutexHeldCount( void )
                {\r
                        ( pxCurrentTCB->uxMutexesHeld )++;\r
                }\r
-       }\r
-       #endif\r
-}\r
-/*-----------------------------------------------------------*/\r
 \r
-void vTaskDecrementMutexHeldCount( void )\r
-{\r
-       #if ( configUSE_MUTEXES == 1 )\r
-       {\r
-               /* If xSemaphoreCreateMutex() is called before any tasks have been created\r
-               then pxCurrentTCB will be NULL. */\r
-               if( pxCurrentTCB != NULL )\r
-               {\r
-                       configASSERT( pxCurrentTCB->uxMutexesHeld );\r
-                       ( pxCurrentTCB->uxMutexesHeld )--;\r
-               }\r
+               return pxCurrentTCB;\r
        }\r
        #endif\r
 }\r
+/*-----------------------------------------------------------*/\r
 \r
 #ifdef FREERTOS_MODULE_TEST\r
        #include "tasks_test_access_functions.h"\r