]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/MSVC-MingW/port.c
Prepare for a FreeRTOS V9 release candidate:
[freertos] / FreeRTOS / Source / portable / MSVC-MingW / port.c
index 64c773ef10909ad6b7cff91cae4301d0b6588f03..5ff8a52daac468102cadb3f85e63b90967c06d8d 100644 (file)
 #define portMAX_INTERRUPTS                             ( ( uint32_t ) sizeof( uint32_t ) * 8UL ) /* The number of bits in an uint32_t. */\r
 #define portNO_CRITICAL_NESTING                ( ( uint32_t ) 0 )\r
 \r
+/* The priorities at which the various components of the simulation execute.\r
+Priorities are higher when a soak test is performed to lessen the effect of\r
+Windows interfering with the timing. */\r
+#define portSOAK_TEST\r
+#ifndef portSOAK_TEST\r
+       #define portSIMULATED_INTERRUPTS_THREAD_PRIORITY THREAD_PRIORITY_NORMAL\r
+       #define portSIMULATED_TIMER_THREAD_PRIORITY              THREAD_PRIORITY_BELOW_NORMAL\r
+       #define portTASK_THREAD_PRIORITY                                 THREAD_PRIORITY_IDLE\r
+#else\r
+       #define portSIMULATED_INTERRUPTS_THREAD_PRIORITY THREAD_PRIORITY_TIME_CRITICAL\r
+       #define portSIMULATED_TIMER_THREAD_PRIORITY              THREAD_PRIORITY_HIGHEST\r
+       #define portTASK_THREAD_PRIORITY                                 THREAD_PRIORITY_ABOVE_NORMAL\r
+#endif\r
 /*\r
  * Created as a high priority thread, this function uses a timer to simulate\r
  * a tick interrupt being generated on an embedded target.  In this Windows\r
@@ -261,7 +274,7 @@ int8_t *pcTopOfStack = ( int8_t * ) pxTopOfStack;
        configASSERT( pxThreadState->pvThread );\r
        SetThreadAffinityMask( pxThreadState->pvThread, 0x01 );\r
        SetThreadPriorityBoost( pxThreadState->pvThread, TRUE );\r
-       SetThreadPriority( pxThreadState->pvThread, THREAD_PRIORITY_IDLE );\r
+       SetThreadPriority( pxThreadState->pvThread, portTASK_THREAD_PRIORITY );\r
 \r
        return ( StackType_t * ) pxThreadState;\r
 }\r
@@ -298,7 +311,7 @@ xThreadState *pxThreadState;
 \r
        if( lSuccess == pdPASS )\r
        {\r
-               if( SetThreadPriority( pvHandle, THREAD_PRIORITY_NORMAL ) == 0 )\r
+               if( SetThreadPriority( pvHandle, portSIMULATED_INTERRUPTS_THREAD_PRIORITY ) == 0 )\r
                {\r
                        lSuccess = pdFAIL;\r
                }\r
@@ -315,7 +328,7 @@ xThreadState *pxThreadState;
                pvHandle = CreateThread( NULL, 0, prvSimulatedPeripheralTimer, NULL, CREATE_SUSPENDED, NULL );\r
                if( pvHandle != NULL )\r
                {\r
-                       SetThreadPriority( pvHandle, THREAD_PRIORITY_BELOW_NORMAL );\r
+                       SetThreadPriority( pvHandle, portSIMULATED_TIMER_THREAD_PRIORITY );\r
                        SetThreadPriorityBoost( pvHandle, TRUE );\r
                        SetThreadAffinityMask( pvHandle, 0x01 );\r
                        ResumeThread( pvHandle );\r
@@ -427,8 +440,8 @@ CONTEXT xContext;
                                pxThreadState = ( xThreadState *) *( ( size_t * ) pvOldCurrentTCB );\r
                                SuspendThread( pxThreadState->pvThread );\r
 \r
-                               /* Ensure the thread is actually suspended by performing a \r
-                               synchronous operation that can only complete when the thread is \r
+                               /* Ensure the thread is actually suspended by performing a\r
+                               synchronous operation that can only complete when the thread is\r
                                actually suspended.  The below code asks for dummy register\r
                                data. */\r
                                xContext.ContextFlags = CONTEXT_INTEGER;\r
@@ -493,7 +506,7 @@ uint32_t ulErrorCode;
        does not run and swap it out before it is closed.  If that were to happen\r
        the thread would never run again and effectively be a thread handle and\r
        memory leak. */\r
-       SetThreadPriority( pvThread, THREAD_PRIORITY_ABOVE_NORMAL );\r
+       SetThreadPriority( pvThread, THREAD_PRIORITY_HIGHEST );\r
 \r
        /* This function will not return, therefore a yield is set as pending to\r
        ensure a context switch occurs away from this thread on the next tick. */\r
@@ -524,13 +537,15 @@ void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber )
 \r
        if( ( ulInterruptNumber < portMAX_INTERRUPTS ) && ( pvInterruptEventMutex != NULL ) )\r
        {\r
-               /* Yield interrupts are processed even when critical nesting is non-zero. */\r
+               /* Yield interrupts are processed even when critical nesting is\r
+               non-zero. */\r
                WaitForSingleObject( pvInterruptEventMutex, INFINITE );\r
                ulPendingInterrupts |= ( 1 << ulInterruptNumber );\r
 \r
-               /* The simulated interrupt is now held pending, but don't actually process it\r
-               yet if this call is within a critical section.  It is possible for this to\r
-               be in a critical section as calls to wait for mutexes are accumulative. */\r
+               /* The simulated interrupt is now held pending, but don't actually\r
+               process it yet if this call is within a critical section.  It is\r
+               possible for this to be in a critical section as calls to wait for\r
+               mutexes are accumulative. */\r
                if( ulCriticalNesting == 0 )\r
                {\r
                        SetEvent( pvInterruptEvent );\r