为什么不提供标准的非忙等待方法? [英] Why not provide a standard non-busy waiting method?
问题描述
嗨。
忙碌等待是一种应该避免的已知反模式。但是,
in C,
没有标准的替代方案,所以当需要等待并且它是'b $ b不忙时,
程序变得100%不可移植。那么为什么不在标准中包含这个
类型
的非繁忙等待功能呢?
Hi.
Busy-waiting is a known anti-pattern that should be avoided. However,
in C,
there is no standard alternative, so when a wait is required and it''s
not busy,
the program becomes 100% non-portable. So then why not include this
type
of non-busy wait functionality in the standard?
推荐答案
mike3写道:
mike3 wrote:
>
嗨。
忙碌等待是一种应该避免的已知反模式。但是,在C中有
,没有标准的替代方案,所以当需要等待时,b $ b并且它不忙,程序变得100%不可移植。那么为什么
在标准中不包含这种类型的非忙等待功能呢?
>
Hi.
Busy-waiting is a known anti-pattern that should be avoided. However,
in C, there is no standard alternative, so when a wait is required
and it''s not busy, the program becomes 100% non-portable. So then why
not include this type of non-busy wait functionality in the standard?
如果底层平台没有这样的支持怎么办? (例如:MS-DOS。)
更不用说,非忙碌等待的概念。意味着一个多元化的b $ b任务系统。
-
+ ------------ ------------- + -------------------- + --------------- -------- +
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody / at\spamcop.net | www.fptech.com | < std_disclaimer.h |
+ ------------------------- + --------- ----------- + ----------------------- +
不要 - 邮寄给我:< mailto:Th ************* @ gmail.com>
What if the underlying platform has no such support? (eg: MS-DOS.)
Not to mention, the concept of "non-busy waiting" implies a mutli-
tasking system.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don''t e-mail me at: <mailto:Th*************@gmail.com>
文章< 47***************@spamcop.net>,
Kenneth Brody< ke ****** @ spamcop.netwrote:
In article <47***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.netwrote:
> mike3写道:
>mike3 wrote:
>>
嗨。
忙碌等待是一种应该避免的已知反模式。但是,在C中,没有标准替代品,所以当需要等待并且它不忙时,程序变得100%不可移植。那么为什么
不在标准中包含这种类型的非忙等待功能呢?
>>
Hi.
Busy-waiting is a known anti-pattern that should be avoided. However,
in C, there is no standard alternative, so when a wait is required
and it''s not busy, the program becomes 100% non-portable. So then why
not include this type of non-busy wait functionality in the standard?
如果底层平台没有这样的支持怎么办? (例如:MS-DOS。)
更不用说,非忙碌等待的概念。意味着一个多任务的任务系统。
What if the underlying platform has no such support? (eg: MS-DOS.)
Not to mention, the concept of "non-busy waiting" implies a mutli-
tasking system.
任何有几个脑细胞一起擦的人都可以看到
处理这个问题的方法就是让这个函数成为一个-op如果有必要的话。
Anyone with couple of brain cells to rub together could see that the
way to handle this is to allow the function to be a no-op if necessary.
mike3< mi ****** @ yahoo.comwrites:
mike3 <mi******@yahoo.comwrites:
忙碌等待是一种已知的反模式,应避免
。但是,在C中,没有标准替代方案,因此当需要等待并且它不忙时,程序变为100%
非便携式。那么为什么不在标准中包含这种类型的非忙等待
功能呢?
Busy-waiting is a known anti-pattern that should be
avoided. However, in C, there is no standard alternative, so when a
wait is required and it''s not busy, the program becomes 100%
non-portable. So then why not include this type of non-busy wait
functionality in the standard?
等待什么?
如果你的程序的要求要求它做一个非繁忙的等待,
然后它可能(但不一定)需要做一些其他的系统特定的东西。将此功能保留到
操作系统或POSIX等二级标准是不合理的。
-
Keith Thompson(The_Other_Keith)< ks *** @ mib.org>
诺基亚
我们必须做点什么。这是事情。因此,我们必须这样做。
- Antony Jay和Jonathan Lynn,是部长
Waiting for what?
If the requirements for your program require it to do a non-busy wait,
then it probably (but not certainly) needs to do some other
system-specific stuff as well. Leaving this functionality up to the
operating system or to a secondary standard such as POSIX isn''t
unreasonable.
--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
这篇关于为什么不提供标准的非忙等待方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!