Saturday 26 May 2018

what is Multiple Process Solution (Baker's Solution) in Operating System

what is Multiple Process Solution (Baker's Solution) in Operating System:

Baker's solution algorithm can solve multiple process solution. it is used for two or more process solution. it is also called multiple process algorithm or Banker's Solution.

1. Peterson solution solves the Critical section Problem for 2 process.
2. we have a multi processor solution called Baker's solution, based on Bakery stores.
3. The basic idea i s that on entering in bakery customer takes a token.
4. However have a least token number service next.
5. Here service means customer enter in critical section.

int token [n];
token [0]= given to process 0
token[1]=given to process 1
.              .
.              .
.              .
.              .
token [n-1]= given to process n-1


suppose there are 5 process P0, P1, P2, P3, P4 and their arrival order 
P0, P3, P4, P2, P1

token=max(P0, P1, P2, P3, P4 )+ 1

initially all process are assigned to 0 

for process P0:
 P0 have the token No. =max(P0, P1, P2,  P3, P4 ) +1
P0= max ( 0, 0, 0, 0, 0 ) +1

for Process P3:

P3=max(P0, P1, P2, P3, P4 )+1
    = max( 1,0,0,0,0 ) +1
P3= 1 +1

for Process P4:

P4=max( 1, 0,0,0 2) +1

note: here allway select maximum value so,

P4= 2 +1

for Process p2:
P2=max(1,0,0,2,3) +1
P2= 3+1

for process P1:

P1=max( P0, P1, P2, P3, P4)+1

=max( 1,0,4,2,3)+1

P1=4+ 1
P1=5                                                                             {Ans}

No comments:

Post a Comment

Popular Posts