Quote (m0hawk @ Feb 28 2014 10:43am)
its actually farily easy once you've understood it properly
Well, I don't know if I understand it fully properly.
I know there is a count variable, I know there are methods to 'wait' and 'signal another semaphore' (using the sembuf struct iirc).
I just gotta figure out how to implement it for my current project.
We have to simulate heat transfer across a rod.
I know I will need an array of n semaphores, each corresponding to a column in the 2d array I use to solve the problem.
Each 'worker' process corresponds to a column. The workers are assigned to solve
ui,j+1, but need to know
ui-1,j && ui,j && ui+1,j in order to solve it (that is, their neighbors values).
(where
i is process ID,
j is a 'unit of time' (your choice of unit) and
ui,j being the temperature at position i at time j of the rod
There is a lot more to it, but I need to become really familiar with the C semaphore stuff.
This post was edited by Eep on Feb 28 2014 01:45pm