Topic: Multithreading correct settings

Hi,
I`m tried the mqtt simple and it work flawlessly. Now i like to try the multithreading approach in the examples folder for a freertos setup.
When unlocking this feature got those APIs.

    /* Posix (Linux/Mac) */
    #include <pthread.h>
    #include <sched.h>
    #include <errno.h>
    typedef pthread_t THREAD_T;
    #define THREAD_CREATE(h, f, c) ({ int ret = pthread_create(h, NULL, f, c); if (ret) { errno = ret; } ret; })
    #define THREAD_JOIN(h, c)      ({ int ret, x; for(x=0;x<c;x++) { ret = pthread_join(h[x], NULL); if (ret) { errno = ret; break; }} ret; })
    #define THREAD_EXIT(e)         pthread_exit((void*)e)

but there for Linux. Do i have to overwrite those and place them somewhere? For instance Semaphores are defined and unlocked in "mqtt_client.c".

Thanks in advance

Share

2

Re: Multithreading correct settings

Hi MO380,

FreeRTOS should work with the POSIX interface:
https://freertos.org/Documentation/03-L … 04-pthread

If you want to use the native API, you would need to set up those macros.

Thanks,
Eric - wolfSSL Support

3

Re: Multithreading correct settings

Hi embhorn,

i'm using the freertos library added by STM32CubeMx, haven't seen any pthread related stuff there. So have to implement them. I guess THREAD_CREATE & THREAD_EXIT shouldn't be a problem, but what about THREAD_JOIN. Could i implement it by using following

vTaskGetInfo( tcpclientHandle, &xTaskDetails,eInvalid );
if(xTaskDetails.eCurrentState == eDeleted) {...}

Just wait until thread has exited.

Thanks in advance

Share