So far, we have assumed that all n threads have small unique IDs. Here is one way to assign small unique IDs to threads. Arrange Bouncer objects in a triangular matrix, where each Bouncer is given an ID as shown in Fig.2.20. Each
thread starts by visiting Bouncer 0. If it gets STOP, it stops. If it gets RIGHT, it visits 1,and if it etgs DOWN, it visits
In general, if a thread gets STOP, it stops. If it gets RIGHT, it visits the next Bouncer on that row, and if it gets DOWN, it visits the next Bouncer in that column. Each thread takes the ID of the Bouncer object where it stops.
• Prove that each thread eventually stops at some Bouncer object.
• How many Bouncer objects do you need in the array if you know in advance the total number of threads?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here