SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Similaire à 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
 

Similaire à 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...
 

Plus 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
 

Plus 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
 

Dernier

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer 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
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer 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
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

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