什么是“忙等待"?在操作系统中? [英] What's "busy waiting" in operating system?
问题描述
我正在研究操作系统,但我对 忙等待
概念有疑问.
I'm researching about operating systems and I have a trouble with the busy waiting
concept.
忙等待"是否真的意味着一个动作必须等待一个条件才能继续,但其他等待也必须等待某个条件,那么有什么区别?
Is it true that "busy waiting" means an action must be waiting a condition to continue, but other waiting must wait some condition too, so what is the difference?
推荐答案
忙等待是进程反复检查条件的地方——它在等待"条件,但它忙"检查它.这会让进程吃掉 CPU(通常).
Busy waiting is where a process checks repeatedly for a condition- it is "waiting" for the condition, but it is "busy" checking for it. This will make the process eat CPU (usually).
例如,我有一个进程想知道是否有互联网连接.这是伪代码.
For example, I have a process that wants to know if there is an internet connection. Here is the psudeocode.
function stay_running_until_there_is_internet() {
while(check_internet() == 0) {
\\ wait
}
}
祝你好运!
这篇关于什么是“忙等待"?在操作系统中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!