I'm currently revising for an exam and came across this question:

Under what circumstances is a spinlock a suitable implementation for a lock? When would it be a bad choice of implementation? Describe a better solution and write a pseudo-code definition for it.

I can answer the question about the un/suitability of spinlocks, but I am absolutely stumped what constitutes a "better solution" and how to implement that in pseudo-code. I'd appreciate if someone could point me in the right direction.

有帮助吗?

解决方案

I would do some investigation into topics like "Critical Section", "Mutex", "Semaphore", "I/O Completion Ports" and think about mechanisms for posting waiting threads.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top