什么是“忙等待"?在操作系统中? [英] What's "busy waiting" in operating system?

查看:277
本文介绍了什么是“忙等待"?在操作系统中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究操作系统,但我对 忙等待 概念有疑问.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆