![Page 1: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/1.jpg)
Sistemas Distribuidos
Ramiro De Santiago Lopez.
Exclusion Mutua: Memoria Compartida.
28/01/2014
![Page 2: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/2.jpg)
Exclusion Mutua (ME)
● Un proceso excluye temporalmente a todos los demás para usar un recurso compartido.
● Sección Crítica (CS).
![Page 3: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/3.jpg)
Exclusion Mutua (ME)
Algoritmo
ME1. Exclusion Mutua
ME2. Libre de deadlock
ME3. Avance
![Page 4: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/4.jpg)
Memoria Compartida
● Puede ser accedida por múltiples procesos (Pi)
● Comunicacion entre Procesos
Memoria Compartida
P1 P2
P3
P5
P4
![Page 5: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/5.jpg)
Soluciones en el modelo Memoria Soluciones en el modelo Memoria CompartidaCompartida
● El matemático holandés Dekker fue el primero en proponer una solución a la exclusión mutua.
● Operaciones atomicas de escritura-lectura.
● Desarrollo 5 versiones de su algoritmo.
● La versión 5 es la que trabaja más eficientemente, siendo una combinación de la 1 y la 4
![Page 6: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/6.jpg)
Primera Solucion
Algoritmo para dos procesos bandera[0] = false bandera[1] = false
p0: bandera[0] = true p1: bandera[1] = true
while( bandera[1]); while( bandera[0] ); //no hace nada; espera. //no hace nada; espera. // sección crítica // sección crítica // fin de la sección crítica // fin de la sección crítica bandera[0] = false bandera[1] = false
Presencia de interbloqueo.
![Page 7: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/7.jpg)
PETERSON’S ALGORITHM
Preba de no deadlock (ME2) (por contradiccion). (flag[1] turn = 1∧ ) (∧ flag[0] turn = 0∧ ) pero, (turn = 1) (∧ turn = 0) = false
Por lo tanto deadlock es imposible.
![Page 8: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/8.jpg)
PETERSON’S ALGORITHM
Preba de Exclusion Mutua (ME1).Supongamos que p0 esta en la Seccion Critica.P1 tiene que esperar a que p0 termine la seccion critica
![Page 9: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/9.jpg)
PETERSON’S ALGORITHM
Preba de Avance(ME3).Supongamos que p0 esta en la Seccion Critica.p1 esta en espera para entrar en la CS
Eventualmente, p0 saldra de la CS y pondra flag[0] = false dando la oportunidad a p1 de entrar en la CS
![Page 10: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/10.jpg)
EXCLUSION MUTUA USANDO INSTRUCCIONES ESPECIALES
![Page 11: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/11.jpg)
TEST-AND-SET TS(r, x)
● TS(r, x) es una operacion atomica definida como r := x; x := 1;
● Instrucciones de este tipo son conocidas como instrucciones read–modify–write (RMW).
![Page 12: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/12.jpg)
TEST-AND-SET TS(r, x)
● Using TS, the mutual exclusion problem can be solved for N processes (N > 1) as follows.
All TS operations are serialized, the first process that executes the TSinstruction enters its CS
![Page 13: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/13.jpg)
LOAD-LINKED AND STORE-CONDITIONAL
● DEC Alpha introduced the special instructions Load-Linked (LL) and Store-conditional (SC)
● Unlike TS, LL and SC are not atomic RMW operations.
● xx is a shared integer and r is a private integer local to a process
![Page 14: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/14.jpg)
LOAD-LINKED AND STORE-CONDITIONAL
● LL(r, x) is like a machine instruction load (i.e., r := xr := x).
● SC(r, x) is like a machine instruction store (i.e., x := rx := r). If SC succeeds, returning a value 1 into rr, else rr=0;
![Page 15: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/15.jpg)
LOAD-LINKED AND STORE-CONDITIONAL
![Page 16: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/16.jpg)
THE GROUP MUTUAL EXCLUSION PROBLEM
● Instead of trying to enter their individual critical sections, processes opt to join distinct forums.
● In any time at most one forum should be in session.
● Any number of processes should be able to join the forum at a time.
● An example is that of a movie theater.
![Page 17: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/17.jpg)
THE GROUP MUTUAL EXCLUSION PROBLEM
● Is a combination of the classical mutual exclusion problem and the readers and writers problem.
![Page 18: Sistemas Distribuidos - CINVESTAVvjsosa/clases/sd/...Sistemas Distribuidos Ramiro De Santiago Lopez. Exclusion Mutua: Memoria Compartida. 28/01/2014. Exclusion Mutua (ME) ... Presencia](https://reader030.vdocuments.pub/reader030/viewer/2022041105/5f063d597e708231d416fed4/html5/thumbnails/18.jpg)
Referencias● Distributed Systems: An Algorithmic Approach.Sukumar Ghos. Chapman & Hall/CRC, Taylor & Francis Group, LLC (2007).
Ch7.
● Peterson's algorithm. http://en.wikipedia.org/wiki/Peterson's_algorithm.
● EXCLUSION MUTUA. http://www.cs.buap.mx/~mceron/cap4_dis.pdf
● Gestión de Procesos. http://www.infor.uva.es/~fjgonzalez/apuntes_aso/Tema1.pdf.
http://in.unsaac.edu.pe/~ecarrasco/sistOp/presentaciones/Cap05-Concurrencia.pdf .
● Exclusion Mutua. http://www.webprogramacion.com/44/sistemas-operativos/exclusion-mutua.aspx.
● Sistemas Operativos. Esclusion Mutua. http://sistemaoperativo.wikispaces.com/Exclusion+Mutua
● Bloqueo Mutuo. http://es.wikipedia.org/wiki/Bloqueo_mutuo.
● Sistemas Operativos. http://florysel.blogspot.mx/2012/11/243-interbloqueo-deadlock.html.
● Concepts of Concurrent Computation
● Concepts of Concurrent Computation http://se.inf.ethz.ch/courses/2013a_spring/ccc/lectures/03_synchronization_algorithms.pdf .
● Concepts of Concurrent Computation http://cs.uns.edu.ar/~pmd/sosd/downloads/Material%20Adicional/Slides/04-SincronizacionExtras.pdf .
● Test-and-set. http://en.wikipedia.org/wiki/Test-and-set
● Load-link/store-conditional. http://en.wikipedia.org/wiki/Load-link/store-conditional
● Memoria compartida. http://es.wikipedia.org/wiki/Memoria_compartida.