FreeRTOS Critical Section issue on OR1200
Posted by avamsi
on 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.
RE: FreeRTOS Critical Section issue on OR1200
Posted by Richard
on 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.
Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.