Problems With Native Spinlock Quiz Solution – Georgia Tech – Advanced Operating Systems


If you checked all three of them, you’re exactly on the right track. Let’s talk about it. First of all, you know that with this, with the naive implementation there is going to be too much contention for the lock when the lock is released. Because everybody, both t2 and t3 in the previous example, jumped in and started looking at the test and set instruction, trying to acquire the lock. And there are thousands of processes, everybody is going to be executing this test and set instruction, so there is going to be plenty of contention on the network, in order to get to that shared variable, that’s the first problem. Now, let’s talk abolut why the second answer is also the right answer. You know from the previous lesson that a shared memory multiprocessor has private caches associated with every one of the processors. And it is often the case that the caches may be kept coherent by the hardware. Now if the private caches associated with every processor and if a value from memory can be cached in that, there is an issue with test and set instruction. And that is, test and set instruction cannot use the cached value, because it has to make sure that the memory value is modified atomically when, when it is inspecting the memory. And therefore. By definition, a test and set of instruction, is not going to exploit caches, it is going to bypass the cache and go to memory, in order to do the test and set operation. And therefore yes, this is also true, that the spin algorithm that I gave you, spin on test and set, is not going to be able to exploit the caches. The third problem is, is the fact that it might disrupt useful work. And it’s also a good answer and the reason is because, when a processor releases the lock. After releasing the lock, that processor wants to go on and do some useful work. And similarly. If, let’s say there are four processors trying to acquire the lock. Only one of them is going to get it, and the others are going to have to back off, because they’re not going to have the lock. Now the one, one guy that did get the lock has useful work to do. But, because of the fact that there’s a lot of contention, the guy that can actually do useful work is being impeded from doing useful work because the contention that is there. In all the other processors trying to go and get the lock when it is not available. So, this is really the problem, that the test and set instructions, because it is bypassing the caches, it’s first of all causing a lot of contention on the network and it is also impeding some of the useful processor from carrying on with its work. Which may advance the cause of the parallel program. So all of these are good answers in terms of the problems with this, with this naive spinlock.

Leave a Reply

Your email address will not be published. Required fields are marked *