Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRTOS/FreeRTOS-Kernel.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Paulyshka <me@mixaill.net>2024-01-18 22:35:16 +0300
committerGitHub <noreply@github.com>2024-01-18 22:35:16 +0300
commite6f6d0ecf4a96bcd6e23e3334ac463056f939be8 (patch)
tree630c3c86b25bef78c021b9e162e89849776c5dee
parent52ab3d0f22bce9195bc965ebc56beec6d57a558b (diff)
Posix port - set name for threads (#950)
Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
-rw-r--r--portable/ThirdParty/GCC/Posix/port.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/portable/ThirdParty/GCC/Posix/port.c b/portable/ThirdParty/GCC/Posix/port.c
index d0152169a..f84517346 100644
--- a/portable/ThirdParty/GCC/Posix/port.c
+++ b/portable/ThirdParty/GCC/Posix/port.c
@@ -51,6 +51,10 @@
*----------------------------------------------------------*/
#include "portmacro.h"
+#ifdef __linux__
+ #define __USE_GNU
+#endif
+
#include <errno.h>
#include <pthread.h>
#include <signal.h>
@@ -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.
*/
@@ -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. */
@@ -383,6 +398,8 @@ static void * prvTimerTickHandler( void * arg )
{
( void ) arg;
+ prvPortSetCurrentThreadName("Scheduler timer");
+
while( xTimerTickThreadShouldRun )
{
/*
@@ -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 );