I need to exit FreeRTOS without aborting whole Windows application. Why? FreeRTOS code is in DLL as a plugin to another application and DLL load could start FreeRTOS and DLL unload needs to correctly finish FreeRTOS.
I hope that I has been solved this task, and FreeRTOS can exit. In 99% FreeRTOS exits correctly. I would like to share my findings with others.
I am rejected to upload my code as attachment, if you are interested in this patch, please allow me to upload code snippet.
Sometimes it is neccesary to use FreeRTOS in DLL plugin and not to destroy whole host application. Yes, there could be clear solution that DLL starts some isolated process, but the interprocess communication could be not too easy to design.
void vPortEndScheduler( void )
{
SetEvent(pvInterruptEvent);
ReleaseMutex( pvInterruptEventMutex );
CloseHandle(pvInterruptEvent); // This will release all loops.
CloseHandle(pvInterruptEventMutex);
vTaskDelete(NULL); // The FreeRTOS calling thread must abort itself.
//exit( 0 );
}
My code is attached, it could be idea how to stop FreeRTOS this way. I know that it is a pretty hack, but it seems to work at least for my purpose. Prototype demonstrator on Windows does not need such critical stability like application in MCU. But still source code could be compilled to MCU without any change.
There could be another approach. When all threads commit suicide, main FreeRTOS thread exits.
Hello Jara,
I’m running into the same issue as you did back then. And of course your solution works wonderful. However I’m trying to find a way not to change the FreeRTOS source. Have you since found another solution? The biggest issue I found is to close the pvInterruptEventMutex handle, since it’s static I have no way of accessing it from other sourcefiles.
@aggarg are there any plans to simplify this? or to include this in any way? I don’t understand why @Jara solution for example is not implemented in the windows port?