]> git.sur5r.net Git - freertos/commitdiff
Kernel updates:
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 11 Feb 2015 15:41:30 +0000 (15:41 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 11 Feb 2015 15:41:30 +0000 (15:41 +0000)
+ Added vTimerSetTimerID() to compliment vTimerGetTimerID().  Now the timer ID can be used as timer local storage.
+ Updated comments and added some additional assert() calls.

Win32 port:
+ Some changes to allow easier 64-bit builds

PIC24/dsPIC port:
+ Added NOP after disable interrupt instruction.

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

13 files changed:
FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/RTOSDemo.uvproj
FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/webserver/httpd-cgi.c
FreeRTOS/Source/include/portable.h
FreeRTOS/Source/include/queue.h
FreeRTOS/Source/include/timers.h
FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h
FreeRTOS/Source/portable/MSVC-MingW/port.c
FreeRTOS/Source/portable/MSVC-MingW/portmacro.h
FreeRTOS/Source/portable/MemMang/heap_1.c
FreeRTOS/Source/portable/MemMang/heap_2.c
FreeRTOS/Source/queue.c
FreeRTOS/Source/tasks.c
FreeRTOS/Source/timers.c

index d4ec7a4e7ff92c91de968b29955851a660d013f7..7445245023e57a4fa85f8481bf6ac6170c6732e1 100644 (file)
@@ -30,6 +30,7 @@
           <SLE66AMisc></SLE66AMisc>
           <SLE66LinkerMisc></SLE66LinkerMisc>
           <SFDFile></SFDFile>
+          <bCustSvd>0</bCustSvd>
           <UseEnv>0</UseEnv>
           <BinPath></BinPath>
           <IncludePath></IncludePath>
@@ -71,6 +72,8 @@
             <UserProg2Name></UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopB1X>0</nStopB1X>
+            <nStopB2X>0</nStopB2X>
           </BeforeMake>
           <AfterMake>
             <RunUserProg1>1</RunUserProg1>
           <StopOnExitCode>3</StopOnExitCode>
           <CustomArgument></CustomArgument>
           <IncludeLibraryModules></IncludeLibraryModules>
+          <ComprImg>1</ComprImg>
         </CommonProperty>
         <DllOption>
           <SimDllName>SARMCM3.DLL</SimDllName>
             <Oh166RecLen>16</Oh166RecLen>
           </OPTHX>
           <Simulator>
-            <UseSimulator>0</UseSimulator>
+            <UseSimulator>1</UseSimulator>
             <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
             <RunToMain>1</RunToMain>
             <RestoreBreakpoints>1</RestoreBreakpoints>
             <RestoreFunctions>1</RestoreFunctions>
             <RestoreToolbox>1</RestoreToolbox>
             <LimitSpeedToRealTime>0</LimitSpeedToRealTime>
+            <RestoreSysVw>1</RestoreSysVw>
           </Simulator>
           <Target>
-            <UseTarget>1</UseTarget>
+            <UseTarget>0</UseTarget>
             <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
-            <RunToMain>0</RunToMain>
+            <RunToMain>1</RunToMain>
             <RestoreBreakpoints>1</RestoreBreakpoints>
             <RestoreWatchpoints>1</RestoreWatchpoints>
             <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
             <RestoreFunctions>0</RestoreFunctions>
             <RestoreToolbox>1</RestoreToolbox>
             <RestoreTracepoints>0</RestoreTracepoints>
+            <RestoreSysVw>1</RestoreSysVw>
           </Target>
           <RunDebugAfterBuild>0</RunDebugAfterBuild>
-          <TargetSelection>4</TargetSelection>
+          <TargetSelection>2</TargetSelection>
           <SimDlls>
             <CpuDll></CpuDll>
             <CpuDllArguments></CpuDllArguments>
             <UseTargetDll>1</UseTargetDll>
             <UseExternalTool>0</UseExternalTool>
             <RunIndependent>0</RunIndependent>
-            <UpdateFlashBeforeDebugging>0</UpdateFlashBeforeDebugging>
+            <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
             <Capability>1</Capability>
             <DriverSelection>4099</DriverSelection>
           </Flash1>
+          <bUseTDR>1</bUseTDR>
           <Flash2>BIN\lmidk-agdi.dll</Flash2>
           <Flash3>"" ()</Flash3>
           <Flash4></Flash4>
+          <pFcarmOut></pFcarmOut>
+          <pFcarmGrp></pFcarmGrp>
+          <pFcArmRoot></pFcArmRoot>
+          <FcArmLst>0</FcArmLst>
         </Utilities>
         <TargetArmAds>
           <ArmAdsMisc>
             <wLevel>0</wLevel>
             <uThumb>0</uThumb>
             <uSurpInc>0</uSurpInc>
+            <uC99>0</uC99>
+            <useXO>0</useXO>
             <VariousControls>
               <MiscControls>--diag_suppress 191,550,513,167,177,144</MiscControls>
               <Define>RVDS_ARMCM3_LM3S102, "PACK_STRUCT_END=","ALIGN_STRUCT_END="</Define>
             <SwStkChk>0</SwStkChk>
             <NoWarn>0</NoWarn>
             <uSurpInc>0</uSurpInc>
+            <useXO>0</useXO>
             <VariousControls>
               <MiscControls></MiscControls>
               <Define></Define>
             <useFile>0</useFile>
             <TextAddressRange>0x00000000</TextAddressRange>
             <DataAddressRange>0x20000000</DataAddressRange>
+            <pXoBase></pXoBase>
             <ScatterFile></ScatterFile>
             <IncludeLibs></IncludeLibs>
             <IncludeLibsPath></IncludeLibsPath>
               <FileType>1</FileType>
               <FilePath>..\Common\Minimal\QueueSet.c</FilePath>
             </File>
+            <File>
+              <FileName>EventGroupsDemo.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Common\Minimal\EventGroupsDemo.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>
               <FileType>1</FileType>
               <FilePath>..\..\Source\portable\RVDS\ARM_CM3\port.c</FilePath>
             </File>
+            <File>
+              <FileName>timers.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\Source\timers.c</FilePath>
+            </File>
+            <File>
+              <FileName>event_groups.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\Source\event_groups.c</FilePath>
+            </File>
             <File>
               <FileName>heap_2.c</FileName>
               <FileType>1</FileType>
index 5b9ae1611d4351374a1575f7b4e89903b5fb4c0f..76e1c3d2b368339e9c8271014f1003aaa54067a4 100644 (file)
@@ -61,7 +61,7 @@ HTTPD_CGI_CALL(rtos, "rtos-stats", rtos_stats );
 HTTPD_CGI_CALL(io, "led-io", led_io );\r
 \r
 \r
-static const struct httpd_cgi_call * const calls[] = { &file, &tcp, &net, &rtos, &io, NULL };\r
+static const struct httpd_cgi_call * calls[] = { &file, &tcp, &net, &rtos, &io, NULL };\r
 \r
 /*---------------------------------------------------------------------------*/\r
 static\r
index 09f894ed60abb776ac31ea5653b82b85a16a8b64..8344383649a0ba0af5e36e58076e0217e4e451ef 100644 (file)
@@ -95,7 +95,7 @@ must be set in the compiler's include path. */
 #endif\r
 \r
 #if portBYTE_ALIGNMENT == 8\r
-       #define portBYTE_ALIGNMENT_MASK ( 0x0007U )\r
+       #define portBYTE_ALIGNMENT_MASK ( 0x0007 )\r
 #endif\r
 \r
 #if portBYTE_ALIGNMENT == 4\r
index 8eb704c18790c4ac8075eed92377a3a87fd44bf0..0633fb3990992a0fa4359a28bcaa89ec13cf91b8 100644 (file)
@@ -1490,10 +1490,8 @@ BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWa
 BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
- * Reset a queue back to its original empty state.  pdPASS is returned if the\r
- * queue is successfully reset.  pdFAIL is returned if the queue could not be\r
- * reset because there are tasks blocked on the queue waiting to either\r
- * receive from the queue or send to the queue.\r
+ * Reset a queue back to its original empty state.  The return value is now\r
+ * obsolete and is always set to pdPASS.\r
  */\r
 #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE )\r
 \r
index bed0e5c2abe8d5f2fba576d0b5d4ede584b98a7f..60f394f591eb820e76781b0e92eb6d279a6547e2 100644 (file)
@@ -265,11 +265,11 @@ TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTi
  * Returns the ID assigned to the timer.\r
  *\r
  * IDs are assigned to timers using the pvTimerID parameter of the call to\r
- * xTimerCreated() that was used to create the timer.\r
+ * xTimerCreated() that was used to create the timer, and by calling the\r
+ * vTimerSetTimerID() API function.\r
  *\r
  * If the same callback function is assigned to multiple timers then the timer\r
- * ID can be used within the callback function to identify which timer actually\r
- * expired.\r
+ * ID can be used as time specific (timer local) storage.\r
  *\r
  * @param xTimer The timer being queried.\r
  *\r
@@ -281,6 +281,27 @@ TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTi
  */\r
 void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;\r
 \r
+/**\r
+ * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );\r
+ *\r
+ * Sets the ID assigned to the timer.\r
+ *\r
+ * IDs are assigned to timers using the pvTimerID parameter of the call to\r
+ * xTimerCreated() that was used to create the timer.\r
+ *\r
+ * If the same callback function is assigned to multiple timers then the timer\r
+ * ID can be used as time specific (timer local) storage.\r
+ *\r
+ * @param xTimer The timer being updated.\r
+ *\r
+ * @param pvNewID The ID to assign to the timer.\r
+ *\r
+ * Example usage:\r
+ *\r
+ * See the xTimerCreate() API function example usage scenario.\r
+ */\r
+void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION;\r
+\r
 /**\r
  * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );\r
  *\r
index ec6422a8bd5518725759430aa7168e378faa6867..ab6d656e17e513246e701c44356786553538d228 100644 (file)
@@ -115,7 +115,7 @@ typedef unsigned short UBaseType_t;
 /* Critical section management. */\r
 #define portINTERRUPT_BITS                     ( ( uint16_t ) configKERNEL_INTERRUPT_PRIORITY << ( uint16_t ) 5 )\r
 \r
-#define portDISABLE_INTERRUPTS()       SR |= portINTERRUPT_BITS\r
+#define portDISABLE_INTERRUPTS()       SR |= portINTERRUPT_BITS; __asm volatile ( "NOP" )\r
 #define portENABLE_INTERRUPTS()                SR &= ~portINTERRUPT_BITS\r
 \r
 /* Note that exiting a critical sectino will set the IPL bits to 0, nomatter\r
index 04311a6a70db065d1d31eafc55a1996a617b0262..056407213a502a1818f550c70e76d6035d945018 100644 (file)
@@ -322,7 +322,7 @@ xThreadState *pxThreadState;
 \r
                /* Start the highest priority task by obtaining its associated thread\r
                state structure, in which is stored the thread handle. */\r
-               pxThreadState = ( xThreadState * ) *( ( uint32_t * ) pxCurrentTCB );\r
+               pxThreadState = ( xThreadState * ) *( ( size_t * ) pxCurrentTCB );\r
                ulCriticalNesting = portNO_CRITICAL_NESTING;\r
 \r
                /* Bump up the priority of the thread that is going to run, in the\r
@@ -422,12 +422,12 @@ void *pvObjectList[ 2 ];
                        if( pvOldCurrentTCB != pxCurrentTCB )\r
                        {\r
                                /* Suspend the old thread. */\r
-                               pxThreadState = ( xThreadState *) *( ( uint32_t * ) pvOldCurrentTCB );\r
+                               pxThreadState = ( xThreadState *) *( ( size_t * ) pvOldCurrentTCB );\r
                                SuspendThread( pxThreadState->pvThread );\r
 \r
                                /* Obtain the state of the task now selected to enter the\r
                                Running state. */\r
-                               pxThreadState = ( xThreadState * ) ( *( uint32_t *) pxCurrentTCB );\r
+                               pxThreadState = ( xThreadState * ) ( *( size_t *) pxCurrentTCB );\r
                                ResumeThread( pxThreadState->pvThread );\r
                        }\r
                }\r
@@ -446,7 +446,7 @@ uint32_t ulErrorCode;
        ( void ) ulErrorCode;\r
 \r
        /* Find the handle of the thread being deleted. */\r
-       pxThreadState = ( xThreadState * ) ( *( uint32_t *) pvTaskToDelete );\r
+       pxThreadState = ( xThreadState * ) ( *( size_t *) pvTaskToDelete );\r
 \r
        /* Check that the thread is still valid, it might have been closed by\r
        vPortCloseRunningThread() - which will be the case if the task associated\r
@@ -477,7 +477,7 @@ uint32_t ulErrorCode;
        ( void ) ulErrorCode;\r
 \r
        /* Find the handle of the thread being deleted. */\r
-       pxThreadState = ( xThreadState * ) ( *( uint32_t *) pvTaskToDelete );\r
+       pxThreadState = ( xThreadState * ) ( *( size_t *) pvTaskToDelete );\r
        pvThread = pxThreadState->pvThread;\r
 \r
        /* Raise the Windows priority of the thread to ensure the FreeRTOS scheduler\r
index af52798c7d79b875d20f8cd1fafeb6db58853f9b..3666c03ea7495e84d88cb854638aa9a6be9bae8a 100644 (file)
@@ -81,8 +81,9 @@
 #define portDOUBLE             double\r
 #define portLONG               long\r
 #define portSHORT              short\r
-#define portSTACK_TYPE uint32_t\r
+#define portSTACK_TYPE size_t\r
 #define portBASE_TYPE  long\r
+#define portPOINTER_SIZE_TYPE size_t\r
 \r
 typedef portSTACK_TYPE StackType_t;\r
 typedef long BaseType_t;\r
@@ -96,15 +97,21 @@ typedef unsigned long UBaseType_t;
     typedef uint32_t TickType_t;\r
     #define portMAX_DELAY ( TickType_t ) 0xffffffffUL\r
 \r
-       /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do\r
-       not need to be guarded with a critical section. */\r
+       /* 32/64-bit tick type on a 32/64-bit architecture, so reads of the tick\r
+       count do not need to be guarded with a critical section. */\r
        #define portTICK_TYPE_IS_ATOMIC 1\r
 #endif\r
 \r
 /* Hardware specifics. */\r
 #define portSTACK_GROWTH                       ( -1 )\r
 #define portTICK_PERIOD_MS                     ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
-#define portBYTE_ALIGNMENT                     4\r
+\r
+\r
+#if defined( __x86_64_ _) || defined( _M_X64 )\r
+       #define portBYTE_ALIGNMENT              8\r
+#else\r
+       #define portBYTE_ALIGNMENT              4\r
+#endif\r
 \r
 #define portYIELD()                                    vPortGenerateSimulatedInterrupt( portINTERRUPT_YIELD )\r
 \r
@@ -186,3 +193,4 @@ void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber );
 void vPortSetInterruptHandler( uint32_t ulInterruptNumber, uint32_t (*pvHandler)( void ) );\r
 \r
 #endif\r
+\r
index 5223dcbc1917e303a0d3b47f8008d1223079a343..195736c606d764d219bf9ab4fc716dd938eda131 100644 (file)
@@ -115,7 +115,7 @@ static uint8_t *pucAlignedHeap = NULL;
                if( pucAlignedHeap == NULL )\r
                {\r
                        /* Ensure the heap starts on a correctly aligned boundary. */\r
-                       pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) );\r
+                       pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );\r
                }\r
 \r
                /* Check there is enough room left for the allocation. */\r
index 4860a99ee59db6f1935f4a778c6ce916af76f94c..6bddc6cd6143b8d6a041551fce095e367ea7583f 100644 (file)
@@ -283,7 +283,7 @@ BlockLink_t *pxFirstFreeBlock;
 uint8_t *pucAlignedHeap;\r
 \r
        /* Ensure the heap starts on a correctly aligned boundary. */\r
-       pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) );\r
+       pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );\r
 \r
        /* xStart is used to hold a pointer to the first item in the list of free\r
        blocks.  The void cast is used to prevent compiler warnings. */\r
index d04d81fe856ee1a311882c2717228f135b761af7..27d3edd6a011472df1e39c6b2e74b8377eaaab51 100644 (file)
@@ -633,10 +633,10 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
        {\r
                taskENTER_CRITICAL();\r
                {\r
-                       /* Is there room on the queue now?  The running task must be\r
-                       the highest priority task wanting to access the queue.  If\r
-                       the head item in the queue is to be overwritten then it does\r
-                       not matter if the queue is full. */\r
+                       /* Is there room on the queue now?  The running task must be the\r
+                       highest priority task wanting to access the queue.  If the head item\r
+                       in the queue is to be overwritten then it does not matter if the\r
+                       queue is full. */\r
                        if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
                        {\r
                                traceQUEUE_SEND( pxQueue );\r
@@ -1092,11 +1092,11 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                {\r
                        traceQUEUE_SEND_FROM_ISR( pxQueue );\r
 \r
-                       /* A task can only have an inherited priority if it is a mutex\r
-                       holder - and if there is a mutex holder then the mutex cannot be\r
-                       given from an ISR.  Therefore, unlike the xQueueGenericGive()\r
-                       function, there is no need to determine the need for priority\r
-                       disinheritance here or to clear the mutex holder TCB member. */\r
+                       /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a\r
+                       semaphore or mutex.  That means prvCopyDataToQueue() cannot result\r
+                       in a task disinheriting a priority and prvCopyDataToQueue() can be\r
+                       called here even though the disinherit function does not check if\r
+                       the scheduler is suspended before accessing the ready lists. */\r
                        ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
 \r
                        /* The event list is not altered if the queue is locked.  This will\r
@@ -1210,11 +1210,23 @@ BaseType_t xReturn;
 UBaseType_t uxSavedInterruptStatus;\r
 Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
+       /* Similar to xQueueGenericSendFromISR() but used with semaphores where the\r
+       item size is 0.  Don't directly wake a task that was blocked on a queue\r
+       read, instead return a flag to say whether a context switch is required or\r
+       not (i.e. has a task with a higher priority than us been woken by this\r
+       post). */\r
+\r
        configASSERT( pxQueue );\r
 \r
-       /* xQueueGenericSendFromISR() should be used in the item size is not 0. */\r
+       /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR()\r
+       if the item size is not 0. */\r
        configASSERT( pxQueue->uxItemSize == 0 );\r
 \r
+       /* Normally a mutex would not be given from an interrupt, and doing so is\r
+       definitely wrong if there is a mutex holder as priority inheritance makes no\r
+       sense for an interrupts, only tasks. */\r
+       configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) );\r
+\r
        /* RTOS ports that support interrupt nesting have the concept of a maximum\r
        system call (or maximum API call) interrupt priority.  Interrupts that are\r
        above the maximum system call priority are kept permanently enabled, even\r
@@ -1231,11 +1243,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
        link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
        portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
 \r
-       /* Similar to xQueueGenericSendFromISR() but used with semaphores where the\r
-       item size is 0.  Don't directly wake a task that was blocked on a queue\r
-       read, instead return a flag to say whether a context switch is required or\r
-       not (i.e. has a task with a higher priority than us been woken by this\r
-       post). */\r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
                /* When the queue is used to implement a semaphore no data is ever\r
@@ -1247,10 +1254,10 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
 \r
                        /* A task can only have an inherited priority if it is a mutex\r
                        holder - and if there is a mutex holder then the mutex cannot be\r
-                       given from an ISR.  Therefore, unlike the xQueueGenericGive()\r
-                       function, there is no need to determine the need for priority\r
-                       disinheritance here or to clear the mutex holder TCB member. */\r
-\r
+                       given from an ISR.  As this is the ISR version of the function it\r
+                       can be assumed there is no mutex holder and no need to determine if\r
+                       priority disinheritance is needed.  Simply increase the count of\r
+                       messages (semaphores) available. */\r
                        ++( pxQueue->uxMessagesWaiting );\r
 \r
                        /* The event list is not altered if the queue is locked.  This will\r
@@ -1441,8 +1448,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                                        any other tasks waiting for the data. */\r
                                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
                                        {\r
-                                               /* Tasks that are removed from the event list will get added to\r
-                                               the pending ready list as the scheduler is still suspended. */\r
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                                {\r
                                                        /* The task waiting has a higher priority than this task. */\r
@@ -2556,6 +2561,7 @@ BaseType_t xReturn;
                if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength )\r
                {\r
                        traceQUEUE_SEND( pxQueueSetContainer );\r
+\r
                        /* The data copied is the handle of the queue that contains data. */\r
                        xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition );\r
 \r
index bce9973d1e93248e32d3186a0c2df1034d5a9bc7..c7b29382d97b54935a93b866fafe37374e77daf1 100644 (file)
@@ -387,7 +387,7 @@ count overflows. */
  * the task.  It is inserted at the end of the list.\r
  */\r
 #define prvAddTaskToReadyList( pxTCB )                                                                                                                         \\r
-       traceMOVED_TASK_TO_READY_STATE( pxTCB )                                                                                                                 \\r
+       traceMOVED_TASK_TO_READY_STATE( pxTCB );                                                                                                                \\r
        taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority );                                                                                             \\r
        vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) )\r
 /*-----------------------------------------------------------*/\r
@@ -598,7 +598,7 @@ StackType_t *pxTopOfStack;
                #if( portSTACK_GROWTH < 0 )\r
                {\r
                        pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 );\r
-                       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
+                       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( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
@@ -2395,7 +2395,7 @@ TickType_t xTimeToWake;
                /* This function should not be called by application code hence the\r
                'Restricted' in its name.  It is not part of the public API.  It is\r
                designed for use by kernel code, and has special calling requirements -\r
-               it should be called from a critical section. */\r
+               it should be called with the scheduler suspended. */\r
 \r
 \r
                /* Place the event list item of the TCB in the appropriate event list.\r
@@ -2406,7 +2406,8 @@ TickType_t xTimeToWake;
 \r
                /* We must remove this task from the ready list before adding it to the\r
                blocked list as the same list item is used for both lists.  This\r
-               function is called form a critical section. */\r
+               function is called with the scheduler locked so interrupts will not\r
+               access the lists at the same time. */\r
                if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                {\r
                        /* The current task must be in a ready list, so there is no need to\r
@@ -3394,6 +3395,9 @@ TCB_t *pxTCB;
                locked then the mutex holder might now be NULL. */\r
                if( pxMutexHolder != NULL )\r
                {\r
+                       /* If the holder of the mutex has a priority below the priority of\r
+                       the task attempting to obtain the mutex then it will temporarily\r
+                       inherit the priority of the task attempting to obtain the mutex. */\r
                        if( pxTCB->uxPriority < pxCurrentTCB->uxPriority )\r
                        {\r
                                /* Adjust the mutex holder state to account for its new\r
@@ -3408,8 +3412,8 @@ TCB_t *pxTCB;
                                        mtCOVERAGE_TEST_MARKER();\r
                                }\r
 \r
-                               /* If the task being modified is in the ready state it will need to\r
-                               be moved into a new list. */\r
+                               /* If the task being modified is in the ready state it will need\r
+                               to be moved into a new list. */\r
                                if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
                                {\r
                                        if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
@@ -3456,15 +3460,23 @@ TCB_t *pxTCB;
 \r
                if( pxMutexHolder != NULL )\r
                {\r
+                       /* A task can only have an inherited priority if it holds the mutex.\r
+                       If the mutex is held by a task then it cannot be given from an\r
+                       interrupt, and if a mutex is given by the holding task then it must\r
+                       be the running state task. */\r
+                       configASSERT( pxTCB == pxCurrentTCB );\r
+\r
                        configASSERT( pxTCB->uxMutexesHeld );\r
                        ( pxTCB->uxMutexesHeld )--;\r
 \r
+                       /* Has the holder of the mutex inherited the priority of another\r
+                       task? */\r
                        if( pxTCB->uxPriority != pxTCB->uxBasePriority )\r
                        {\r
                                /* Only disinherit if no other mutexes are held. */\r
                                if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 )\r
                                {\r
-                                       /* A task can only have an inhertied priority if it holds\r
+                                       /* A task can only have an inherited priority if it holds\r
                                        the mutex.  If the mutex is held by a task then it cannot be\r
                                        given from an interrupt, and if a mutex is given by the\r
                                        holding task then it must be the running state task.  Remove\r
index 11b33dbd5e24c92268dd0dd8bb45c2446fe7fff2..b270488bc9dc06205c7471f8adcfa799d738da2a 100644 (file)
@@ -827,8 +827,31 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
 void *pvTimerGetTimerID( const TimerHandle_t xTimer )\r
 {\r
 Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
+void *pvReturn;\r
 \r
-       return pxTimer->pvTimerID;\r
+       configASSERT( xTimer );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               pvReturn = pxTimer->pvTimerID;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID )\r
+{\r
+Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
+\r
+       configASSERT( xTimer );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               pxTimer->pvTimerID = pvNewID;\r
+       }\r
+       taskEXIT_CRITICAL();\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r