Hi again algorism,
Let's say there are two threads/functions running concurrently in the program and some of the data generated in one thread needs to be shared with the other thread/function. Some or all of the data may want to be shared between the two threads but I would also like to know how one thread is able to signal the other thread when certain procedures and/or conditions have been carried out.
This is simply a question of a standardized style of implementation for a system which caters to the internal messaging of a program. I realize some of these issues can be totally avoided with careful implementation and careful ordering of functions and procedures. However I am sure there is a precedent for organizing the program execution with greater flexibility. Thereby this issue arises with respect to the messaging across program internals.
Code:
//
// Header declarations
//
struct data
{
variables;
}
void *thread_func1(struct data)
{
while(1)
{
ops:
ops A;
// Some data used from ops C or D;
ops B;
// Some data used from ops C or D;
}
return;
}
void *thread_func2(struct data)
{
while(1)
{
ops:
ops C;
ops D;
// Some data used from ops A or B;
}
return;
}
int main()
{
thread_func1(data);
thread_func2(data);
return;
}
Additional variables could be added to the struct, to say give a boolean signal when A, B, C, D or parts of A, B, C, D have competed. So in such a scenario at least 4 additional variables would be added to the struct to provide the relevant signals. Are there better ways to implement things like these?