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.

RTOS/CC3200: Second osi task created, do not start

Part Number: CC3200
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi, I am using the OSI_Taskcreate to run 2 task. The first task runs, but once it finishes, it does not run the 2nd task. I don't get it, I followed the freertos_demo example.

This is in my main code

lRetVal = osi_TaskCreate( WlanAPMode, \
                            (const signed char*)"wireless LAN in AP mode", \
                            OSI_STACK_SIZE, NULL, 1, NULL );

    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }
    
    lRetVal = osi_TaskCreate( SendAnalogInputToClient, "Analog Input to Client",\
        							OSI_STACK_SIZE, NULL, 1, NULL );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the task scheduler
    //
    osi_start();

Once the WLANAPMODE finishes running, it is supposed to run the SendAnalogInputToClient, which is simply a UART_Print msg, but it does not show up on the console. Instead it the console just says that "Error[-1] on the line I run my 2nd task"

Here is the code for the SendAnalogInputToClient

void SendAnalogInputToClient( void *pvParameters )
{


		UART_PRINT("message = ");
		UART_PRINT("\n\r");
		osi_Sleep(200);

}

  • Hi Marcus,

    Try putting the code in your tasks in a loop.

    Best Regards,
    Ben M

  • Hi Ben M,

    I tried placing the codes in SendAnalogInputToClient in a loop and it still doesn't work... I'm not sure, but is anything from the VStartSimpleLinkSpawnTask affecting my task? Because I'm currently integrating the wlanap example and from what I read, my second task may not run at all due to the first task's priority. However, I need the wlanapmode to run simultaneously with my own set of codes.

    To make it more detailed:

    WlanAPMode Task - It consist of the wlanapmode and bsdtcpsocket server to receive data\

    SendAnalogInputToClient Task - It will send data to my client every 2 seconds

    I need both of these task to run at the same time, I can't allow it to pause and go to the other task because the socket connection and wifi connection will be destroyed.. Previously I managed to use PThreads to do this, but even when I tried using the freeRTOSdemo example, my second task doesn't run, I do not know why..



    Marcus

  • Hi Marcus,

    Just a quick comment. You need to realize how RT kernel works.

    It is not used time slice scheduler as if the "big" OS like a Windows, Linux, etc. Scheduler works in RTOS at very simple principle. Task with highest priority is running till is suspended. Task can be suspended by sleep, waiting for synchronisation object, etc.

    For example if you run two task with same priority without any mechanism to suspend task. First task will be executed all the time and 2nd task will not be running. You need use inside your tasks os_Sleep() or synchronisation object (mutex, semaphore, etc.).

    As I advised at previous discussion thread you should see TI-RTOS Kernel Workshop ( processors.wiki.ti.com/.../Introduction_to_the_TI-RTOS_Kernel_Workshop ). Although it is for TI-RTOS and you used FreeRTOS, basics principles are similar.

    Jan
  • Hi Jan,

    Thanks for the response. So for my first task, if i'd like to call in task No.2, I will have to call OS_Sleep() and it will straight away run the task No.2? While it is sleeping, will all the functions stop running, for example, my socket connection. I took a look as you had suggested previously on the videos, but I still do not understand because I am pretty new to this and also I have limited time and only get to work on this project on weekends.. hope you understand.

    Another method I've been thinking, is to bring in POSIX Threads into my task.. However I've had some problems with it, like whether I should use the pthread.h or the <ti/sysbios/posix/pthread.h>. And whenever I build the project, I get errors.. I'm not sure how to add in the library -pthread.

    In Linux C, I can do something like this: gcc -pthread . But in the code composer studio I can't find the settings to do this.

    -Marcus

  • Hi Marcus,

    Without deeper understanding how RTOS works, it is not possible write effectively code based on OS, I think. But you are programmer, it is your choice.

    Functions with prefix os_ are only wrapper around TI-RTOS or FreeRTOS functions. In case of using blocking socket API are other tasks switched also. This blocking SimpleLink API calls includes synchronisation object inside. In case of non-OS this blocking function are only waiting and wasting CPU cycles. But in case OS is used blocking function suspend task and other tasks can run.

    Jan
  • Hi Jan,

    Alright noted! Thank you very much. I will try to read up and watch the video this week and hopefully I understand it more.

    Marcus