1 / 12

Drinking Philosophers

Drinking Philosophers. Algoritmos Distribuídos Professora: Lúcia Drummond. Drinking Philosophers.

tabib
Télécharger la présentation

Drinking Philosophers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Drinking Philosophers Algoritmos Distribuídos Professora: Lúcia Drummond

  2. Drinking Philosophers Os nós podem acessar diferentes subconjuntos de recursos sempre que eles exigem acesso a recursos compartilhados, então passa a existir a possibilidade de que vizinhos em G acessem recursos compartilhados concorrentemente. A técnica de empregar um único garfo por aresta para assegurar acesso exclusivo aos recursos que dois vizinhos compartilham não é mais suficiente. Instituto de Computação - UFF

  3. Drinking Philosophers Ao invés disso, associado com todas as arestas deve existir um objeto para cada recurso que os correspondentes vizinhos compartilham. Tais objetos são garrafas. Instituto de Computação - UFF

  4. Algoritmo Drinking _Philosophers • Variáveis thirstyi=false; holds_bottlei jk= false para todo nj∈ Neigi e todo bk ∈ Bij; holds_turni j= false para todo nj∈ Neigi; owes_bottlei jk= false para todo nj∈ Neigi e todo bk ∈ Bij; needs_bottlei jk= false para todo nj∈ Neigi e todo bk ∈ Bij; Xi=0; Yi=0; Instituto de Computação - UFF

  5. Algoritmo Drinking _Philosophers • Algoritmo (1)Input: msgi = nil; Ação quando not thirstye necessita-se do acesso ao recurso compartilhado: thirstyi:=true; needs_bottleijk:= true para todo nj ∈ Neigi e todo bk ∈ Bij tal que acesso ao recurso que bk representa é necessário; Instituto de Computação - UFF

  6. Algoritmo Drinking _Philosophers para todo nj∈ Neigi tal que existe bk ∈ Bij com needs_bootleijk=true e holds_bottleijk=false do begin Seja Xi o subconjuntos de Bij tal que bk∈ Xi se e somente se needs_bottleijk=true e holds_bottleijk=false; Envie request(Xi) para todo nj; Xi;=0; end Instituto de Computação - UFF

  7. Algoritmo Drinking _Philosophers • Algoritmo (cont) (2)Input: msgi = request(X) tal que origemi(msgi)=nj; Ação: para todo bk∈ X do if not thirstyi or not holds_turnijor not needs_bottleijkthen begin holds_bottleijk:=false; Xi:=Xi∪ {bk}; if thirstyand needs_bottleijkthen Yi:=Yi∪ {bk}; end Instituto de Computação - UFF

  8. Algoritmo Drinking _Philosophers else owes_bottleijk:=true; if Xi ≠0 then begin if Yi = 0 then Envie bottle(Xi,nil) para nj; else begin Envie bottle(Xi,request(Yi)) para nj; Yi:=0; end Xi:=0; end Instituto de Computação - UFF

  9. Algoritmo Drinking _Philosophers • Algoritmo (cont) (3)Input: msgi = bottle(X,t) tal que origemi(msgi)=nj; Ação: holds_bottleijk:= true para todo bk ∈ X; if t = turnthen holds_turnij:= true; if t = request(Y) then owes_bottleijk:=true para todo bk ∈ Y; if holds_bottleiklpara todonk ∈ Neigi e todo bl ∈ Bikthen Instituto de Computação - UFF

  10. Algoritmo Drinking _Philosophers begin acessa recursos compartilhados; thirstyi:=false; para todo nk ∈ Neigido if holds_turnikthen begin holds_turnik:=false; para todo bl ∈ Bikdo if owes_bottleiklthen begin owes_bottleikl:=false; holds_bottleikl:=false; Xi:=Xi∪ {bl}; end Instituto de Computação - UFF

  11. Algoritmo Drinking _Philosophers if Xi ≠ 0 then begin Envie bottle(Xi,turn) para nk; Xi:=0; end else Envie turn para nk; end end Instituto de Computação - UFF

  12. Algoritmo Drinking _Philosophers • Algoritmo (cont) (4)Input: msgi = turn tal que origemi(msgi)=nj; Ação: holds_turnij:= true; Instituto de Computação - UFF

More Related