SlideShare una empresa de Scribd logo
1 de 17
OperatingSystemsFirstPracticalAssignment Team OS-Project-EVA Emmanuel Alejandro García Solís - 1450138 Maximiliano Hernández Castillo - 1453557 Adán de Jesús Silva Cuéllar - 1462847 http://os-projecteva.blogspot.com/
Implementation of Locks synch.cc synch.h Lock::Lock(constchar* debugName) {    name = debugName;    semaphore = new Semaphore("lock", 1);    lockHolder = NULL;}Lock::~Lock() {    deletesemaphore;}voidLock::Acquire() {    semaphore->P();    lockHolder = currentThread;} classLock {   public:   Lock(constchar*debugName);   	~Lock(); 	   voidAcquire();    voidRelease();   boolIsHeldByCurrentThread()  booltryAcquire(); private:    constchar* name;		Thread *lockHolder;    	Semaphore *semaphore; };
Implementation of Locks synch.cc synch.h boolLock::IsHeldByCurrentThread(){    returnlockHolder == currentThread;}voidLock::Release() {    ASSERT(IsHeldByCurrentThread());    lockHolder = NULL;    semaphore->V();} boolLock::tryAcquire(){ if(lockHolder == NULL){ semaphore->P(); lockHolder = currentThread; return true;    } else{ return false;     } } classLock {   public:   Lock(constchar*debugName);   	~Lock(); 	   voidAcquire();    voidRelease();   boolIsHeldByCurrentThread()  booltryAcquire(); private:    constchar* name;		Thread *lockHolder;    	Semaphore *semaphore; }; /*AlmostthesamethanAcquire(), exceptthat, ifsomeone has thelock, itwillreturnimmediatelyinstead of waiting*/
Implementation of C. V. synch.cc Condition::Condition(constchar* debugName, Lock* conditionLock){     name = debugName;    waitQueue = new List<Semaphore *>;}voidCondition::Wait(Lock *conditionLock) {    Semaphore *waiter;    ASSERT(conditionLock>IsHeldByCurrentThread());waiter = new Semaphore("condition", 0);    waitQueue->Append(waiter);    conditionLock->Release();    waiter->P();    conditionLock->Acquire();    deletewaiter; } /*Queuecontainingallocated Semaphoresforeachwaitingthread*/ /* Checksifthecurrentthread has thelock. Creates a semaphore, initially 0. Addsthesemaphoretothequeue. Releasesthelock, and goestosleepuntil someonesends a Signal. Whensomeonesends a Signal, reaquiresthe lock  and deletesthesemaphore*/
Implementation of C. V. synch.cc voidCondition::Signal(Lock *conditionLock) {    Semaphore *waiter;    ASSERT(conditionLock->IsHeldByCurrentThread());    if(!waitQueue->IsEmpty()){        waiter = waitQueue->Remove();        waiter->V();    }}voidCondition::Broadcast(Lock *conditionLock) {    while(!waitQueue->IsEmpty()){        Signal(conditionLock);    }} /*Checksifthethecurrentthread has thelock*/ /*Ifit’s true, removesthelastsemaphorefromthe waitqueue, assignsittothewaitersemaphore,  and calls V, towakehim up*/ /* Wake up allthreadswaitingonthiscondition untilthewaitqueueisempty*/
Dining philosophers
Dining philosophers In computer science, the dining philosophers problem is an example problem often used in concurrent algorithm design to illustrate synchronization issues and techniques for resolving them.
Deadlock  Refers to a specific condition when two or more processes are each waiting for the other to release a resource, or more than two processes are waiting for resources in a circular chain.
some possible solutions
By cyclic turn By Several turns. Established several turns. To make it clear, we suppose each philosopher has a token while is eating, when he finishes, he gives his token to the next philosopher at his right.
By Several turns Established several turns. To make it clear, we suppose each philosopher has a token while is eating, when he finishes, he gives his token to the next philosopher at his right.
Gracias porsuatencion :)

Más contenido relacionado

La actualidad más candente

为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?勇浩 赖
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Michael Barker
 
Programação completa e perfeira
Programação completa e perfeiraProgramação completa e perfeira
Programação completa e perfeiraMagno Rodrigues
 
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...Security Session
 
20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会Hiroki Mizuno
 
One definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьOne definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьPlatonov Sergey
 
Ravada VDI Eslibre
Ravada VDI EslibreRavada VDI Eslibre
Ravada VDI Eslibrefrankiejol
 
Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018Stuart Leeks
 
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)jon_bell
 
Promises in JavaScript
Promises in JavaScriptPromises in JavaScript
Promises in JavaScriptRevath S Kumar
 
it's only abuse if it crashes
it's only abuse if it crashesit's only abuse if it crashes
it's only abuse if it crashesEleanor McHugh
 

La actualidad más candente (19)

为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!
 
Debugging TV Frame 0x09
Debugging TV Frame 0x09Debugging TV Frame 0x09
Debugging TV Frame 0x09
 
Programação completa e perfeira
Programação completa e perfeiraProgramação completa e perfeira
Programação completa e perfeira
 
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
 
20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会
 
One definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьOne definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим жить
 
Vcs8
Vcs8Vcs8
Vcs8
 
Ravada VDI Eslibre
Ravada VDI EslibreRavada VDI Eslibre
Ravada VDI Eslibre
 
Crash Fast & Furious
Crash Fast & FuriousCrash Fast & Furious
Crash Fast & Furious
 
gemdiff
gemdiffgemdiff
gemdiff
 
Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018
 
Android taipei 20160225 淺談closure
Android taipei 20160225   淺談closureAndroid taipei 20160225   淺談closure
Android taipei 20160225 淺談closure
 
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
 
EasyMock 101
EasyMock 101EasyMock 101
EasyMock 101
 
Promises in JavaScript
Promises in JavaScriptPromises in JavaScript
Promises in JavaScript
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Michael kontopoulos
Michael kontopoulosMichael kontopoulos
Michael kontopoulos
 
it's only abuse if it crashes
it's only abuse if it crashesit's only abuse if it crashes
it's only abuse if it crashes
 

Destacado

Dining philosopher mutex_2
Dining philosopher mutex_2Dining philosopher mutex_2
Dining philosopher mutex_2Chitu Banchhor
 
dining philosophers problem using montiors
dining philosophers problem using montiorsdining philosophers problem using montiors
dining philosophers problem using montiorsWarda Chaudhry
 
Dining Philosopher's Problem
Dining Philosopher's ProblemDining Philosopher's Problem
Dining Philosopher's ProblemYash Mittal
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OSC.U
 
Lec11 semaphores
Lec11 semaphoresLec11 semaphores
Lec11 semaphoresanandammca
 
Peterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionPeterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionBipul Chandra Kar
 

Destacado (8)

Dining philosopher mutex_2
Dining philosopher mutex_2Dining philosopher mutex_2
Dining philosopher mutex_2
 
DPP
DPPDPP
DPP
 
dining philosophers problem using montiors
dining philosophers problem using montiorsdining philosophers problem using montiors
dining philosophers problem using montiors
 
Dining Philosopher's Problem
Dining Philosopher's ProblemDining Philosopher's Problem
Dining Philosopher's Problem
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
Lec11 semaphores
Lec11 semaphoresLec11 semaphores
Lec11 semaphores
 
Peterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionPeterson Critical Section Problem Solution
Peterson Critical Section Problem Solution
 
Semaphores
SemaphoresSemaphores
Semaphores
 

Similar a Os Practical Assignment 1

Java 5 concurrency
Java 5 concurrencyJava 5 concurrency
Java 5 concurrencypriyank09
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrentRoger Xia
 
Theoretical presentation1nachos
Theoretical presentation1nachosTheoretical presentation1nachos
Theoretical presentation1nachoscolli03
 
Unit Testing: Special Cases
Unit Testing: Special CasesUnit Testing: Special Cases
Unit Testing: Special CasesCiklum Ukraine
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...DroidConTLV
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()Kiwamu Okabe
 
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel ZikmundKarel Zikmund
 
exception handling in cpp
exception handling in cppexception handling in cpp
exception handling in cppgourav kottawar
 
Unit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application developmentUnit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application developmentrohitgudasi18
 
Orsiso
OrsisoOrsiso
Orsisoe27
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerJAX London
 
NDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel ZikmundNDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel ZikmundKarel Zikmund
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
Unit testing CourseSites Apache Filter
Unit testing CourseSites Apache FilterUnit testing CourseSites Apache Filter
Unit testing CourseSites Apache FilterWayan Wira
 
Grand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-CGrand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-CPavel Albitsky
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 

Similar a Os Practical Assignment 1 (20)

Fault tolerance made easy
Fault tolerance made easyFault tolerance made easy
Fault tolerance made easy
 
Java 5 concurrency
Java 5 concurrencyJava 5 concurrency
Java 5 concurrency
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
 
Java Concurrency
Java ConcurrencyJava Concurrency
Java Concurrency
 
Theoretical presentation1nachos
Theoretical presentation1nachosTheoretical presentation1nachos
Theoretical presentation1nachos
 
Unit Testing: Special Cases
Unit Testing: Special CasesUnit Testing: Special Cases
Unit Testing: Special Cases
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 
My java file
My java fileMy java file
My java file
 
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund
 
exception handling in cpp
exception handling in cppexception handling in cpp
exception handling in cpp
 
Unit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application developmentUnit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application development
 
Orsiso
OrsisoOrsiso
Orsiso
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
NDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel ZikmundNDC Sydney 2019 - Async Demystified -- Karel Zikmund
NDC Sydney 2019 - Async Demystified -- Karel Zikmund
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
Unit testing CourseSites Apache Filter
Unit testing CourseSites Apache FilterUnit testing CourseSites Apache Filter
Unit testing CourseSites Apache Filter
 
Grand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-CGrand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-C
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
Server1
Server1Server1
Server1
 

Más de Emmanuel Garcia

Más de Emmanuel Garcia (8)

Reporte Project Puddi - Semana 9
Reporte Project Puddi - Semana 9Reporte Project Puddi - Semana 9
Reporte Project Puddi - Semana 9
 
Reporte Project Puddi - Semana 9
Reporte Project Puddi - Semana 9Reporte Project Puddi - Semana 9
Reporte Project Puddi - Semana 9
 
Puddi Semana 7
Puddi Semana 7Puddi Semana 7
Puddi Semana 7
 
Fase 2
Fase 2Fase 2
Fase 2
 
Avance de proyecto
Avance de proyectoAvance de proyecto
Avance de proyecto
 
Presentación Proyecto POO y TPOO
Presentación Proyecto POO y TPOOPresentación Proyecto POO y TPOO
Presentación Proyecto POO y TPOO
 
Proyecto final
Proyecto finalProyecto final
Proyecto final
 
Algoritmo De Dijkstra
Algoritmo De DijkstraAlgoritmo De Dijkstra
Algoritmo De Dijkstra
 

Último

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Último (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Os Practical Assignment 1

  • 1. OperatingSystemsFirstPracticalAssignment Team OS-Project-EVA Emmanuel Alejandro García Solís - 1450138 Maximiliano Hernández Castillo - 1453557 Adán de Jesús Silva Cuéllar - 1462847 http://os-projecteva.blogspot.com/
  • 2. Implementation of Locks synch.cc synch.h Lock::Lock(constchar* debugName) {    name = debugName;    semaphore = new Semaphore("lock", 1);    lockHolder = NULL;}Lock::~Lock() {    deletesemaphore;}voidLock::Acquire() {    semaphore->P();    lockHolder = currentThread;} classLock { public: Lock(constchar*debugName); ~Lock(); voidAcquire(); voidRelease(); boolIsHeldByCurrentThread() booltryAcquire(); private: constchar* name; Thread *lockHolder; Semaphore *semaphore; };
  • 3. Implementation of Locks synch.cc synch.h boolLock::IsHeldByCurrentThread(){    returnlockHolder == currentThread;}voidLock::Release() {    ASSERT(IsHeldByCurrentThread());    lockHolder = NULL;    semaphore->V();} boolLock::tryAcquire(){ if(lockHolder == NULL){ semaphore->P(); lockHolder = currentThread; return true; } else{ return false; } } classLock { public: Lock(constchar*debugName); ~Lock(); voidAcquire(); voidRelease(); boolIsHeldByCurrentThread() booltryAcquire(); private: constchar* name; Thread *lockHolder; Semaphore *semaphore; }; /*AlmostthesamethanAcquire(), exceptthat, ifsomeone has thelock, itwillreturnimmediatelyinstead of waiting*/
  • 4. Implementation of C. V. synch.cc Condition::Condition(constchar* debugName, Lock* conditionLock){     name = debugName;    waitQueue = new List<Semaphore *>;}voidCondition::Wait(Lock *conditionLock) {    Semaphore *waiter;    ASSERT(conditionLock>IsHeldByCurrentThread());waiter = new Semaphore("condition", 0);    waitQueue->Append(waiter);    conditionLock->Release();    waiter->P();    conditionLock->Acquire();    deletewaiter; } /*Queuecontainingallocated Semaphoresforeachwaitingthread*/ /* Checksifthecurrentthread has thelock. Creates a semaphore, initially 0. Addsthesemaphoretothequeue. Releasesthelock, and goestosleepuntil someonesends a Signal. Whensomeonesends a Signal, reaquiresthe lock and deletesthesemaphore*/
  • 5. Implementation of C. V. synch.cc voidCondition::Signal(Lock *conditionLock) {    Semaphore *waiter;    ASSERT(conditionLock->IsHeldByCurrentThread());    if(!waitQueue->IsEmpty()){        waiter = waitQueue->Remove();        waiter->V();    }}voidCondition::Broadcast(Lock *conditionLock) {    while(!waitQueue->IsEmpty()){        Signal(conditionLock);    }} /*Checksifthethecurrentthread has thelock*/ /*Ifit’s true, removesthelastsemaphorefromthe waitqueue, assignsittothewaitersemaphore, and calls V, towakehim up*/ /* Wake up allthreadswaitingonthiscondition untilthewaitqueueisempty*/
  • 7. Dining philosophers In computer science, the dining philosophers problem is an example problem often used in concurrent algorithm design to illustrate synchronization issues and techniques for resolving them.
  • 8.
  • 9. Deadlock Refers to a specific condition when two or more processes are each waiting for the other to release a resource, or more than two processes are waiting for resources in a circular chain.
  • 10.
  • 12. By cyclic turn By Several turns. Established several turns. To make it clear, we suppose each philosopher has a token while is eating, when he finishes, he gives his token to the next philosopher at his right.
  • 13.
  • 14. By Several turns Established several turns. To make it clear, we suppose each philosopher has a token while is eating, when he finishes, he gives his token to the next philosopher at his right.
  • 15.
  • 16.