Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
n9wxu committed May 14, 2024
2 parents 5910076 + a8376db commit 3a9b028
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 39 deletions.
4 changes: 3 additions & 1 deletion list.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ void vListInsert( List_t * const pxList,
for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )
{
/* There is nothing to do here, just iterating to the wanted
* insertion position. */
* insertion position.
* IF YOU FIND YOUR CODE STUCK HERE, SEE THE NOTE JUST ABOVE.
*/
}
}

Expand Down
59 changes: 21 additions & 38 deletions portable/MSVC-MingW/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,48 +435,31 @@ static void prvProcessSimulatedInterrupts( void )

if( ulSwitchRequired != pdFALSE )
{
void * pvOldCurrentTCB;

pvOldCurrentTCB = pxCurrentTCB;
/* Suspend the old thread. */
pxThreadState = ( ThreadState_t * ) *( ( size_t * ) pxCurrentTCB );
SuspendThread( pxThreadState->pvThread );

/* Ensure the thread is actually suspended by performing a
* synchronous operation that can only complete when the thread
* is actually suspended. The below code asks for dummy register
* data. Experimentation shows that these two lines don't appear
* to do anything now, but according to
* https://devblogs.microsoft.com/oldnewthing/20150205-00/?p=44743
* they do - so as they do not harm (slight run-time hit). */
xContext.ContextFlags = CONTEXT_INTEGER;
( void ) GetThreadContext( pxThreadState->pvThread, &xContext );

/* Select the next task to run. */
vTaskSwitchContext();

/* If the task selected to enter the running state is not the task
* that is already in the running state. */
if( pvOldCurrentTCB != pxCurrentTCB )
{
/* Suspend the old thread. In the cases where the (simulated)
* interrupt is asynchronous (tick event swapping a task out rather
* than a task blocking or yielding) it doesn't matter if the
* 'suspend' operation doesn't take effect immediately - if it
* doesn't it would just be like the interrupt occurring slightly
* later. In cases where the yield was caused by a task blocking
* or yielding then the task will block on a yield event after the
* yield operation in case the 'suspend' operation doesn't take
* effect immediately. */
pxThreadState = ( ThreadState_t * ) *( ( size_t * ) pvOldCurrentTCB );
SuspendThread( pxThreadState->pvThread );

/* Ensure the thread is actually suspended by performing a
* synchronous operation that can only complete when the thread is
* actually suspended. The below code asks for dummy register
* data. Experimentation shows that these two lines don't appear
* to do anything now, but according to
* https://devblogs.microsoft.com/oldnewthing/20150205-00/?p=44743
* they do - so as they do not harm (slight run-time hit). */
xContext.ContextFlags = CONTEXT_INTEGER;
( void ) GetThreadContext( pxThreadState->pvThread, &xContext );

/* Obtain the state of the task now selected to enter the
* Running state. */
pxThreadState = ( ThreadState_t * ) ( *( size_t * ) pxCurrentTCB );

/* pxThreadState->pvThread can be NULL if the task deleted
* itself - but a deleted task should never be resumed here. */
configASSERT( pxThreadState->pvThread != NULL );
ResumeThread( pxThreadState->pvThread );
}
/* Obtain the state of the task now selected to enter the
* Running state. */
pxThreadState = ( ThreadState_t * ) ( *( size_t * ) pxCurrentTCB );

/* pxThreadState->pvThread can be NULL if the task deleted
* itself - but a deleted task should never be resumed here. */
configASSERT( pxThreadState->pvThread != NULL );
ResumeThread( pxThreadState->pvThread );
}

/* If the thread that is about to be resumed stopped running
Expand Down

0 comments on commit 3a9b028

Please sign in to comment.