08-20-2008 08:14 AM
Hallo to all
my dilemma is as follows:
i have to build a program that uses three parallel loops.
the first one is taking care of data acquisition, control loops and graphs.
the second one is saving every constant time (the constant changes for different stages).
and the third is a loop of events (who changes the parameters of the other loops)
the reason of working in such a way is that speed is very important and the events seldom occurs.
my question is:
is the only way to move information between the loops without making them to wait is by global and local variables? Or is there another way of doing it?
Besides I would appreciate advices on how to avoid and recognize race conditions.
Thanks in advance
Shai.
08-20-2008 09:17 AM
Hi Shai,
One of the best techniques to use is queues. If you look at the templates for the producer/consumer architecture then this is the method they use. (File>>New then From Template>>Frameworks>>Design Patterns and then either producer/consumer (events) or (data). Also if you search the example finder for queues several examples are found. I would suggest looking at queue basics for your application.
Queues are useful as they guarantee that no data will be lost. If you are only concerned with the latest value then notifiers can also be used.
Regards,