Solutions of a Problem in Concurrent Programming - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Solutions of a Problem in Concurrent Programming

Description:

Basic Goals of Dijkstra's Solution. Symmetric between N computers ... Dijkstra's Solution ... Problems in Dijkstra's Solution ... – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 15
Provided by: YL9
Category:

less

Transcript and Presenter's Notes

Title: Solutions of a Problem in Concurrent Programming


1
Solutions of a Problem in Concurrent Programming
  • Proseminar Software Pioneers
  • By Prof. Dr. Heike Wehrheim
  • Diplo. Inform. Björn Metzler

2
Contents
  • A brief introduction of Dijkstra and Lamport
  • Problem in Concurrent Programming
  • Dijkstras Solution
  • Semaphores Solution
  • Lamports Solution
  • Conclusion

3
Edsger W. Dijkstra and Leslie Lamport
  • Photographs are from google photo

4
Problem in Concurrent Programming
  • N computers
  • one critical section.
  • Two requirements
  • Communication between computers
  • Undividable writing or reading

5
Basic Goals of Dijkstras Solution
  • Symmetric between N computers
  • No After you After you blocking

6
Dijkstras Solution
Part I Interger j Li0bifalse Li1if
k?i then Li2 begin citrue Li3
if bk then ki goto Li1
end else . .
Critical Section
1
2
3
N
i
  • Code from Solution of a Problem in Concurrent
    Programming Control E.W.Dijkstra

7
Dijkstras Solution
Part II Li4begin cifalse for
j1 step 1 until N do if j?i and
not cj then goto Li1 end critical
section citruebitrue . . go
to Li0
Critical Section
i
1
2
3
N
Code from Solution of a Problem in Concurrent
Programming Control E.W.Dijkstra
8
Problems in Dijkstras Solution
  • When the i-th computer breaks down in the
    critical section, the whole system will be in a
    dead lock

Critical Section
????
i
Hey, we have waited too long!
1
2
3
N
What is he doing for such a long time?
Who knows. Just have to wait here.
9
Semaphores Solution
  • Semaphore values
  • Two indivisible actions
  • P- operation
  • V- operation
  • Random choosing from the waiting list

begin semaphore mutex mutex 1 parbegin
begin L1 P(mutex) critcal
section 1 V(mutex)
remainder of cycle 1
go to L1 end
begin L2 P(mutex)
critical section 2
V(mutex) remainder of
cycle 2 go to L2
end parendend end
10
Problems of Semaphores Solution
  • We can no forecast or decide which process will
    be removed from the waiting list.
  • Explicit control - deadlock

11
Lamports Solution
  • Begin integer j
  • L1 choosingi1
  • numberi1maximum(number1,...numberN)
  • choosingi0
  • for j1 step 1 until N do
  • begin
  • L2 if choosingj?0 then goto L2
  • L3 if numberj?0 and (numberj,j)lt
    (numberi,i) then goto L3
  • end
  • Critical section
  • Numberi0
  • Noncritical section
  • Goto L1
  • end

Critical Section
1
2
3
N
i
12
Lamports Solution
  • Begin integer j
  • L1 choosingi1
  • numberi1maximum(number1,...numberN)
  • choosingi0
  • for j1 step 1 until N do
  • begin
  • L2 if choosingj?0 then goto L2
  • L3 if numberj?0 and (numberj,j)lt
    (numberi,i) then goto L3
  • end
  • Critical section
  • Numberi0
  • Noncritical section
  • Goto L1
  • end

Critical Section
i
1
2
3
N
13
Problems in Lamports Solution
  • These computers are no longer symmetrical.
  • The number attribute will be too big.

14
Conclusion
  • Dijkstras Solution
  • N computers get equal chances, and avoid after
    you after you blocking.
  • Weak point Once one computer breaks down inside
    the CS, that will be a catastrophe.
  • Semaphores Solution
  • Based on a semaphore value with two undividable
    action P and V.
  • Weak point Too reliance upon a single hardware
    component.
  • Lamports Solution
  • Every computer got its own attribute and dont
    afraid break-down in CS.
  • This attribute will be too huge and increase the
    systems load.
Write a Comment
User Comments (0)
About PowerShow.com