I am trying to write a program to process images. The aim is to process different parts of an image at the same time. So i am using multithreading.
Lets say the input image has 1000 rows. Each thread is supposed to process 100 rows at one time. So 10 threads would do the job. But i want to have 3 threads working at the same time. So i decided to use JOINABLE threads. And with pthread_join i wait for each 3 threads to finish their jobs. Then i call the other three threads.
Thread1 Active
Thread2 Active
Thread3 Active
Thread1 Done
Thread2 Done
Thread3 Done
Thread4 Active
Thread5 Active
Thread6 Active
Thread4 Done
Thread5 Done
Thread6 Done
so on...
It is working now. But my problem is I want to start a thread when a previous thread finishes its job, without waiting for the other two threads to finish their jobs.
something like this
Thread1 Active
Thread2 Active
Thread3 Active
Thread1 Done
Thread4 Active --->Thread4 doesnt wait for 2. and 3. to finish their jobs
Thread2 Done
Thread3 Done