Question: Implement the Ballroom Dancers simulation in c++. Imagine that threads represent ballroom dancers and that two kinds of dancers, leaders and followers, wait in two
Implement the Ballroom Dancers simulation in c++. Imagine that threads represent ballroom dancers and that two kinds of dancers, leaders and followers, wait in two queues before entering the dance floor. When a leader arrives, it checks to see if there is a follower waiting. If so, they can both proceed. Otherwise it waits. Similarly, when a follower arrives, it checks for a leader and either proceeds or waits, accordingly. Input: ./a.out n m output.txt where n is the number of "leaders" and m is the number of "followers" and output.txt is the output file generated by your program. Output: leader dances with follower For all threads, the number of leaders and followers may be different. We want to make sure all dancers dance at least once. After all have dance, the program ends. Keep a running count of how many followers have danced and leaders have danced.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
