Objects as event flags, mutexes etc. can be defined per thread in the configurator. But their purpose is thread sychronization so there is a need for shared objects which should be visible from all threads and mainly initialized before any thread starts.
There is tx_application_define_user() function which could be used for this purpose but it is called AFTER all threads starts (which makes no sense to me). So how to perform a, I believe, common task i.e. call initialization code which needs to be called before any thread starts? I could make every thread wait on an event flag set after all initialization is done. Fine but it needs global object and it has to be initialized BEFORE any thread starts.
Well, I can define such an object in the first thread and because threads are started in defined order and objects are created before thread really starts it should work. But it is ugly and probably depends on an undocumented behavior. Is there a supported and more elegant way how to do it?
In reply to WarrenM:
In reply to Michal:
if you look at the initialisation code for threadx in the file tx_initialize_kernel_enter.c (you will need to add threadx source code to the project) you can see the initialisation flow for threadx. The Threads and thread objects added in the Synergy configurator are created in the call to tx_application_define(); (which will also call tx_application_define_user() if added by the user to the project) :-
However the threads are not actually executed until the scheduling loop is entered :-
In reply to Jeremy:
Well, it was a bit more complicated. I've found some modules as crypto can't be initialized from tx_application_define_user() because their lower part isn't initialized, yet. So I had to divide initialization to the two parts. The first is called from tx_application_define_user() and creates global objects and the second is called at the start of one thread and all other threads wait until it is done using global event flags created in the first phase. Rather messy but works.