- 1、本文档共5页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Proactor和Reactor模式_继续并发系统设计的扫盲
Proactor和Reactor模式_继续并发系统设计的扫盲
6.6.2008
Kevin Lynx
Proactor和Reactor都是并发编程中的设计模式。在我看来,他们都是用于派发/分离IO操作事件的。这里所谓的IO事件也就是诸如read/write的IO操作。派发/分离就是将单独的IO事件通知到上层模块。两个模式不同的地方在于,Proactor用于异步IO,而Reactor用于同步IO。
摘抄一些关键的东西:
Two patterns that involve event demultiplexors are called Reactor and Proactor [1]. The Reactor patterns involve synchronous I/O, whereas the Proactor pattern involves asynchronous I/O.
关于两个模式的大致模型,从以下文字基本可以明白:
An example will help you understand the difference between Reactor and Proactor. We will focus on the read operation here, as the write implementation is similar. Heres a read in Reactor:
* An event handler declares interest in I/O events that indicate readiness for read on a particular socket ;* The event demultiplexor waits for events ;* An event comes in and wakes-up the demultiplexor, and the demultiplexor calls the appropriate handler; * The event handler performs the actual read operation, handles the data read, declares renewed interest in ? I/O events, and returns control to the dispatcher .
By comparison, here is a read operation in Proactor (true async):
* A handler initiates an asynchronous read operation (note: the OS must support asynchronous I/O). In this ? case, the handler does not care about I/O readiness events, but is instead registers interest in receiving ? completion events;* The event demultiplexor waits until the operation is completed ;* While the event demultiplexor waits, the OS executes the read operation in a parallel kernel thread, puts ? data into a user-defined buffer, and notifies the event demultiplexor that the read is complete ;* The event demultiplexor calls the appropriate handler; * The event handler handles the data from user defined buffer, starts a new asynchronous operation, and returns? control to the event demultiplexor.
可以看出,两个模式的相同点,都是对某个IO事件的事件通知(即告诉某个模块,这个IO操作可以进行或已经完成)。在结构上,两者也有相同点:demultiplexor负责提交IO操作(异步)、查询设备是否可操作(同步),然后当条件满足时,就回调handler。不同点在于,异步情况下(Proactor),当回调hand
您可能关注的文档
- 6级范文背诵50篇.doc
- 【步步高 学案导学设计】2014-2015学年高中英语(外研版,必修三)课时作业:Module 1 Period 4.docx
- 英语四级模拟.docx
- 2014-2015高一第二学期英语第一次测试.doc
- 亿唐网的衰败.docx
- 雅虎企业介绍.doc
- 【英语辩论】期末资料收集.docx
- 成人学士学位英语.doc
- 雅虎惨案 16年败掉1000亿美金市值.docx
- 史上最全REACH法规解释.doc
- 甘肃省XB师范大学附属中学2025届高三上学期一模诊断考试地理答案.doc
- 甘肃省XB师范大学附属中学2025届高三上学期一模诊断政治含解析.doc
- 安徽省皖江名校2024-2025学年高一上学期12月联考英语无答案.doc
- 2025年1月八省联考高考综合改革适应性测高三化学陕西山西宁夏青海卷无答案.doc
- 2025年1月八省联考高考综合改革适应性测高三化学四川卷无答案.doc
- 2025年1月八省联考高考综合改革适应性测高三政治陕西山西宁夏青海卷无答案.doc
- 2025年1月内蒙古自治区普通高等学校招生考试适应性测试(八省联考)历史无答案.doc
- 2025年1月内蒙古自治区普通高等学校招生考试适应性测试(八省联考)历史含解析.doc
- 2025年1月四川省普通高等学校招生考试适应性测试(八省联考)历史含解析.doc
- 2025年1月四川省普通高等学校招生考试适应性测试(八省联考)政治无答案.doc
文档评论(0)