mirror of
				https://github.com/FreeRTOS/FreeRTOS-Kernel.git
				synced 2025-11-04 02:32:42 -05:00 
			
		
		
		
	Pend a yield in portPRE_TASK_DELETE_HOOK
When a task deletes itself, it calls portPRE_TASK_DELETE_HOOK which translates to vPortCloseRunningThread on the Windows port. vPortCloseRunningThread never returns and as a result, taskYIELD_WITHIN_API in vTaskDelete does not get called. As a result, the next task is not scheduled when configUSE_PREEMPTION is set to 0. This change records that a yield is pending so that the next tick interrupt switches out the task that was deleted. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
		
							parent
							
								
									e6d8308fde
								
							
						
					
					
						commit
						4d7b2f6685
					
				
					 1 changed files with 14 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -547,6 +547,20 @@ void vPortCloseRunningThread( void * pvTaskToDelete,
 | 
			
		|||
    /* This is called from a critical section, which must be exited before the
 | 
			
		||||
     * thread stops. */
 | 
			
		||||
    taskEXIT_CRITICAL();
 | 
			
		||||
 | 
			
		||||
    /* Record that a yield is pending so that the next tick interrupt switches
 | 
			
		||||
     * out this thread regardless of the value of configUSE_PREEMPTION. This is
 | 
			
		||||
     * needed when a task deletes itself - the taskYIELD_WITHIN_API within
 | 
			
		||||
     * vTaskDelete does not get called because this function never returns. If
 | 
			
		||||
     * we do not pend portINTERRUPT_YIELD here, the next task is not scheduled
 | 
			
		||||
     * when configUSE_PREEMPTION is set to 0. */
 | 
			
		||||
    if( pvInterruptEventMutex != NULL )
 | 
			
		||||
    {
 | 
			
		||||
        WaitForSingleObject( pvInterruptEventMutex, INFINITE );
 | 
			
		||||
        ulPendingInterrupts |= ( 1 << portINTERRUPT_YIELD );
 | 
			
		||||
        ReleaseMutex( pvInterruptEventMutex );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    CloseHandle( pxThreadState->pvYieldEvent );
 | 
			
		||||
    ExitThread( 0 );
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue