mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-07 05:34:59 -05:00
Delete kernel created task in posix port
This commit is contained in:
parent
741f2874d8
commit
d05ee040fd
1 changed files with 16 additions and 30 deletions
46
portable/ThirdParty/GCC/Posix/port.c
vendored
46
portable/ThirdParty/GCC/Posix/port.c
vendored
|
|
@ -73,7 +73,6 @@
|
|||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "list.h"
|
||||
#include "timers.h"
|
||||
#include "utils/wait_for_event.h"
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
@ -87,7 +86,6 @@ typedef struct THREAD
|
|||
void * pvParams;
|
||||
BaseType_t xDying;
|
||||
struct event * ev;
|
||||
ListItem_t xThreadListItem;
|
||||
} Thread_t;
|
||||
|
||||
/*
|
||||
|
|
@ -112,7 +110,6 @@ static BaseType_t xSchedulerEnd = pdFALSE;
|
|||
static pthread_t hTimerTickThread;
|
||||
static bool xTimerTickThreadShouldRun;
|
||||
static uint64_t prvStartTimeNs;
|
||||
static List_t xThreadList;
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupSignalsAndSchedulerPolicy( void );
|
||||
|
|
@ -196,14 +193,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
|||
|
||||
thread->ev = event_create();
|
||||
|
||||
vListInitialiseItem( &thread->xThreadListItem );
|
||||
listSET_LIST_ITEM_OWNER( &thread->xThreadListItem, thread );
|
||||
|
||||
vPortEnterCritical();
|
||||
|
||||
/* Add the new thread in xThreadList. */
|
||||
vListInsertEnd( &xThreadList, &thread->xThreadListItem );
|
||||
|
||||
iRet = pthread_create( &thread->pthread, &xThreadAttributes,
|
||||
prvWaitForStart, thread );
|
||||
|
||||
|
|
@ -234,8 +225,6 @@ BaseType_t xPortStartScheduler( void )
|
|||
{
|
||||
int iSignal;
|
||||
sigset_t xSignals;
|
||||
ListItem_t * pxIterator;
|
||||
const ListItem_t * pxEndMarker;
|
||||
|
||||
hMainThread = pthread_self();
|
||||
prvPortSetCurrentThreadName("Scheduler");
|
||||
|
|
@ -262,18 +251,18 @@ BaseType_t xPortStartScheduler( void )
|
|||
sigwait( &xSignals, &iSignal );
|
||||
}
|
||||
|
||||
/* Cancel all the running thread. */
|
||||
pxEndMarker = listGET_END_MARKER( &xThreadList );
|
||||
/* Cancel the Idle task and free its resources */
|
||||
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
|
||||
vTaskDelete( xTaskGetIdleTaskHandle() );
|
||||
#endif /* #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */
|
||||
|
||||
for( pxIterator = listGET_HEAD_ENTRY( &xThreadList ); pxIterator != pxEndMarker; pxIterator = listGET_NEXT( pxIterator ) )
|
||||
{
|
||||
Thread_t * pxThread = ( Thread_t * ) listGET_LIST_ITEM_OWNER( pxIterator );
|
||||
#if ( configUSE_TIMERS == 1 )
|
||||
/* Cancel the Timer task and free its resources */
|
||||
vTaskDelete( xTimerGetTimerDaemonTaskHandle() );
|
||||
#endif /* #if ( configUSE_TIMERS == 1 ) */
|
||||
|
||||
pthread_cancel( pxThread->pthread );
|
||||
event_signal( pxThread->ev );
|
||||
pthread_join( pxThread->pthread, NULL );
|
||||
event_delete( pxThread->ev );
|
||||
}
|
||||
/* Cancel the last task. */
|
||||
vTaskDelete( xTaskGetCurrentTaskHandle() );
|
||||
|
||||
/*
|
||||
* clear out the variable that is used to end the scheduler, otherwise
|
||||
|
|
@ -294,6 +283,8 @@ BaseType_t xPortStartScheduler( void )
|
|||
|
||||
void vPortEndScheduler( void )
|
||||
{
|
||||
Thread_t * pxCurrentThread;
|
||||
|
||||
/* Stop the timer tick thread. */
|
||||
xTimerTickThreadShouldRun = false;
|
||||
pthread_join( hTimerTickThread, NULL );
|
||||
|
|
@ -302,7 +293,10 @@ void vPortEndScheduler( void )
|
|||
xSchedulerEnd = pdTRUE;
|
||||
( void ) pthread_kill( hMainThread, SIG_RESUME );
|
||||
|
||||
pthread_exit( NULL );
|
||||
/* Waiting to be deleted here. */
|
||||
pxCurrentThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||
event_wait( pxCurrentThread->ev );
|
||||
pthread_testcancel();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -485,11 +479,6 @@ void vPortCancelThread( void * pxTaskToDelete )
|
|||
{
|
||||
Thread_t * pxThreadToCancel = prvGetThreadFromTask( pxTaskToDelete );
|
||||
|
||||
/* Remove the thread from xThreadList. */
|
||||
vPortEnterCritical();
|
||||
uxListRemove( &pxThreadToCancel->xThreadListItem );
|
||||
vPortExitCritical();
|
||||
|
||||
/*
|
||||
* The thread has already been suspended so it can be safely cancelled.
|
||||
*/
|
||||
|
|
@ -594,9 +583,6 @@ static void prvSetupSignalsAndSchedulerPolicy( void )
|
|||
|
||||
hMainThread = pthread_self();
|
||||
|
||||
/* Setup thread list to record all the task which are not deleted. */
|
||||
vListInitialise( &xThreadList );
|
||||
|
||||
/* Initialise common signal masks. */
|
||||
sigfillset( &xAllSignals );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue