pthread: Remove pthread TLS cleanup dependency on FreeRTOS Static Task Cleanup Hook

This commit removes the need to define the vTaskCleanupTCB hook in
pthread to cleanup the thread-specific data before a thread is deleted.
This commit is contained in:
Sudeep Mohanty
2022-10-31 10:02:03 +01:00
parent 8416f0f540
commit b3755b751e
12 changed files with 90 additions and 83 deletions

View File

@@ -365,6 +365,8 @@ int pthread_join(pthread_t thread, void **retval)
pthread_delete(pthread);
xSemaphoreGive(s_threads_mux);
}
/* clean up thread local storage before task deletion */
pthread_internal_local_storage_destructor_callback(handle);
vTaskDelete(handle);
}
@@ -399,6 +401,8 @@ int pthread_detach(pthread_t thread)
} else {
// pthread already stopped
pthread_delete(pthread);
/* clean up thread local storage before task deletion */
pthread_internal_local_storage_destructor_callback(handle);
vTaskDelete(handle);
}
xSemaphoreGive(s_threads_mux);
@@ -409,9 +413,8 @@ int pthread_detach(pthread_t thread)
void pthread_exit(void *value_ptr)
{
bool detached = false;
/* preemptively clean up thread local storage, rather than
waiting for the idle task to clean up the thread */
pthread_internal_local_storage_destructor_callback();
/* clean up thread local storage before task deletion */
pthread_internal_local_storage_destructor_callback(NULL);
if (xSemaphoreTake(s_threads_mux, portMAX_DELAY) != pdTRUE) {
assert(false && "Failed to lock threads list!");