eclipse-threadx / threadx

Eclipse ThreadX is an advanced real-time operating system (RTOS) designed specifically for deeply embedded applications.
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/threadx/index.md
MIT License
2.89k stars 782 forks source link

_tx_semaphore_created_ptr is always NULL #369

Closed xray-bit closed 6 months ago

xray-bit commented 6 months ago

Describe the bug I want to print the semaphore information, but the value of the pointer variable _tx_semaphore_created_ptr is always NULL.

Device: Cortex-M4 ThreadX Version: 6.4.1 Toolchain: arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi

To Reproduce

#include <tx_api.h>
#include <tx_semaphore.h>

// ...

static void show_sem(void)
{
    uart_printf("sem_ptr = %p\n", _tx_semaphore_created_ptr);
    uart_printf("sem_cnt = %d\n", _tx_semaphore_created_count);
}

// ...

I have created several semaphores in other files and they are running normally.

Expected behavior expected:

sem_ptr = 0x2000****
sem_cnt = [greater than 0]

but the actual output

sem_ptr = 0
sem_cnt = 0
xray-bit commented 6 months ago

any help?

amgross commented 6 months ago

Hi @xray-bit , can you please give us 'minimal reproducible example'? From what you wrote I would guess you have some bug and show_sem is running before you created the semaphores or after you deleted them.

xray-bit commented 6 months ago

@amgross Sorry, I was busy earlier. Thanks for the reply.
When I created a new project to reproduce the problem, it became normal again and I will check why the previous one was faulty.