Skip to content

Commit

Permalink
Posix port - set name for threads (#950)
Browse files Browse the repository at this point in the history
Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
  • Loading branch information
Mixaill and jasonpcarroll committed Jan 18, 2024
1 parent 52ab3d0 commit e6f6d0e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions portable/ThirdParty/GCC/Posix/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
*----------------------------------------------------------*/
#include "portmacro.h"

#ifdef __linux__
#define __USE_GNU
#endif

#include <errno.h>
#include <pthread.h>
#include <signal.h>
Expand Down Expand Up @@ -134,6 +138,16 @@ void prvFatalError( const char * pcCall,
}
/*-----------------------------------------------------------*/

static void prvPortSetCurrentThreadName(char * pxThreadName)
{
#ifdef __APPLE__
pthread_setname_np(pxThreadName);
#else
pthread_setname_np(pthread_self(), pxThreadName);
#endif
}
/*-----------------------------------------------------------*/

/*
* See header file for description.
*/
Expand Down Expand Up @@ -224,6 +238,7 @@ BaseType_t xPortStartScheduler( void )
const ListItem_t * pxEndMarker;

hMainThread = pthread_self();
prvPortSetCurrentThreadName("Scheduler");

/* Start the timer that generates the tick ISR(SIGALRM).
* Interrupts are disabled here already. */
Expand Down Expand Up @@ -383,6 +398,8 @@ static void * prvTimerTickHandler( void * arg )
{
( void ) arg;

prvPortSetCurrentThreadName("Scheduler timer");

while( xTimerTickThreadShouldRun )
{
/*
Expand Down Expand Up @@ -493,6 +510,9 @@ static void * prvWaitForStart( void * pvParams )
uxCriticalNesting = 0;
vPortEnableInterrupts();

/* Set thread name */
prvPortSetCurrentThreadName(pcTaskGetName(xTaskGetCurrentTaskHandle()));

/* Call the task's entry point. */
pxThread->pxCode( pxThread->pvParams );

Expand Down

0 comments on commit e6f6d0e

Please sign in to comment.