I have some doubts regarding the Peterson algorithm in a binary tree.
I am doing some exercises from the book "The Art of Multiprocessing Programming" and I am stuck in chapter 2, ex 13:
"Another way to generalize Petersonβs two-threaded lock is to organize a series of 2-threaded Peterson locks in a binary tree. Let n be a power of two. Each thread is assigned a leaf lock, which it shares with another thread. Each lock treats one thread as thread 0 and the other - like thread 1. "
This is normal, but what? If Peterson considers only 2 threads, how will it be a tree? One tree with one single leaf? (because if I have 2 threads and each leaf processes 2 threads ... will the result be a tree with a single leaf?)
"In the method of obtaining tree locks, a thread receives every two-threading. Peterson blocks this leaf flow at the root. The tree locks released for the tree lock open each of the 2-thread Petroner locks that the thread acquired, from the root to its leaf."
What did he mean? How does a leaf go through the root of a node? Very confused !!: S
Thanks guys!
source share