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

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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - 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
 
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
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 

Último (20)

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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - 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
 
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
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 

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.