Introduce the portSOFTWARE_BARRIER macro which thus far is only used by the Win32 demo to hold execution up in case a simulated interrupt is executing simultaneously. That should never happen as all threads should execute on the same core, but we have had numerous reports that this and other Win32 port changes we have made fixed these issues - although we have not been able to replicate them ourselves.

pull/7/head
Richard Barry 5 years ago
parent 18f87e8c33
commit 2415dc26b0

@ -257,6 +257,10 @@ hold explicit before calling the code. */
#define portMEMORY_BARRIER() #define portMEMORY_BARRIER()
#endif #endif
#ifndef portSOFTWARE_BARRIER
#define portSOFTWARE_BARRIER()
#endif
/* The timers module relies on xTaskGetSchedulerState(). */ /* The timers module relies on xTaskGetSchedulerState(). */
#if configUSE_TIMERS == 1 #if configUSE_TIMERS == 1

@ -75,7 +75,7 @@ static uint32_t prvProcessTickInterrupt( void );
* attempt to obtain pvInterruptEventMutex if a critical section is used inside * attempt to obtain pvInterruptEventMutex if a critical section is used inside
* an interrupt handler itself. * an interrupt handler itself.
*/ */
static volatile BaseType_t xInsideInterrupt = pdFALSE; volatile BaseType_t xInsideInterrupt = pdFALSE;
/* /*
* Called when the process exits to let Windows know the high timer resolution * Called when the process exits to let Windows know the high timer resolution
@ -394,7 +394,7 @@ CONTEXT xContext;
xInsideInterrupt = pdFALSE; xInsideInterrupt = pdFALSE;
WaitForMultipleObjects( sizeof( pvObjectList ) / sizeof( void * ), pvObjectList, TRUE, INFINITE ); WaitForMultipleObjects( sizeof( pvObjectList ) / sizeof( void * ), pvObjectList, TRUE, INFINITE );
/* /* Cannot be in a critical section to get here. Tasks that exist a /* Cannot be in a critical section to get here. Tasks that exist a
critical section will block on a yield mutex to wait for an interrupt to critical section will block on a yield mutex to wait for an interrupt to
process if an interrupt was set pending while the task was inside the process if an interrupt was set pending while the task was inside the
critical section. xInsideInterrupt prevents interrupts that contain critical section. xInsideInterrupt prevents interrupts that contain

@ -74,6 +74,11 @@ typedef unsigned long UBaseType_t;
#define portYIELD() vPortGenerateSimulatedInterrupt( portINTERRUPT_YIELD ) #define portYIELD() vPortGenerateSimulatedInterrupt( portINTERRUPT_YIELD )
extern volatile BaseType_t xInsideInterrupt;
#define portSOFTWARE_BARRIER() while( xInsideInterrupt != pdFALSE )
/* Simulated interrupts return pdFALSE if no context switch should be performed, /* Simulated interrupts return pdFALSE if no context switch should be performed,
or a non-zero number if a context switch should be performed. */ or a non-zero number if a context switch should be performed. */
#define portYIELD_FROM_ISR( x ) ( void ) x #define portYIELD_FROM_ISR( x ) ( void ) x

@ -2113,7 +2113,17 @@ void vTaskSuspendAll( void )
BaseType_t. Please read Richard Barry's reply in the following link to a BaseType_t. Please read Richard Barry's reply in the following link to a
post in the FreeRTOS support forum before reporting this as a bug! - post in the FreeRTOS support forum before reporting this as a bug! -
http://goo.gl/wu4acr */ http://goo.gl/wu4acr */
/* portSOFRWARE_BARRIER() is only implemented for emulated/simulated ports that
do not otherwise exhibit real time behaviour. */
portSOFTWARE_BARRIER();
/* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
is used to allow calls to vTaskSuspendAll() to nest. */
++uxSchedulerSuspended; ++uxSchedulerSuspended;
/* Enforces ordering for ports and optimised compilers that may otherwise place
the above increment elsewhere. */
portMEMORY_BARRIER(); portMEMORY_BARRIER();
} }
/*----------------------------------------------------------*/ /*----------------------------------------------------------*/

Loading…
Cancel
Save