SlideShare a Scribd company logo
Operating systems

      Carmen Suárez
       Abraham Silva
         Gaby García
Problem unbounded-bufer (producer-
                consumer)
Producer and Consumer share a common buffer
But not everything is happiness and perfection...
The producer tries to get to the buffer and add
elements but it’s already full
The consumer tries to get to the buffer but it’s
empty
When the producer and the consumer go to sleep, and don't
receive calls from anyone. A deadlock occurs




           Producer                  Consumer
The solution to this problem is:

The use of semaphores or locks. A semaphore will regulate
the production and the consuming of the buffer, giving
access to only one process at a time.




                                  http://bit.ly/rlGtNe
Pseudocode

define N 100
typedef int semaphore;
semaphore mutex = 1;           void consumer(void){
semaphore empaty = N;          int element:
semaphore full = 0;            while(true){
void producer(void){           down(full);
int element;                   down(mutex);
while(true){                   element=down_element();
element = produce_element();
down(empaty);
                               up(mutex);
down(full);                    up(empaty);
insert_element(element);       consum_element(element)-,
up(mutex);                     }
up(full);
}                              }
}
http://bit.ly/rlGtNe
Dining Philosophers
First
                "possible" solution
#define N 5
void filosofo(int i)
{
while(TRUE){
•   think
•   take left fork
•   take right fork
•   eat
•   leave left fork
•   leave right fork
}
}
Deadlock

•   All of the philosophers are holding a fork
    while waiting for other fork to be released.
•   There are no forks available anymore.
•   They can’t eat because they need two forks.
•   Starvation
Eliminate deadlocks


•   TryAcquire
•   Release all the locks, wait and then
    reacquire them in the right order
•   Order the locks: Establish a time for locks
Solution
Suspension algorithms

There are three components of the time used in a process:

•   Spinning: It’s the time the thread takes to check whether
    the lock is available or not. During this time the process is
    not executing.
•   Suspending: Is the amount of time the thread is
    suspended or sleeping, waiting for the lock to be available
•   Resuming: Is the amount of time the thread takes to
    restart the execution after acquiring the lock.
Optimal algorithm

•   The lock is released in less than the suspend and resume
    time, the process spins until it acquires the lock.
Optimal Algorithm


•   The lock is released in more than the suspend and resume
    time, the process should suspend immediately.
Other worse algorithm than SR

•   if it spins for more than suspend and resume time, then suspend. The
    worst case is when lock is free after a thread start the suspension. The
    SR algorithm will cost the suspend and resume time but will spin less time
    than this algorithm.
Bibliography


•   Martin Rinard OS Notes http://people.csail.mit.edu/rinard/osnotes/
•   Sistemas Operativos Modernos, Andrew S. Tanenbaum, 3rd Ed,
    Prentice Hall.
•   Dining philosophers image
HTTP://UPLOAD.WIKIMEDIA.ORG/WIKIPEDIA/COMMONS/THUMB/6/6A/DINING_ PHIL
            OSOPHERS.PNG/200PX-DINING_PHILOSOPHERS.PNG
•   Deadlock image
    http://www.cs.rpi.edu/academics/courses/fall04/os/c10/deadlock2.gif
Gracias por su atencion 

Blog:
        http://os-sistemasoperativos.blogspot.com

More Related Content

Viewers also liked

Linear programming graphical method (feasibility)
Linear programming   graphical method (feasibility)Linear programming   graphical method (feasibility)
Linear programming graphical method (feasibility)
Rajesh Timane, PhD
 
Producer consumer
Producer consumerProducer consumer
Producer consumer
Mohd Tousif
 
Operation Research (Simplex Method)
Operation Research (Simplex Method)Operation Research (Simplex Method)
Operation Research (Simplex Method)
Shivani Gautam
 
Application Layer
Application Layer Application Layer
Application Layer
Dr Shashikant Athawale
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationWayne Jones Jnr
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OSC.U
 
Linear programing
Linear programingLinear programing
Linear programing
Aniruddh Tiwari
 
SlideShare 101
SlideShare 101SlideShare 101
SlideShare 101
Amit Ranjan
 

Viewers also liked (9)

Linear programming graphical method (feasibility)
Linear programming   graphical method (feasibility)Linear programming   graphical method (feasibility)
Linear programming graphical method (feasibility)
 
Producer consumer
Producer consumerProducer consumer
Producer consumer
 
Operation Research (Simplex Method)
Operation Research (Simplex Method)Operation Research (Simplex Method)
Operation Research (Simplex Method)
 
Application Layer
Application Layer Application Layer
Application Layer
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
Linear programing
Linear programingLinear programing
Linear programing
 
SlideShare 101
SlideShare 101SlideShare 101
SlideShare 101
 

Similar to Operating systems

UNIT III Process Synchronization.docx
UNIT III Process Synchronization.docxUNIT III Process Synchronization.docx
UNIT III Process Synchronization.docx
karthikaparthasarath
 
Synchronization problem with threads
Synchronization problem with threadsSynchronization problem with threads
Synchronization problem with threads
Syed Zaid Irshad
 
Deadlock _Classic problems.pptx
Deadlock _Classic problems.pptxDeadlock _Classic problems.pptx
Deadlock _Classic problems.pptx
GopikaS12
 
12 deadlock concept
12 deadlock concept12 deadlock concept
12 deadlock concept
DeepaMaria10489
 
Sync, async and multithreading
Sync, async and multithreadingSync, async and multithreading
Sync, async and multithreading
Tuan Chau
 
Storm Real Time Computation
Storm Real Time ComputationStorm Real Time Computation
Storm Real Time Computation
Sonal Raj
 
Process Synchronization -1.ppt
Process Synchronization -1.pptProcess Synchronization -1.ppt
Process Synchronization -1.ppt
jayverma27
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
AhmedKhairulAmin
 
Sumatra and git
Sumatra and gitSumatra and git
Sumatra and git
Michele Mattioni
 
7308346-Deadlock.pptx
7308346-Deadlock.pptx7308346-Deadlock.pptx
7308346-Deadlock.pptx
sheraz7288
 
Full solution to bounded buffer
Full solution to bounded bufferFull solution to bounded buffer
Full solution to bounded buffer
Syed Zaid Irshad
 
Process cooperation and synchronisation
Process cooperation and synchronisation Process cooperation and synchronisation
Process cooperation and synchronisation
JayeshGadhave1
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
madhuributani
 
Deadlock Slides
Deadlock SlidesDeadlock Slides
Deadlock Slides
sehrishishaq1
 
multithreading.pptx
multithreading.pptxmultithreading.pptx
multithreading.pptx
Sravanibitragunta
 
Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010
敬倫 林
 
Slot03 concurrency2
Slot03 concurrency2Slot03 concurrency2
Slot03 concurrency2
Viên Mai
 

Similar to Operating systems (20)

UNIT III Process Synchronization.docx
UNIT III Process Synchronization.docxUNIT III Process Synchronization.docx
UNIT III Process Synchronization.docx
 
Synchronization problem with threads
Synchronization problem with threadsSynchronization problem with threads
Synchronization problem with threads
 
Deadlock _Classic problems.pptx
Deadlock _Classic problems.pptxDeadlock _Classic problems.pptx
Deadlock _Classic problems.pptx
 
12 deadlock concept
12 deadlock concept12 deadlock concept
12 deadlock concept
 
Sync, async and multithreading
Sync, async and multithreadingSync, async and multithreading
Sync, async and multithreading
 
Storm Real Time Computation
Storm Real Time ComputationStorm Real Time Computation
Storm Real Time Computation
 
Process Synchronization -1.ppt
Process Synchronization -1.pptProcess Synchronization -1.ppt
Process Synchronization -1.ppt
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
 
Sumatra and git
Sumatra and gitSumatra and git
Sumatra and git
 
7308346-Deadlock.pptx
7308346-Deadlock.pptx7308346-Deadlock.pptx
7308346-Deadlock.pptx
 
Full solution to bounded buffer
Full solution to bounded bufferFull solution to bounded buffer
Full solution to bounded buffer
 
Process cooperation and synchronisation
Process cooperation and synchronisation Process cooperation and synchronisation
Process cooperation and synchronisation
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
22 multi threading iv
22 multi threading iv22 multi threading iv
22 multi threading iv
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
 
Deadlock Slides
Deadlock SlidesDeadlock Slides
Deadlock Slides
 
multithreading.pptx
multithreading.pptxmultithreading.pptx
multithreading.pptx
 
Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010
 
Slot03 concurrency2
Slot03 concurrency2Slot03 concurrency2
Slot03 concurrency2
 
Unbounded
UnboundedUnbounded
Unbounded
 

More from Abraham

Operating systems
Operating systemsOperating systems
Operating systemsAbraham
 
Presentacion Final Organigrama
Presentacion Final OrganigramaPresentacion Final Organigrama
Presentacion Final OrganigramaAbraham
 
Proyecto Organigrama
Proyecto OrganigramaProyecto Organigrama
Proyecto Organigrama
Abraham
 
Deteccion de Ciclos en c
Deteccion de Ciclos en cDeteccion de Ciclos en c
Deteccion de Ciclos en cAbraham
 
Deteccion de Ciclos
Deteccion de CiclosDeteccion de Ciclos
Deteccion de CiclosAbraham
 
Deteccion de Ciclos
Deteccion de CiclosDeteccion de Ciclos
Deteccion de CiclosAbraham
 
Derivada Polinomios en C
Derivada Polinomios en CDerivada Polinomios en C
Derivada Polinomios en CAbraham
 
Serie Fibonacci en C
Serie Fibonacci en CSerie Fibonacci en C
Serie Fibonacci en CAbraham
 
Tipos de Ordenamiento en C
Tipos de Ordenamiento en CTipos de Ordenamiento en C
Tipos de Ordenamiento en CAbraham
 
Herramientas para programar en C
Herramientas para programar en CHerramientas para programar en C
Herramientas para programar en C
Abraham
 
Algoritmo de prim
Algoritmo de primAlgoritmo de prim
Algoritmo de prim
Abraham
 
Algoritmo prim
Algoritmo primAlgoritmo prim
Algoritmo primAbraham
 

More from Abraham (12)

Operating systems
Operating systemsOperating systems
Operating systems
 
Presentacion Final Organigrama
Presentacion Final OrganigramaPresentacion Final Organigrama
Presentacion Final Organigrama
 
Proyecto Organigrama
Proyecto OrganigramaProyecto Organigrama
Proyecto Organigrama
 
Deteccion de Ciclos en c
Deteccion de Ciclos en cDeteccion de Ciclos en c
Deteccion de Ciclos en c
 
Deteccion de Ciclos
Deteccion de CiclosDeteccion de Ciclos
Deteccion de Ciclos
 
Deteccion de Ciclos
Deteccion de CiclosDeteccion de Ciclos
Deteccion de Ciclos
 
Derivada Polinomios en C
Derivada Polinomios en CDerivada Polinomios en C
Derivada Polinomios en C
 
Serie Fibonacci en C
Serie Fibonacci en CSerie Fibonacci en C
Serie Fibonacci en C
 
Tipos de Ordenamiento en C
Tipos de Ordenamiento en CTipos de Ordenamiento en C
Tipos de Ordenamiento en C
 
Herramientas para programar en C
Herramientas para programar en CHerramientas para programar en C
Herramientas para programar en C
 
Algoritmo de prim
Algoritmo de primAlgoritmo de prim
Algoritmo de prim
 
Algoritmo prim
Algoritmo primAlgoritmo prim
Algoritmo prim
 

Recently uploaded

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 

Recently uploaded (20)

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 

Operating systems

  • 1. Operating systems Carmen Suárez Abraham Silva Gaby García
  • 2. Problem unbounded-bufer (producer- consumer) Producer and Consumer share a common buffer But not everything is happiness and perfection...
  • 3. The producer tries to get to the buffer and add elements but it’s already full
  • 4. The consumer tries to get to the buffer but it’s empty
  • 5. When the producer and the consumer go to sleep, and don't receive calls from anyone. A deadlock occurs Producer Consumer
  • 6. The solution to this problem is: The use of semaphores or locks. A semaphore will regulate the production and the consuming of the buffer, giving access to only one process at a time. http://bit.ly/rlGtNe
  • 7. Pseudocode define N 100 typedef int semaphore; semaphore mutex = 1; void consumer(void){ semaphore empaty = N; int element: semaphore full = 0; while(true){ void producer(void){ down(full); int element; down(mutex); while(true){ element=down_element(); element = produce_element(); down(empaty); up(mutex); down(full); up(empaty); insert_element(element); consum_element(element)-, up(mutex); } up(full); } } }
  • 10. First "possible" solution #define N 5 void filosofo(int i) { while(TRUE){ • think • take left fork • take right fork • eat • leave left fork • leave right fork } }
  • 11. Deadlock • All of the philosophers are holding a fork while waiting for other fork to be released. • There are no forks available anymore. • They can’t eat because they need two forks. • Starvation
  • 12. Eliminate deadlocks • TryAcquire • Release all the locks, wait and then reacquire them in the right order • Order the locks: Establish a time for locks
  • 14. Suspension algorithms There are three components of the time used in a process: • Spinning: It’s the time the thread takes to check whether the lock is available or not. During this time the process is not executing. • Suspending: Is the amount of time the thread is suspended or sleeping, waiting for the lock to be available • Resuming: Is the amount of time the thread takes to restart the execution after acquiring the lock.
  • 15. Optimal algorithm • The lock is released in less than the suspend and resume time, the process spins until it acquires the lock.
  • 16. Optimal Algorithm • The lock is released in more than the suspend and resume time, the process should suspend immediately.
  • 17. Other worse algorithm than SR • if it spins for more than suspend and resume time, then suspend. The worst case is when lock is free after a thread start the suspension. The SR algorithm will cost the suspend and resume time but will spin less time than this algorithm.
  • 18. Bibliography • Martin Rinard OS Notes http://people.csail.mit.edu/rinard/osnotes/ • Sistemas Operativos Modernos, Andrew S. Tanenbaum, 3rd Ed, Prentice Hall. • Dining philosophers image HTTP://UPLOAD.WIKIMEDIA.ORG/WIKIPEDIA/COMMONS/THUMB/6/6A/DINING_ PHIL OSOPHERS.PNG/200PX-DINING_PHILOSOPHERS.PNG • Deadlock image http://www.cs.rpi.edu/academics/courses/fall04/os/c10/deadlock2.gif
  • 19. Gracias por su atencion  Blog: http://os-sistemasoperativos.blogspot.com