mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-12 00:57:44 -04:00
Posix: Fix no task switching issue if a task ended
When the main function of a task exits, no task switching happened. This is because all the remaining tasks are waiting on the condition variable. The fix is to trigger a task switch and mark the exiting task as "Dying" to be suspened and exited properly from the scheduler.
This commit is contained in:
parent
d428209d01
commit
a4e007e755
1 changed files with 9 additions and 0 deletions
9
portable/ThirdParty/GCC/Posix/port.c
vendored
9
portable/ThirdParty/GCC/Posix/port.c
vendored
|
@ -66,6 +66,7 @@
|
|||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define SIG_RESUME SIGUSR1
|
||||
#define portTASK_ENDED_DELAY ( 500 )
|
||||
|
||||
typedef struct THREAD
|
||||
{
|
||||
|
@ -421,6 +422,14 @@ Thread_t *pxThread = pvParams;
|
|||
/* Call the task's entry point. */
|
||||
pxThread->pxCode( pxThread->pvParams );
|
||||
|
||||
/* The task has finished, we need to trigger a task switch here
|
||||
* to avoid exiting while all tasks are waiting to be signaled.
|
||||
* So we will mark the task as Dying here then delay the task
|
||||
* with any value to trigger a task switch where the task will
|
||||
* be suspended and exited. */
|
||||
pxThread->xDying = pdTRUE;
|
||||
vTaskDelay( portTASK_ENDED_DELAY );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue