A single-lane bridge connects the two Vermont villages of North Tunbridge and South Tunbridge. Farmers in the
Question:
A single-lane bridge connects the two Vermont villages of North Tunbridge and South Tunbridge. Farmers in the two villages use this bridge to deliver their produce.
the neighboring town. The bridge can become deadlocked if a northbound and a southbound farmer get on the bridge at the same time. (Vermont farmers are stubborn and are unable to back up.) Using semaphores and/or mutex locks, design an algorithm in pseudocode that prevents deadlock. Initially, do not be concerned about starvation (the situation in which northbound farmers prevent southbound farmers from using the bridge, or vice versa).
a) Write the pseudocode algorithm.
b) Modify your solution so that it is starvation-free.
c) Implement your solution using POSIX synchronization. In particular, represent northbound and southbound farmers as separate threads. Once a farmer is on the bridge, the associated thread will sleep for a random period of time, representing traveling across the bridge. Design your program so that you can. create several threads representing the northbound and southbound farmers. ex§. (3 southbound, 4 northbound) or (2 southbound, 5 northbound) or (4 southbound, 1 northbound), etc. Note: the number of southbound and
northbound farmers will be provided on the command line.
Value at Risk The New Benchmark for Managing Financial Risk
ISBN: 978-0071464956
3rd edition
Authors: Philippe Jorion