Embed presentation
Download to read offline

























![Solution??■ Each philosopher is a process.■ One semaphore per fork:■ forks: array[0..4] of semaphores■ Initialization: forks[i].count:=1 for i:=0..4Process Pi:repeatthink;wait(forks[i]);wait(forks[(i+1)%5]);eat;signal(forks[(i+1)%5]);signal(forks[i]);forever• Deadlock if each philosopher starts by picking left fork!Concurrenty (15)3636](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fcs34515-ch06concurrency2-241015104805-8377fdf9%2f75%2fCSE34115-1115-Ch-06-Concurrency-2-pptx-26-2048.jpg&f=jpg&w=240)
![Another Solution■ A solution: admit only 4philosophers at a time thattries to eat■ Then 1 philosopher canalways eat when the other 3are holding 1 fork■ Introduce semaphore T thatlimits to 4 the number ofphilosophers “sitting at thetable”■ Initialize: T.count:=4Process Pi:repeatthink;wait(T);wait(forks[i]);wait(forks[(i+1)%5]);eat;signal(forks[(i+1)%5]);signal(forks[i]);signal(T);foreverConcurrenty (15)3737](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fcs34515-ch06concurrency2-241015104805-8377fdf9%2f75%2fCSE34115-1115-Ch-06-Concurrency-2-pptx-27-2048.jpg&f=jpg&w=240)


El capítulo 6 del curso de sistemas operativos se centra en la concurrencia y el manejo de interbloqueos, describiendo las condiciones necesarias para que sucedan y las estrategias para prevenir, evitar, detectar o ignorar estos problemas. Se presentan conceptos como el algoritmo del banquero para la asignación segura de recursos y el ejemplo de los filósofos comensales para ilustrar el manejo de recursos compartidos. La gestión de interbloqueos se considera esencial para mantener la eficiencia y la estabilidad del sistema.

























![Solution??■ Each philosopher is a process.■ One semaphore per fork:■ forks: array[0..4] of semaphores■ Initialization: forks[i].count:=1 for i:=0..4Process Pi:repeatthink;wait(forks[i]);wait(forks[(i+1)%5]);eat;signal(forks[(i+1)%5]);signal(forks[i]);forever• Deadlock if each philosopher starts by picking left fork!Concurrenty (15)3636](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fcs34515-ch06concurrency2-241015104805-8377fdf9%2f75%2fCSE34115-1115-Ch-06-Concurrency-2-pptx-26-2048.jpg&f=jpg&w=240)
![Another Solution■ A solution: admit only 4philosophers at a time thattries to eat■ Then 1 philosopher canalways eat when the other 3are holding 1 fork■ Introduce semaphore T thatlimits to 4 the number ofphilosophers “sitting at thetable”■ Initialize: T.count:=4Process Pi:repeatthink;wait(T);wait(forks[i]);wait(forks[(i+1)%5]);eat;signal(forks[(i+1)%5]);signal(forks[i]);signal(T);foreverConcurrenty (15)3737](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fcs34515-ch06concurrency2-241015104805-8377fdf9%2f75%2fCSE34115-1115-Ch-06-Concurrency-2-pptx-27-2048.jpg&f=jpg&w=240)

