mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Changed vPortCheckCorrectThreadIsRunning() in the Win32 port layer to use the Win32 thread ID rather than its handle.
This commit is contained in:
parent
60bea08b22
commit
37b6fb5773
|
@ -88,7 +88,12 @@ typedef struct
|
|||
long lWaitingInterruptAck;
|
||||
|
||||
/* Handle of the thread that executes the task. */
|
||||
void * pvThread;
|
||||
void *pvThread;
|
||||
|
||||
/* Used to check that the thread that is supposed to be running in indeed
|
||||
the thread that is running. */
|
||||
unsigned long ulThreadId;
|
||||
|
||||
} xThreadState;
|
||||
|
||||
/* Pseudo interrupts waiting to be processed. This is a bit mask where each
|
||||
|
@ -181,7 +186,7 @@ xThreadState *pxThreadState = NULL;
|
|||
pxThreadState = ( xThreadState * ) ( pxTopOfStack - sizeof( xThreadState ) );
|
||||
|
||||
/* Create the thread itself. */
|
||||
pxThreadState->pvThread = ( void * ) CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE ) pxCode, pvParameters, CREATE_SUSPENDED, NULL );
|
||||
pxThreadState->pvThread = CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE ) pxCode, pvParameters, CREATE_SUSPENDED, &( pxThreadState->ulThreadId ) );
|
||||
SetThreadPriorityBoost( pxThreadState->pvThread, TRUE );
|
||||
pxThreadState->lWaitingInterruptAck = pdFALSE;
|
||||
SetThreadPriority( pxThreadState->pvThread, THREAD_PRIORITY_IDLE );
|
||||
|
@ -536,15 +541,20 @@ long lMutexNeedsReleasing;
|
|||
|
||||
void vPortCheckCorrectThreadIsRunning( void )
|
||||
{
|
||||
xThreadState *pxThreadState = ( xThreadState * ) *( ( unsigned long * ) pxCurrentTCB );
|
||||
xThreadState *pxThreadState;
|
||||
|
||||
/* When switching threads, Windows does not always seem to run the selected
|
||||
thread immediately. This function can be called to check if the thread
|
||||
that is currently running is the thread that is responsible for executing
|
||||
the task selected by the real time scheduler. */
|
||||
if( GetCurrentThread() != pxThreadState->pvThread )
|
||||
if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
|
||||
{
|
||||
SwitchToThread();
|
||||
pxThreadState = ( xThreadState * ) *( ( unsigned long * ) pxCurrentTCB );
|
||||
|
||||
if( GetCurrentThreadId() != pxThreadState->ulThreadId )
|
||||
{
|
||||
SwitchToThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue