2. Develop a solution for the Dining Philosopher's problem using AND-Synchronization (i.e. Parallel Semaphores SP and SV)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

WHats the pseduo code in c++/python for number 2? 

1. Imagine a very long bridge across the Mississippi River. A car will take upwards of 15 minutes to cross this bridge. Due to construction, the bridge
has been reduced to a single lane that has to be shared by traffic in both directions. It is obviously not possible to allow traffic in both directions
simultaneously, and so a special traffic control mechanism is installed with the following rules:
• An arriving car will have to wait if the bridge is currently occupied by one or more cars moving in the opposite direction.
Multiple cars are allowed to cross the bridge in the same direction at the same time (one after another)
●
• In order to avoid starvation, the entry of cars onto the bridge in one direction must be stopped after a batch of K cars has entered the bridge from
one direction, to allow traffic moving in the opposite direction (if there are any cars waiting)
• If there are no cars, the bridge is open in both directions, and the first arriving car will determine the direction of traffic.
Viewing each car as a process that is traveling in either the West-East (WE) or East-West (EW) direction, develop a MONITOR that implements the
rules listed above. Your MONITOR must use the monitor procedures Enter_WE(), Enter_EW(), Exit_WE(), Exit_EW() when a car enters and exits the
bridge.
Your solution must show all necessary MONITOR variables and condition variables. It must not unnecessarily restrict vehicles attempting to cross the
bridge, must be deadlock free, and must not starve traffic in either direction.
2. Develop a solution for the Dining Philosopher's problem using AND-Synchronization (i.e. Parallel Semaphores SP and SV)
Transcribed Image Text:1. Imagine a very long bridge across the Mississippi River. A car will take upwards of 15 minutes to cross this bridge. Due to construction, the bridge has been reduced to a single lane that has to be shared by traffic in both directions. It is obviously not possible to allow traffic in both directions simultaneously, and so a special traffic control mechanism is installed with the following rules: • An arriving car will have to wait if the bridge is currently occupied by one or more cars moving in the opposite direction. Multiple cars are allowed to cross the bridge in the same direction at the same time (one after another) ● • In order to avoid starvation, the entry of cars onto the bridge in one direction must be stopped after a batch of K cars has entered the bridge from one direction, to allow traffic moving in the opposite direction (if there are any cars waiting) • If there are no cars, the bridge is open in both directions, and the first arriving car will determine the direction of traffic. Viewing each car as a process that is traveling in either the West-East (WE) or East-West (EW) direction, develop a MONITOR that implements the rules listed above. Your MONITOR must use the monitor procedures Enter_WE(), Enter_EW(), Exit_WE(), Exit_EW() when a car enters and exits the bridge. Your solution must show all necessary MONITOR variables and condition variables. It must not unnecessarily restrict vehicles attempting to cross the bridge, must be deadlock free, and must not starve traffic in either direction. 2. Develop a solution for the Dining Philosopher's problem using AND-Synchronization (i.e. Parallel Semaphores SP and SV)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Representation of Polynomial
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education