程序代做 COMP3231/COMP9201/COMP3891/COMP9283

12/04/2022, 09:28 Exam/Multiprocessor – COMP3231/COMP9201/COMP3891/COMP9283
Multiprocessors
1. Multiprocessors
1. Describe why the use of spinlocks might be

Copyright By PowCoder代写 加微信 powcoder

more appropriate than blocking locks on a multiprocessor when compared to a uniprocessor. Is there a trade-off between spinning and blocking on a multiprocessor? Discuss.
2. Is a single ready queue on a multiprocessor a good idea? Why?
3. What is thread affinity? Why might it improve performance?
4. Compare test-and-set and test-and-test-and-set.
Describe why the use of spinlocks might be more appropriate than blocking locks on a multiprocessor when compared to a uniprocessor. Is there a trade-off between spinning and blocking on a multiprocessor? Discuss.
Spinlocks are generally inappropriate on uniprocessors. A process on a uniprocessor either immediately acquires a spinlock or spins forever, waiting for another process to release the lock. However, that other process can’t run since the first process is using the processor to spin. As a result, blocking is preferable.
On a multiprocessor, the thread holding the lock may be presently active on another processor, and it could release the lock at any time. On a multiprocessor, spin-locking can be worthwhile if the average time spent spinning is less than the average overhead of a context switch away from, and back to, the lock requestor.
Is a single ready queue on a multiprocessor a good idea? Why?
Using a single shared ready queue is a bad idea for two reasons:
The queue is a shared resource, so it can become a bottleneck when lots of processors want to schedule their next task. For example, if the queue is protected by a single lock, a single shared ready queue introduces lock contention when many processors are trying to schedule work.
It does not guarantee a process runs on the same CPU when possible, hence resulting in more cache misses.
However, if the number of CPUs in your multiprocessor is small enough that the bottleneck described above isn’t an issue, then a single shared queue is good idea. This is because they’re simple to implement and provide automatic load balancing.
What is thread affinity? Why might it improve performance?
https://wiki.cse.unsw.edu.au/cs3231cgi/Exam/Multiprocessor

12/04/2022, 09:28 Exam/Multiprocessor – COMP3231/COMP9201/COMP3891/COMP9283
Thread affinity is when a scheduler will try to schedule a thread on a particular processor or processors in a multiprocessor machine. This increases the probability that the thread will be scheduled on a processor it has already run on. This generally improves performance because the processor has accumulated cache entries related to the thread, so later runs of the thread may not need to reload these cache entries again.
Compare test-and-set and test-and-test-and-set.
Test-and-set (TSL) is a busy-wait primitive, and will usually lead to lock contention when spinning on the lock. This results in frequent bus locking, causing heavy bus contention and slowing down the communication for other CPUs (regardless of whether they need the lock). Caching does not reduce bus contention – either TSL locks the entire bus, or the bus is used to synchronise cache entries regarding the lock. TSL therefore does NOT scale with the number of processors.
Test-and-test-and-set (TTSL) involves spinning on the lock-value in the cache, which when released uses TSL to acquire it. As this method spins on the cache content, there is no bus contention until the lock is actually released, and cache entries need to be updated / lock needs to be acquired (set). Compared to TSL, caching is used more effectively with significantly reduced bus contention. However, there is no guarantee on the order of CPUs that acquire the lock, which could lead to starvation – whichever CPU can set the lock first will acquire the lock (this is an issue with TSL). Even though TTSL performs better than TSL, it also does NOT scale with number of processors as eventually there will be enough processors to cause heavy bus contention when acquiring the lock.
Exam/Multiprocessor (last edited 2020-08-19 15:31:08 by KevinElphinstone)
https://wiki.cse.unsw.edu.au/cs3231cgi/Exam/Multiprocessor

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com