This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-CC1352R1: pthread_attr_setstacksize restrictions

Part Number: LAUNCHXL-CC1352R1
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Code Composer Studio


Hello to all

In my program, I use 3 threads
At the same time, I determined by experience that for all 3 threads the sum of parameters pthread_attr_setstacksize
cannot be more than 3550, but it is not obligatory that they are equal (and now it’s 700 + 1400 + 1400)
A value of 1400 allows to the thread to work with the spiFFSI file system.
When this limit 3550 is exceeded, the application simply does not work.

I did not find a description of the restrictions on this parameter.
Does anyone know how this works?

thank you in advance

  • Have you run the ROV and checked what is happening? It could be that you are using memory from heap and that the heap is too small. 

    Could you also provide the code where you define the tasks to see how you set the taskstack sizes?  

  • Any update? 

  • Hi TER!

    Many thanks for attention!

    Unfortunately, I recently started with TI FW and SW and the use of

    Runtime Object View (ROV) causes me certain problems.
    Therefore, I send my code that defines the threads.
    Maybe there is a mistake explaining my problems.


    Thank you very much
    ======== Start of Code.   File  main_tirtos.c  =============
    #include <stdint.h>
    /* POSIX Header files */
    #include <pthread.h>
    /* RTOS header files */
    #include <ti/sysbios/BIOS.h>
    /* Driver header files */
    #include <ti/drivers/GPIO.h>
    /* Example/Board Header files */
    #include <ti/drivers/Board.h>
    #include "disp.h"     

    /* Mutex to protect the reading/writing of the temperature variables */
    pthread_mutex_t temperatureMutex;
    pthread_mutex_t mainMutex;

    extern void *sensorsI2CThread(void *arg0);
    extern void *initThread(void *arg0);      
    extern void *translationThread(void *arg0);
    extern void spiFFSInit( void );

    /* Stack size in bytes. Large enough in case debug kernel is used. */
    #define THREADSTACKSIZE_INIT 700  
    #define THREADSTACKSIZE_I2C  1400 
    #define THREADSTACKSIZE_TRN  1400 

    /*
     *  ======== main ========
     */
    int main(void)
    {
        pthread_t           thread;
        pthread_attr_t      attrs;
        struct sched_param  priParam;
        int                 retc;

        /* Call driver init functions */
        Board_init();

        /* Initialize the attributes structure with default values */
        pthread_attr_init(&attrs);

        /* Set priority, detach state, and stack size attributes */
        priParam.sched_priority = 3;
        retc = pthread_attr_setschedparam(&attrs, &priParam);
        retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
        retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE_INIT);
        if (retc != 0) {
            /* failed to set attributes */
            while (1) {}
        }

        // Init thread
        retc = pthread_create(&thread, &attrs, initThread, NULL);
        if (retc != 0) {
            /* pthread_create() failed */
            while (1) {}
        }

        // Sensors on I2C data read thread
        /*
         *  Let's make the temperature thread a higher priority .
         *  Higher number means higher priority in TI-RTOS.
         */
        priParam.sched_priority = 2;
        retc = pthread_attr_setschedparam(&attrs, &priParam);
        retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE_I2C );
        if (retc != 0) {
            /* failed to set priority */
            while (1) {}
        }

        retc = pthread_create(&thread, &attrs, sensorsI2CThread, NULL);
        if (retc != 0) {
            /* pthread_create() failed */
            while (1) {}
        }

        // Measurement translation thread
        //  Let's make the Measurement translation thread a higher priority .

        priParam.sched_priority = 1;
        retc = pthread_attr_setschedparam(&attrs, &priParam);
        retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE_TRN );
        if (retc != 0) {
            // failed to set priority
            while (1) {}
        }

        retc = pthread_create(&thread, &attrs, translationThread, NULL);
        if (retc != 0) {
            // pthread_create() failed
            while (1) {}
        }

        /* Create a mutex that will protect temperature variables */
        retc = pthread_mutex_init(&temperatureMutex, NULL);
        if (retc != 0) {
            /* pthread_mutex_init() failed */
            while (1) {}
        }

        /* Create a INIT mutex that will protect initialisation */
         retc = pthread_mutex_init(&mainMutex, NULL);
         if (retc != 0) {
             /* pthread_mutex_init() failed */
             while (1) {}
         }

        /* Initialize the GPIO since multiple threads are using it */
        GPIO_init();

        /* Start the TI-RTOS scheduler */
        BIOS_start();

        return (0);
    }
    ========= End of Code ============

  • Could you elaborate why you are not able to get the stack/ heap sizes from ROV?