I am learning parallel processing and I am doing a parallel program using
fork(). My problem is as stated below...


                        __      __      __      __      __
Initial:  3 0 5 1 2->  |__| -> |__| -> |__| -> |__| -> |__|


                        2
                        __      __      __      __      __      
Step 1 :    3 0 5 1->  |__| -> |__| -> |__| -> |__| -> |__|


                        1    2
                        __      __      __      __      __      
Step 2 :      3 0 5->  |__| -> |__| -> |__| -> |__| -> |__|     

                                        
                        1    5  2
                        __      __      __      __      __
Step 3 :        3 0->  |__| -> |__| -> |__| -> |__| -> |__|


                        0    1  2    5                  
                        __      __      __      __      __
Step 4 :          3    |__| -> |__| -> |__| -> |__| -> |__|

  :
  :
  :                     0       1       2       3       5
                        __      __      __      __      __      
Step 9 :               |__| -> |__| -> |__| -> |__| -> |__|
                        A       B       C       D       E

Each box in the above diagram represent a process which is a child
process, ie: B is child for A, C is child for B , D is child for C and E
is child for D.

The program should be able to do sorting of the input which in this case
is 3 0 5 1 2. And the sorting should be done parallely. For example , once
the program get input it should pass the first integer to the A 
and while the A receive the second input it should sort it out. if
the second input bigger than the first input then it should pass it to B
( child to A) and keep the smaller value in A . When the A
process the third value it need to sort it out again and pass the bigger
value to B and sorting process takes place in B and the bigger value will
be pass to C. The same process going on until all the numbers sorted.
The number of process is fixed. In this case is five...

Can anyone guide me???


Thanks in advance...
 

Regards
S.Balan                                                             

Reply via email to