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.

PROCESSOR-SDK-AM335X: Porting POSIX to RTOS

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: SYSBIOS

Goodmorning,

I write you since I need to port a linux application that uses POSIX threads into RTOS system. I have teh following doubt:

  1. In am335x_app_bbbam335x.cfg as indicated by , I added the following:
    /* Load the posix package */
    var Settings = xdc.useModule('ti.posix.tirtos.Settings');
    Settings.enableMutexPriority = true;
    besides I had to change Task.enableIdleTask = true; otherwise I got an error, is it correct?
  2. In Linux, I used clock_nanosleep(&ts, NULL); where ts is a timespec staruct. In RTOS implementation of POSIX do I have to use sleep(int usec) contained in unistd.h?
  3. In Linux, I used clock_gettime(CLOCK_MONOTONIC, &ts); I can use it in RTOS implementation, right? Do I have only to call at the in the initialization clock_settime(CLOCK_REALTIME, &ts); to set the time to 0?
  4. Despite having included
    #include <pthread.h>
    #include <sys/types.h>
    inside the pthread.h file many function were excluded because of some ifdef. To avoid this problem, I had to define some constant _POSIX_THREADS  and _POSIX_THREAD_PRIORITY_SCHEDULING ,as shown below. Is it normal?
  5. Can RTOS Task and POSIX thread coexist inside the same program?

Thank you for the assistance.

Regards,

Davide Brunelli

  • Hi Davide,

    TI-POSIX is documented here: <BIOS>\docs\tiposix\Users_Guide.html.

    There is a POSIX demo that executes on AM335x which is documented here: http://software-dl.ti.com/processor-sdk-rtos/esd/docs/06_01_00_08/rtos/index_examples_demos.html?highlight=posix#posix-smp-demo

    I'm looping in a colleague for further help on these questions.

    Thanks and regards,
    Frank

  • Hi David,

    1. There’s this in $TREES/tiposix/tiposix-1.31.00.09/packages/ti/posix/tirtos/Settings.xs:

        /*

         *  BIOS posix uses the Idle task to clean up detached pthreads that

         *  have exited.  Check that the Idle task is enabled.

         */

        if (Task.enableIdleTask == false) {

            throw new xdc.global.Error("Task.enableIdleTask must be set to true");

        }

    However, this has nothing to do with Settings.enableMutexPriority setting (not sure If you were implying that).

    2. There is a clock_nanosleep() in tirtos posix, but its function prototype is different than you are using.  There is also nanosleep() in tirtos posix, which has the same function prototype arguments as your Linux usage of clock_nanosleep().

    Take a look in <tiposix>/packages/ti/posix/ccs/time.h

     

    3. Yes, you can use clock_gettime(CLOCK_MONOTONIC, &ts) in TI-RTOS.

    You don’t need to call clock_settime() unless you want to establish a new time base.

    4. You should have the TI-POSIX include folder on the include path *before* the toolchain include. When including pthread.h, it will include the TI-POSIX version, which will then include the toolchain version. Something like:

    -I<SDK>/.../ti/posix/gcc

    Also (in case you were), you should not be using the –std=gnu99 compiler. Using gnu99 will include the GNU POSIX implementation, which collides with the TI-POSIX implementation. Using either c99 or c++98 turns off GNU POSIX.

    5. Yes. In fact, POSIX threads are implemented as TI-RTOS Tasks.

    PS: It would be good to know what SYSBIOS/tiposix version are you using. These solutions are based on a recent tiposix release.

    -Kevin

  • Hello Kevin,

    thank you for your answer. Regarding your answer:

    1. Well, the error that I got asked me explicity to set Task.enableIdleTask = true, for the reason that you clearly explained. So it's ok.
    2. I've checked, ok
    3. I've checked, ok
    4. As you suggested I changed the GNU compiler command as "${CG_TOOL_GCC}" -c -std=c99 and all the posix symbols appear defined. Apparently I don't need to include any extra directories aside the default include ones of the example project.
    5. Ok, the sdk version that I'm using is ti-processor-sdk-rtos-am335x-evm-06.01.00.08-Windows-x86-Install

    Thank you for your support.

    In case I need further doubts, I'll write again.

    Regards,

    Davide