Hello Ranchers,
As you know, the interface provided with the assignment specifies the following lock method (or something similar to it):
My concern lies with the sentence that states, "
the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked." Now this subject has come up several times in this forum, and usually the general consensus is to use notifyAll() in the unlock method to wake up all waiting threads so they can check to see if the record they are waiting for is available. However, this technically does consume some CPU cycles, albeit a very small amount.
In
Steve's Post, he outlines a waiting thread queue that he used to ensure that no CPU cycles were consumed until the specific record that a thread was waiting for is unlocked. He also received a perfect score in his locking. Personally, I think the concept of a waiting thread queue is an absolute must in a real world application. But I have always thought that it would be outside the scope of this assignment.
Any thoughts?
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook