diff options
Diffstat (limited to 'utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c')
| -rw-r--r-- | utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c b/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c index acac53cc..3391bf8a 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c +++ b/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c @@ -9,6 +9,8 @@ * SPDX-License-Identifier: MIT **************************************************************************/ +// Portions of this file were generated with AI assistance. + /**************************************************************************/ /**************************************************************************/ /** */ @@ -348,6 +350,7 @@ TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, ret = tx_thread_create(&pxTaskBuffer->thread, (CHAR *)pcName, txfr_thread_wrapper, (ULONG)pvParameters, puxStackBuffer, stack_depth_bytes, prio, prio, 0u, TX_DONT_START); if(ret != TX_SUCCESS) { + (void)tx_semaphore_delete(&pxTaskBuffer->notification_sem); TX_FREERTOS_ASSERT_FAIL(); return NULL; } @@ -356,6 +359,12 @@ TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, ret = tx_thread_resume(&pxTaskBuffer->thread); if(ret != TX_SUCCESS) { + /* The thread exists but was never started. It has to be terminated + before it can be deleted, which is the order the idle task uses when + it reaps a deleted task. */ + (void)tx_thread_terminate(&pxTaskBuffer->thread); + (void)tx_thread_delete(&pxTaskBuffer->thread); + (void)tx_semaphore_delete(&pxTaskBuffer->notification_sem); TX_FREERTOS_ASSERT_FAIL(); return NULL; } @@ -643,7 +652,7 @@ void vTaskPrioritySet(TaskHandle_t xTask, char *pcTaskGetName(TaskHandle_t xTaskToQuery) { TX_THREAD *p_thread; - char *p_task_name; + const char *p_task_name; UINT ret; if(xTaskToQuery == NULL) { @@ -658,7 +667,8 @@ char *pcTaskGetName(TaskHandle_t xTaskToQuery) return 0; } - return p_task_name; + /* FreeRTOS exposes task names through a writable pointer type. */ + return (char *)p_task_name; } @@ -1487,6 +1497,7 @@ QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, ret = tx_semaphore_create(&pxQueueBuffer->write_sem, "", uxQueueLength); if(ret != TX_SUCCESS) { + (void)tx_semaphore_delete(&pxQueueBuffer->read_sem); return NULL; } @@ -1543,11 +1554,16 @@ QueueHandle_t xQueueCreate(UBaseType_t uxQueueLength, UBaseType_t uxItemSize) ret = tx_semaphore_create(&p_queue->read_sem, "", 0u); if(ret != TX_SUCCESS) { + txfr_free(p_mem); + txfr_free(p_queue); return NULL; } ret = tx_semaphore_create(&p_queue->write_sem, "", uxQueueLength); if(ret != TX_SUCCESS) { + (void)tx_semaphore_delete(&p_queue->read_sem); + txfr_free(p_mem); + txfr_free(p_queue); return NULL; } |
