Model a  common  roadway  occurrence,  where  a  lane  is  closed  and  a  flag  person is directing traffic. There is a two-lane road with one lane closed, and vehicles are approaching from the North and South directions. Due to the traffic lights, the cars arrive in bursts. When a car reaches the construction area, there is an 80% chance that another car will follow it. However, if no car comes, there will be a 20-second gap (utilizing the provided pthread_sleep function) before any new car arrives. During the intervals where no cars are at either end, the flag person will rest. However, when a car arrives at either end, the flag person will wake up and manage the traffic flow from that side, until there are no more cars from that side or until there are 10 or more cars waiting in the opposite direction. If there are 10 or more cars on the opposite side, the flag person must allow those cars to pass first. Each car takes one second to travel through the construction area. Your task is to build a simulation of these events, ensuring that a deadlock never occurs.  Requirements You must design  and  implement  a  multi-threaded  C/C++  program  using  the  Pthread  library  that  avoids deadlocks. You  need  to utilize  Pthread  synchronization  structures,  such  as  semaphores and  mutex  locks,  to  achieve synchronization. Solely using mutex locks for synchronization is not a valid solution for this problem.  You are not allowed to use condition variables. Question: I am so confused on how to start this. Would you provide any pseduocode or some steps I have to follow or reply to this questions? My understanding is that I have to queues Norht and South. Echa car will be a tread and there would be 2 semaphores for the counting of how many cars are at each side? I will also need a lock(mutex) that that flag person will hold to control de traffic flow. I that correct?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
icon
Concept explainers
Question

  Model a  common  roadway  occurrence,  where  a  lane  is  closed  and  a  flag 
person is directing traffic. There is a two-lane road with one lane closed, and vehicles are
approaching from the North and South directions. Due to the traffic lights, the cars arrive in bursts. When
a car reaches the construction area, there is an 80% chance that another car will follow it. However, if no
car comes, there will be a 20-second gap (utilizing the provided pthread_sleep function) before any new
car arrives. During the intervals where no cars are at either end, the flag person will rest. However, when a car arrives at either end, the flag person will wake up and manage the traffic flow from that side, until there are no more cars from that side or until there are 10 or more cars waiting in the opposite direction. If there are 10 or more cars on the opposite side, the flag person must allow those cars to pass first.
Each car takes one second to travel through the construction area. Your task is to build a simulation of these events, ensuring that a deadlock never occurs. 

  1. Requirements
    You must design  and  implement  a  multi-threaded  C/C++  program  using  the  Pthread  library  that  avoids deadlocks. You  need  to utilize  Pthread  synchronization  structures,  such  as  semaphores and  mutex  locks,  to  achieve synchronization. Solely using mutex locks for synchronization is not a valid solution for this problem. 
    You are not allowed to use condition variables.

Question: I am so confused on how to start this. Would you provide any pseduocode or some steps I have to follow or reply to this questions? My understanding is that I have to queues Norht and South. Echa car will be a tread and there would be 2 semaphores for the counting of how many cars are at each side? I will also need a lock(mutex) that that flag person will hold to control de traffic flow. I that correct? 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Heuristic System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY