[Solved] CSC33200-Assignment 3-Pthreads that synchronizes the threads access to the output screen and prevents deadlock

$25

File Name: CSC33200-Assignment_3-Pthreads_that_synchronizes_the_threads_access_to_the_output_screen_and_prevents_deadlock.zip
File Size: 1036.2 KB

SKU: [Solved] CSC33200-Assignment 3-Pthreads that synchronizes the threads access to the output screen and prevents deadlock Category: Tag:
5/5 - (1 vote)

Assignment 3A 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 to 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.)Implement a solution using Pthreads that synchronizes the threads access to the output screen and prevents deadlock. In particular, represent northbound and southbound farmers as separate threads (use several threads representing the northbound and southbound farmers). Once a farmer is on the bridge the associated thread will: Print to the screen North (or South) Tunbridge farmer can cross the bridge after the thread has granted access to the lock. Print on the screen North (or South) Tunbridge is traveling on the bridge as Sleep for a random period (up to 3 seconds). Print to the screen North (or South) Tunbridge farmer has left the bridge before releasing the lock.Meanwhile, the other village farmer is waiting for the bridge to be clear. The program screen printout should look like the following:North Tunbridge #1 farmer can cross the bridgeNorth Tunbridge #1 is traveling on the bridgeNorth Tunbridge #1 farmer has left the bridge

South Tunbridge #1 farmer can cross the bridge South Tunbridge #1 is traveling on the bridgeSouth Tunbridge #1 farmer has left the bridge

North Tunbridge #2 farmer can cross the bridgeNorth Tunbridge #2 is traveling on the bridgeNorth Tunbridge #2 farmer has left the bridge

Submit the following:I. The program code with all commentsII. Screenshots of the output for your program when:a. not using the lockb. using the lockIII. Assignment report which will answer the following questions:1. What type of lock your code is using?2. How many processes does your program fork? Are there equal number of North and South processes?

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSC33200-Assignment 3-Pthreads that synchronizes the threads access to the output screen and prevents deadlock
$25