I have to modify an image filtering program to divide the work among separate threads. There will be two image pointers (just a redefinition of a unsigned char pointer). One is the image to be modified, and the other is the output pointer. Each thread will only read values from the input image, which will not be modified at all. And each thread will write indepedent pieces of the output image. So, is there any reason to use semaphores? I've never used threads before, but I don't see the necessity for them in this program, since I can't think of any situation for corruption/race conditions.
Second question; where do variables have to be declared to be part of the shared memory across all threads? Will variables made inside of main be shared, or do they have be declared globally before main? If the second situation is the case, would I be fine just passing the image pointer values in a struct to each thread?
Thanks for the help guys!
edit: For the shared memory issue, If i just declare static image pointers outside of main, then assign them before initiating threads, the threads can then access those pointers, right?