测试和设置是做什么用的? [英] What is Test-and-Set used for?
本文介绍了测试和设置是做什么用的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在阅读了测试和设置 维基百科条目之后,我仍然留下一个问题Test-and-Set 将用于什么?"
After reading the Test-and-Set Wikipedia entry, I am still left with the question "What would a Test-and-Set be used for?"
我知道您可以使用它来实现 Mutex(如维基百科中所述),但它还有什么其他用途?
I realize that you can use it to implement Mutex (as described in wikipedia), but what other uses does it have?
推荐答案
您在完成一些工作后想要将数据写入内存时使用它,并确保自您启动以来另一个线程没有覆盖目标.许多无锁/互斥算法采用这个表格.
You use it any time you want to write data to memory after doing some work and make sure another thread hasn't overwritten the destination since you started. A lot of lock/mutex-free algorithms take this form.
这篇关于测试和设置是做什么用的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文