Skip to content

Commit 77ad717

Browse files
RedaMaheralfred2g
andauthored
Posix: Fix no task switching issue if a task ended its main function (#184)
* 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. * Posix: Assert and stop if the Task function returned * Posix: just assert if a task returned from its main function Co-authored-by: alfred gedeon <alfred2g@hotmail.com>
1 parent fccb97b commit 77ad717

File tree

1 file changed

+7
-0
lines changed
  • portable/ThirdParty/GCC/Posix

1 file changed

+7
-0
lines changed

portable/ThirdParty/GCC/Posix/port.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ Thread_t *pxThread = pvParams;
430430
/* Call the task's entry point. */
431431
pxThread->pxCode( pxThread->pvParams );
432432

433+
/* A function that implements a task must not exit or attempt to return to
434+
* its caller as there is nothing to return to. If a task wants to exit it
435+
* should instead call vTaskDelete( NULL ). Artificially force an assert()
436+
* to be triggered if configASSERT() is defined, so application writers can
437+
* catch the error. */
438+
configASSERT( pdFALSE );
439+
433440
return NULL;
434441
}
435442
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)