Community
Participate
Working Groups
These to functions are key function for the correct functioning of the FORTE execution model for IEC 61499 FB networks. Currently these are required to be implemented in CThread. Therefore for each new operating system this has to be done. However not all threads in FORTE need this functions. To be more specific only CEventChainExecutionThread is needing them and also demands a specific behavior. The most stable deadlock avoiding implementation is by implementing them with a counting semaphore. Therefore the better solution would be to introduce a Semaphore abstraction class to be provided for each operating system and moving the functionality of these functions to the CEventeChainExecutionThread. This would make it easier to correctly port FORTE to new operating systems.
I'Ve implemetned this feature and tested in posix. Further tests are needed.
A problem I found was that if the CDevice is deleted without sending a stop command before, the CEventChainExecutionThread may never end. This occurs when CEventChainExecutionThread.run() is in selfSuspend, waiting for the semaphore. Because the stop command is not received, the end() function in the CEventChainExecutionThread is not called (where the resumeSuspend() is called, incrementing the semaphore). So when the destuctor of the CResource is called, it calls the destructor of the CEventChainExecutionThread which does nothing, but calls the destructor of the Thread. This setAlive to false and waits infinite for the thread to end, but since the thread is still in selfSuspend, it never ends. Callind the end() function in the destructor of CEventChainExecutionThread would solve this issue.
Normally a device it should not be possible to delete a device without that a stop command is issued. At least for all FORTE versions I know to shutdown FORTE is the sending of an KILL command via the management interface or the KILL command is issued from a OS signal (e.g., SIG_TERM). If you have a different way to shutdown your device I would recommend that you invoke the changeFBExecutionState(cg_nMGM_CMD_Kill); in the desctructor of your device or even better before you delete your device.
As the original issue of this issue is implemented and working with 1.9.0 I close this issue for now.