SlideShare una empresa de Scribd logo
1 de 19
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

Más contenido relacionado

Similar a Operating systems

Process Synchronization -1.ppt
Process Synchronization -1.pptProcess Synchronization -1.ppt
Process Synchronization -1.pptjayverma27
 
7308346-Deadlock.pptx
7308346-Deadlock.pptx7308346-Deadlock.pptx
7308346-Deadlock.pptxsheraz7288
 
Full solution to bounded buffer
Full solution to bounded bufferFull solution to bounded buffer
Full solution to bounded bufferSyed 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 JAVAVINOTH R
 
Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010敬倫 林
 
Slot03 concurrency2
Slot03 concurrency2Slot03 concurrency2
Slot03 concurrency2Viên Mai
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Feihong Hsu
 
Lecture 5 process synchronization
Lecture 5 process synchronizationLecture 5 process synchronization
Lecture 5 process synchronizationKlintonChhun
 
Reflex - How Does It Work? (extended dance remix)
Reflex - How Does It Work? (extended dance remix)Reflex - How Does It Work? (extended dance remix)
Reflex - How Does It Work? (extended dance remix)Rocco Caputo
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Sachintha Gunasena
 

Similar a Operating systems (20)

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
 
Unbounded
UnboundedUnbounded
Unbounded
 
Java threading
Java threadingJava threading
Java threading
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3
 
Lecture 5 process synchronization
Lecture 5 process synchronizationLecture 5 process synchronization
Lecture 5 process synchronization
 
Reflex - How Does It Work? (extended dance remix)
Reflex - How Does It Work? (extended dance remix)Reflex - How Does It Work? (extended dance remix)
Reflex - How Does It Work? (extended dance remix)
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
 

Más de Abraham

Operating systems
Operating systemsOperating systems
Operating systemsAbraham
 
Presentacion Final Organigrama
Presentacion Final OrganigramaPresentacion Final Organigrama
Presentacion Final OrganigramaAbraham
 
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 CAbraham
 
Algoritmo de prim
Algoritmo de primAlgoritmo de prim
Algoritmo de primAbraham
 
Algoritmo prim
Algoritmo primAlgoritmo prim
Algoritmo primAbraham
 

Más de Abraham (11)

Operating systems
Operating systemsOperating systems
Operating systems
 
Presentacion Final Organigrama
Presentacion Final OrganigramaPresentacion Final Organigrama
Presentacion Final 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
 

Último

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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