Compare commits

...

5 commits

Author SHA1 Message Date
Muhammad Usman
4e109896c3
Merge b8d21ede7c into 32e581636f 2025-07-24 10:57:52 +05:00
Gaurav-Aggarwal-AWS
32e581636f
Delete thread key on process exit (#1297)
Previously, the shared thread key was deleted in xPortStartScheduler
after scheduler was ended. This created a race condition where
prvThreadKeyDestructor (responsible for freeing thread-specific heap
memory) would not be called if xPortStartScheduler deleted the key
before the last task deletion, as destructors are not invoked after key
deletion (see https://github.com/walac/glibc/blob/master/nptl/pthread_create.c#L145-L150).

Move thread key deletion to process exit to ensure all thread-specific
memory is properly freed.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2025-07-24 11:07:27 +05:30
usman-pak1991
b8d21ede7c
event_group.c visibilty converted to public from private. 2025-06-13 12:42:24 +05:00
Ghufran Khan
b942fdaad0
Merge pull request #1 from Selectronic-AU/feature/battries_msvc_port_fix
Excluding windows api from portmacro.h and adding it to port.c
2025-04-01 14:23:17 +11:00
Jauhersaeed
1973533fd4
excluding windows api from portmacro.h and adding it to port.c to avoid yeild() defined as macro in freertos-addons 2025-04-01 07:13:30 +05:00
4 changed files with 14 additions and 12 deletions

View file

@ -241,7 +241,7 @@ add_library(freertos_kernel STATIC)
add_subdirectory(include)
add_subdirectory(portable)
target_sources(freertos_kernel PRIVATE
target_sources(freertos_kernel PUBLIC
croutine.c
event_groups.c
list.c

View file

@ -33,6 +33,17 @@
#include "FreeRTOS.h"
#include "task.h"
#ifdef WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#else
#include <winsock.h>
#endif
#include <windows.h>
#include <timeapi.h>
#include <mmsystem.h>
#include <winbase.h>
#ifdef __GNUC__
#include "mmsystem.h"
#else

View file

@ -29,16 +29,7 @@
#ifndef PORTMACRO_H
#define PORTMACRO_H
#ifdef WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#else
#include <winsock.h>
#endif
#include <windows.h>
#include <timeapi.h>
#include <mmsystem.h>
#include <winbase.h>
#ifdef __cplusplus
extern "C" {

View file

@ -140,6 +140,8 @@ static void prvThreadKeyDestructor( void * pvData )
static void prvInitThreadKey( void )
{
pthread_key_create( &xThreadKey, prvThreadKeyDestructor );
/* Destroy xThreadKey when the process exits. */
atexit( prvDestroyThreadKey );
}
/*-----------------------------------------------------------*/
@ -315,8 +317,6 @@ BaseType_t xPortStartScheduler( void )
/* Restore original signal mask. */
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
prvDestroyThreadKey();
return 0;
}
/*-----------------------------------------------------------*/