FreeRTOS Critical Section issue on OR1200

avamsi wrote on Thursday, July 19, 2012:

We are running freeRTOSV6.1.1 on Openrisc1200. There is a problem with the critical section execution. Actually, we created three tasks with same prority(same time slice). In the task functionality, we called some print functions that internally calls portENTERCRITICAL & portEXITCRITICAL to protect the data to send on uart(console prints). The tasks executed for some time(printed the text on console). Later only one task is running fine. We are unable to find the control of the other tasks(even did not hit break point).  Some times that task is also not running, control jumping to unknown location.With out this critical section part in the tasks, we are sure that tasks are running fine all the time. The same issue raised in the ISR execution also. When ever we used this critical section part, control did not return form ISR to task. Can some one explain how to make use of this critical sections with out effecting the  task.


rtel wrote on Thursday, July 19, 2012:

I have absolutely no idea about the OpenRISC architecture, or the port you are using, so I’m afraid I cannot give an authoritative answer, but from experience check to ensure your print functions are not themselves manipulating the interrupt state through any means other than calls to taskENTER_CRITICAL() and taskEXIT_CRITICAL() - assuming your implementation of these functions takes care of critical section nesting, any other interrupt manipulation will break the nesting count.

You can also consider using a simple mutex() to access the print function, ensuring the buffers a flushed before the mutex is returned, or using scheduler locking (vTaskSuspendAll() and xTaskResumeAll()) in place of a critical section.