SlideShare a Scribd company logo
First Theoretical Presentation Team : Sistemas Soperativos Students: ,[object Object]
Richie
Jose Using: nachOS version 3.4 (c++) . Contents: 1) Algorithm for solving producer consumer problem using locks. 2) Algorithms for testing the locks functionallity.
Producer Consumer with locks. consumer(){ bool hasConsumerLock = false; while(1){ if(!hasConsumerLock){ consumerLock->Acquire(); hasConsumerLock = true; } if(products > 0){ changeProductsState->Acquire(); products--; changeProductsState->Release(); consumerLock->Release() hasConsumerLock = false; } } } producer(){ bool hasProducerLock = false; while(1){ if(!hasProducerLock){ producerLock->Acquire(); hasProducerLock = true; } if(products < maxProducts){ changeProductsState->Acquire(); products--; changeProductsState->Release(); producerLock->Release() hasProducerLock = false; } } } int maxProducts; int products; Lock *consumerLock; Lock *producerLock; Lock *changeProductsState;
Producer producer(){ bool hasProducerLock = false; while(1){ if(!hasProducerLock){ producerLock->Acquire(); hasProducerLock = true; } if(products < maxProducts){ changeProductsState->Acquire(); products++;//producing changeProductsState->Release(); producerLock->Release() hasProducerLock = false; } } }
Consumer consumer(){ bool hasConsumerLock = false; while(1){ if(!hasConsumerLock){ consumerLock->Acquire(); hasConsumerLock = true; } if(products > 0){ changeProductsState->Acquire(); p roducts--; //consuming changeProductsState->Release(); consumerLock->Release() hasConsumerLock = false; } } }

More Related Content

What's hot

Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
Andres Almiray
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing10Pines
 
How to make a large C++-code base manageable
How to make a large C++-code base manageableHow to make a large C++-code base manageable
How to make a large C++-code base manageable
corehard_by
 
Javaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 GroovybuildersJavaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 Groovybuilders
Andres Almiray
 
Teorical 1
Teorical 1Teorical 1
Teorical 1everblut
 
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
LogeekNightUkraine
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
Andres Almiray
 
Theorical 1
Theorical 1Theorical 1
Theorical 1everblut
 
Joel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMDJoel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMD
Sergey Platonov
 
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
PROIDEA
 
C++17 now
C++17 nowC++17 now
C++17 now
corehard_by
 
Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++
corehard_by
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
CanSecWest
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servletsdhrubo kayal
 
openCV with python
openCV with pythonopenCV with python
openCV with python
Wei-Wen Hsu
 

What's hot (19)

Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing
 
How to make a large C++-code base manageable
How to make a large C++-code base manageableHow to make a large C++-code base manageable
How to make a large C++-code base manageable
 
Javaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 GroovybuildersJavaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 Groovybuilders
 
Teorical 1
Teorical 1Teorical 1
Teorical 1
 
Drools Fisl
Drools FislDrools Fisl
Drools Fisl
 
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
 
Theorical 1
Theorical 1Theorical 1
Theorical 1
 
Joel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMDJoel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMD
 
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
 
Unbounded
UnboundedUnbounded
Unbounded
 
Unbounded
UnboundedUnbounded
Unbounded
 
Cs1123 6 loops
Cs1123 6 loopsCs1123 6 loops
Cs1123 6 loops
 
C++17 now
C++17 nowC++17 now
C++17 now
 
Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servlets
 
openCV with python
openCV with pythonopenCV with python
openCV with python
 

Viewers also liked

Comparativesuperlative
ComparativesuperlativeComparativesuperlative
Comparativesuperlative
Sara Flores
 
Mostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovine
Mostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovineMostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovine
Mostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovineLamire
 
Practical presentationnachos
Practical presentationnachosPractical presentationnachos
Practical presentationnachoscolli03
 
Prepositions
PrepositionsPrepositions
Prepositions
Sara Flores
 
To be-present-tense-1
To be-present-tense-1To be-present-tense-1
To be-present-tense-1
Sara Flores
 
Nachos Theoretical assigment 3
Nachos Theoretical assigment 3Nachos Theoretical assigment 3
Nachos Theoretical assigment 3colli03
 
DAILY ROUTINE. TRINITY
DAILY ROUTINE. TRINITYDAILY ROUTINE. TRINITY
DAILY ROUTINE. TRINITY
Sara Flores
 
Table of cardinal numbers
Table of cardinal numbersTable of cardinal numbers
Table of cardinal numbersSara Flores
 
Physical appearance
 Physical appearance Physical appearance
Physical appearance
Sara Flores
 

Viewers also liked (9)

Comparativesuperlative
ComparativesuperlativeComparativesuperlative
Comparativesuperlative
 
Mostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovine
Mostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovineMostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovine
Mostarke u dvije verzije, bosanske studentice i capi iz zapadne hercegovine
 
Practical presentationnachos
Practical presentationnachosPractical presentationnachos
Practical presentationnachos
 
Prepositions
PrepositionsPrepositions
Prepositions
 
To be-present-tense-1
To be-present-tense-1To be-present-tense-1
To be-present-tense-1
 
Nachos Theoretical assigment 3
Nachos Theoretical assigment 3Nachos Theoretical assigment 3
Nachos Theoretical assigment 3
 
DAILY ROUTINE. TRINITY
DAILY ROUTINE. TRINITYDAILY ROUTINE. TRINITY
DAILY ROUTINE. TRINITY
 
Table of cardinal numbers
Table of cardinal numbersTable of cardinal numbers
Table of cardinal numbers
 
Physical appearance
 Physical appearance Physical appearance
Physical appearance
 

Similar to Theoretical presentation1nachos

The uniform interface is 42
The uniform interface is 42The uniform interface is 42
The uniform interface is 42
Yevhen Bobrov
 
Java 5 concurrency
Java 5 concurrencyJava 5 concurrency
Java 5 concurrencypriyank09
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016
Danny Preussler
 
10reasons
10reasons10reasons
10reasonsLi Huan
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
Ying Zhang
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1Emmanuel Garcia
 
Object Oreinted Approach in Coldfusion
Object Oreinted Approach in ColdfusionObject Oreinted Approach in Coldfusion
Object Oreinted Approach in Coldfusion
guestcc9fa5
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
Gowtham Reddy
 
Introduction to Testcontainers
Introduction to TestcontainersIntroduction to Testcontainers
Introduction to Testcontainers
VMware Tanzu
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
Alex Miller
 
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
zznate
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
ciklum_ods
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
Marcus Lagergren
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
Mahmoud Samir Fayed
 
Testing the waters of iOS
Testing the waters of iOSTesting the waters of iOS
Testing the waters of iOS
Kremizas Kostas
 
Writing more complex models
Writing more complex modelsWriting more complex models
Writing more complex models
Mohamed Samy
 
Retrofitting
RetrofittingRetrofitting
Retrofitting
Ted Husted
 

Similar to Theoretical presentation1nachos (20)

The uniform interface is 42
The uniform interface is 42The uniform interface is 42
The uniform interface is 42
 
Java 5 concurrency
Java 5 concurrencyJava 5 concurrency
Java 5 concurrency
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016
 
Java Concurrency
Java ConcurrencyJava Concurrency
Java Concurrency
 
10reasons
10reasons10reasons
10reasons
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
Object Oreinted Approach in Coldfusion
Object Oreinted Approach in ColdfusionObject Oreinted Approach in Coldfusion
Object Oreinted Approach in Coldfusion
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
 
Introduction to Testcontainers
Introduction to TestcontainersIntroduction to Testcontainers
Introduction to Testcontainers
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
 
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Testing the waters of iOS
Testing the waters of iOSTesting the waters of iOS
Testing the waters of iOS
 
Writing more complex models
Writing more complex modelsWriting more complex models
Writing more complex models
 
Retrofitting
RetrofittingRetrofitting
Retrofitting
 

More from colli03

Practical prestantion 1 nachOS
Practical prestantion 1 nachOSPractical prestantion 1 nachOS
Practical prestantion 1 nachOS
colli03
 
Presentación POO
Presentación POOPresentación POO
Presentación POO
colli03
 
Diagramas uml2
Diagramas uml2Diagramas uml2
Diagramas uml2colli03
 
Diagramas uml
Diagramas umlDiagramas uml
Diagramas umlcolli03
 
Actividad 6
Actividad 6Actividad 6
Actividad 6
colli03
 
Proyecto final de POO
Proyecto final de POOProyecto final de POO
Proyecto final de POOcolli03
 
Proyecto final de POO
Proyecto final de POOProyecto final de POO
Proyecto final de POO
colli03
 
Proyecto final de control moderno
Proyecto final de control modernoProyecto final de control moderno
Proyecto final de control moderno
colli03
 
Proyecto final OOP
Proyecto final OOPProyecto final OOP
Proyecto final OOP
colli03
 

More from colli03 (9)

Practical prestantion 1 nachOS
Practical prestantion 1 nachOSPractical prestantion 1 nachOS
Practical prestantion 1 nachOS
 
Presentación POO
Presentación POOPresentación POO
Presentación POO
 
Diagramas uml2
Diagramas uml2Diagramas uml2
Diagramas uml2
 
Diagramas uml
Diagramas umlDiagramas uml
Diagramas uml
 
Actividad 6
Actividad 6Actividad 6
Actividad 6
 
Proyecto final de POO
Proyecto final de POOProyecto final de POO
Proyecto final de POO
 
Proyecto final de POO
Proyecto final de POOProyecto final de POO
Proyecto final de POO
 
Proyecto final de control moderno
Proyecto final de control modernoProyecto final de control moderno
Proyecto final de control moderno
 
Proyecto final OOP
Proyecto final OOPProyecto final OOP
Proyecto final OOP
 

Recently uploaded

Building Your Employer Brand with Social Media
Building Your Employer Brand with Social MediaBuilding Your Employer Brand with Social Media
Building Your Employer Brand with Social Media
LuanWise
 
In the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptxIn the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptx
Adani case
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
Operational Excellence Consulting
 
An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.
Any kyc Account
 
Buy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star ReviewsBuy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star Reviews
usawebmarket
 
Search Disrupted Google’s Leaked Documents Rock the SEO World.pdf
Search Disrupted Google’s Leaked Documents Rock the SEO World.pdfSearch Disrupted Google’s Leaked Documents Rock the SEO World.pdf
Search Disrupted Google’s Leaked Documents Rock the SEO World.pdf
Arihant Webtech Pvt. Ltd
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdfBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
daothibichhang1
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
Aurelien Domont, MBA
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
Lviv Startup Club
 
Training my puppy and implementation in this story
Training my puppy and implementation in this storyTraining my puppy and implementation in this story
Training my puppy and implementation in this story
WilliamRodrigues148
 
The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...
balatucanapplelovely
 
Project File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdfProject File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdf
RajPriye
 
Recruiting in the Digital Age: A Social Media Masterclass
Recruiting in the Digital Age: A Social Media MasterclassRecruiting in the Digital Age: A Social Media Masterclass
Recruiting in the Digital Age: A Social Media Masterclass
LuanWise
 
Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431
ecamare2
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
uae taxgpt
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Holger Mueller
 
Brand Analysis for an artist named Struan
Brand Analysis for an artist named StruanBrand Analysis for an artist named Struan
Brand Analysis for an artist named Struan
sarahvanessa51503
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
SynapseIndia
 
The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...
Adam Smith
 
Authentically Social Presented by Corey Perlman
Authentically Social Presented by Corey PerlmanAuthentically Social Presented by Corey Perlman
Authentically Social Presented by Corey Perlman
Corey Perlman, Social Media Speaker and Consultant
 

Recently uploaded (20)

Building Your Employer Brand with Social Media
Building Your Employer Brand with Social MediaBuilding Your Employer Brand with Social Media
Building Your Employer Brand with Social Media
 
In the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptxIn the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptx
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
 
An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.
 
Buy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star ReviewsBuy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star Reviews
 
Search Disrupted Google’s Leaked Documents Rock the SEO World.pdf
Search Disrupted Google’s Leaked Documents Rock the SEO World.pdfSearch Disrupted Google’s Leaked Documents Rock the SEO World.pdf
Search Disrupted Google’s Leaked Documents Rock the SEO World.pdf
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdfBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
 
Training my puppy and implementation in this story
Training my puppy and implementation in this storyTraining my puppy and implementation in this story
Training my puppy and implementation in this story
 
The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...
 
Project File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdfProject File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdf
 
Recruiting in the Digital Age: A Social Media Masterclass
Recruiting in the Digital Age: A Social Media MasterclassRecruiting in the Digital Age: A Social Media Masterclass
Recruiting in the Digital Age: A Social Media Masterclass
 
Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
 
Brand Analysis for an artist named Struan
Brand Analysis for an artist named StruanBrand Analysis for an artist named Struan
Brand Analysis for an artist named Struan
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
 
The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...
 
Authentically Social Presented by Corey Perlman
Authentically Social Presented by Corey PerlmanAuthentically Social Presented by Corey Perlman
Authentically Social Presented by Corey Perlman
 

Theoretical presentation1nachos

  • 1.
  • 3. Jose Using: nachOS version 3.4 (c++) . Contents: 1) Algorithm for solving producer consumer problem using locks. 2) Algorithms for testing the locks functionallity.
  • 4. Producer Consumer with locks. consumer(){ bool hasConsumerLock = false; while(1){ if(!hasConsumerLock){ consumerLock->Acquire(); hasConsumerLock = true; } if(products > 0){ changeProductsState->Acquire(); products--; changeProductsState->Release(); consumerLock->Release() hasConsumerLock = false; } } } producer(){ bool hasProducerLock = false; while(1){ if(!hasProducerLock){ producerLock->Acquire(); hasProducerLock = true; } if(products < maxProducts){ changeProductsState->Acquire(); products--; changeProductsState->Release(); producerLock->Release() hasProducerLock = false; } } } int maxProducts; int products; Lock *consumerLock; Lock *producerLock; Lock *changeProductsState;
  • 5. Producer producer(){ bool hasProducerLock = false; while(1){ if(!hasProducerLock){ producerLock->Acquire(); hasProducerLock = true; } if(products < maxProducts){ changeProductsState->Acquire(); products++;//producing changeProductsState->Release(); producerLock->Release() hasProducerLock = false; } } }
  • 6. Consumer consumer(){ bool hasConsumerLock = false; while(1){ if(!hasConsumerLock){ consumerLock->Acquire(); hasConsumerLock = true; } if(products > 0){ changeProductsState->Acquire(); p roducts--; //consuming changeProductsState->Release(); consumerLock->Release() hasConsumerLock = false; } } }
  • 7.
  • 8. Safety Here the code produce a deadlock on porpuse to show that two locks can not have access to the same lock at the same time. Lock *l2; Lock *l3; Rutine1(){ while(1){ l2->Acquire(); l3->Acquire(); #some critical computation goes here l3->Release(); l2->Release(); } } Rutine2(){ while(1){ l3->Acquire(); l2->Acquire(); #some critical computation goes here l2->Release(); l3->Release() ; } }