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.

Task blocked by unknown

Other Parts Discussed in Thread: CC3200

Hello,

I am using TI RTOS version 2.00.02.36 for CC3200 MCU.


I have five tasks in code. Among all one task always stays in blocked state. RTOS detailed view every time shows blocked by unknown. Kindly give me some input so I can understand what does it mean. All tasks created statically.

Regards,

Niral

  • Hi Niral,

    In ROV, the following code determines when to use Unknown:

    if (checkMailboxes(view, obj) == true) return;
    if (checkGateMutexes(view, obj) == true ) return;
    if (checkGateMutexPris(view, obj) == true ) return;
    if (checkSemaphores(view, obj) == true) return;
    if (checkEvents(view, obj) == true ) return;
    if (checkTaskSleep(view, obj) == true ) return;

    view.blockedOn = "Unknown";

    Having said that, if a block object (e.g. semaphore) is constructed instead of created, under certain conditions ROV does not know about it. So it says Unknown.

    Fyi...construct is like create except no memory allocation occurs. Instead the structure is supplied to the construct (instead of being allocated in the create).

    Please note the drivers in TI-RTOS use construct instead of create for kernel objects (in the version you are using).

    Todd

  • Hi ToddMullanix ,

    I got your point. So is there a way to determine what is blocking task?

    I have created task statically..

    var paraUartRcv = new Task.Params();
    paraUartRcv.instance.name = "objUartRcv";
    paraUartRcv.priority = 1;
    paraUartRcv.stackSize = 1024;
    Program.global.objUartRcv = Task.create("&uartRcv_Tsk", paraUartRcv);

    Task Code:

    Void uartRcv_Tsk(UArg arg0, UArg arg1)
    {
    	int iReadByte;
    
    	while(!g_bRunRcvTsk)
    	{
    		Task_sleep(1000);
    	}
    
    	while(1)
    	{
    		Log_e("\n\n[[UART]]\n\n");
    		iReadByte = UART_read(uart1, &zbRxBuff, 50);
    		if(iReadByte > 0)
    		{
    			zbRxBuff[iReadByte] = '\0';
    			rxDone = 1;
    			Log_e(zbRxBuff);
    		}
    	}
    }

    Log_e is a macro of System_printf() and System_flush(). However code is in forever loop it prints [[UART]] in console one time only. After that it went into blocked state..


    UART_read() is blocking task for infinite time. Following UART configuration I'm using..

    UART_Params 	  uartParams;
    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_NEWLINE;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 9600;
    
    uart1 = UART_open(Board_UART1, &uartParams);
    if (uart1 == NULL) {
            System_abort("Error opening the UART");
    }
  • The default mode in UART_Params_init is UART_MODE_BLOCKING, so your call to UART_read is going to be a blocking call. UART uses a semaphore for synchronization between the UART interrupt and blocked task that called UART_read.  Since this is a constructed Semaphore (again to avoid memory allocation in the UART_open), you'll see that the Task is blocked on "Unknown" when it is still waiting for data...we know this stinks and are looking at ways to make this better in a future release.

    If you look in the callstack tab for the tasks in ROV, you should be able to see where each task is. This information can point you to what is happening. Please note the callstack information is most reliable when you use the debug option when building the kernel. The options are on the BIOS->Runtime page in the graphical .cfg tool.

    Hope that helps,

    Todd

  • Todd,

    From reference to your replay I have figured out that UART_read() keep waiting for data and hence block task. So, I have used readTimeout and it solved issue of task blocking however, I could not find any document regarding readTimeout.

    I have set readTimeout to 20 and noticed that I can receive max of 16bytes, rest of is ignored completely. Setting readTimeout to more than 20 results to termination of code.

    Niral
  • The timeout is used in Semaphore_pend so the units are Clock ticks (1ms by default). What type of termination occurs when the timeout is >20.

    Todd