📄 00000036.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: fzhang (老铁), 信区: Linux <BR>标 题: Re: 再论"对linux的质量质疑" <BR>发信站: BBS 水木清华站 (Fri Jul 30 22:05:49 1999) <BR> <BR>【 在 nudtbegger (军人) 的大作中提到: 】 <BR>∶<I> 异步IO最大的实现背景应该是网络应用吧,特别是SERVER(WEB,FTP, </I><BR>∶<I> 1等待多个事件的能力,SELECT是LINUX实现单线程对多请求的唯一方法, </I><BR>∶<I> (若不对,请指出)。系统用SELECT在事件到来(eg.当一个REQUEST到来时) </I><BR>∶<I> 通知所有的等待同一事件的线程,但是却只有一个线程能处理。这样有几个 </I><BR>∶<I> 开销,1,唤醒的几个线程要同步,最后只能由一个线程来完成服务。2,有 </I><BR>∶<I> 不少线程本来只要睡眠就行,结果却被唤醒,虽然很快就又接着等待,但是 </I><BR>∶<I> CPU时间又消耗不少。有了这两大限制,我的一个师兄告诉我说,一般都是 </I><BR>∶<I> 用一个线程守侯,当来了REQUEST,就通知另一个线程守侯,自己处理,或者 </I><BR>∶<I> 通知另一个线呈处理,自己接着守侯。这样仍然增加了开销。如果LINUX </I><BR>∶<I> 象NT那样,提供能够只唤醒一个线程的函数,无疑将提高处理REQUEST的效率。 </I><BR>Yes, it is true in Linux2.2, but will not in 2.4(we can expect it this fall): <BR>The Linux model of network sockets is one common across most UNIX variants <BR>which adhere to the standards. This is not to say that the standard doesn't <BR>have some deficiencies. Under Linux 2.2, if you have a number of processes <BR>all waiting on an event from a network socket (a web port, for instance) <BR>they will all be woken up when activity is detected. So, for every web page <BR>request, a number of web server processes will suddenly wake up and try and <BR>get at the request... only one will succeed. The losers of the herd will put <BR>themselves back to sleep and wait for the next connection. Linux is a terribly <BR>efficient system and manages to wake up all these processes, give the resource <BR>to one of them, and put the remainder back to sleep very quickly, however <BR>benchmarks have shown that we could be more efficient if we eliminated the <BR>"stampede effect." Thus, the Linux minds cast about for a solution and decided <BR> to implement "wake one" under Linux. This change allows programs to let Linux <BR>know that they should be the only one to be woken up in the case of activity. <BR>It is expected that by the time Linux 2.4 ships, Apache and other similar se <BR>rvers will begin using this new functionality to increase the efficiency of <BR>what they do. <BR> <BR>∶<I> 2异步IO的能力。真正的异步IO和非阻塞IO是不同的,LINUX下实现的就 </I><BR>∶<I> 是非阻塞IO。LINUX下一个网络线程执行了非阻塞IO读,从连接中读取CLIENT </I><BR>∶<I> 的数据,但是,这时CLIENT的数据还未到,该线程可以执行其他的工作,但是, </I><BR>∶<I> 该线程在数据到来时还要执行一次读,否则就得不到数据,如果不知道什么 </I><BR>∶<I> 时候数据能到,将循环等待。但是在真正的异步IO中,情况不是这样,线程 </I><BR>∶<I> 执行一条读后,就不要在读,系统在数据到来时会通知线程
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -