yashdosi
yashdosi

Reputation: 1256

Inter Thread Communication in C

As a part of my project I have to modify a Numerical Integration Algorithm using threads.

This is roughly what happens in the conventional sequential approach..

void Controller(struct DE)
{
    //initialization step
    for(;;)   //till the entire range has not been covered...
    {
         //compute the next time-point solution using the previously known solutions.
         NIiter();
         //then check if the result is acceptable or not and take the necessary steps...
    }
}

Now this is what I intend to do....

void Controller(struct DE)
{
    //initialization step
    for(;;)   //till the entire range has been covered...
    {
         //compute the next time using the previously known solution.
         NIiter();
         //when I have an approximate solution available..launch a thread to compute the next time-point using this approximate solution as a previous solution...something like forward pipelining...
         //then check if BOTH the results are acceptable or not and take the necessary steps...
    }
}

But I dont understand how to notify my controller that the an approximate solution is available...so it can launch a new thread...

This is my first exposure to multi-threaded programming...so forgive me if this seems to be an obvious question..also I am using Pthread library in my project...

Upvotes: 0

Views: 5878

Answers (1)

Ed Heal
Ed Heal

Reputation: 60037

This is a vast topic but here are some pointers

  1. Worker threads - Basically create a bunch of threads and have a queue of tasks. They take one of the queue and do the job
  2. IPC - Here you have semaphores, shared memory, messaging passing. Links are on the page

The Wikipedia will get you going.

Upvotes: 1

Related Questions