Skip to Content
LINUX系統程式設計 第二版
book

LINUX系統程式設計 第二版

by Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from LINUX系統程式設計 第二版
106
|
第四章
poll()
select()
(第 2 章有討論)的每次調用,需提供一份所要檢視之檔案描述器
的完整清單。然後核心必須處理清單中每個檔案描述器。當這份清單變大時—它可能包
含成百上千的檔案描述器—每次調用所要處理的清單會變成擴充性的瓶頸(scalability
bottleneck)。
epoll 避開這個問題的方法,就是讓「事件檢視器的登記」(monitor registration)與「實
際的事件檢視工作」(actual monitoring)脫勾。一個系統呼叫用於初始設定 epoll 的作
業環境,另一個系統呼叫用於把所要檢視的檔案描述器加入作業環境,或是從作業環境
中移除檔案描述器,第三個系統呼叫則實際進行事件的等待。
建立一個新的 epoll 實例
epoll_create1()
可用於建立一個 epoll 的作業環境:
#include <sys/epoll.h>
int epoll_create1 (int flags);
/* 已遭棄用。在新的程式碼中應該使用 epoll_create1() */
int epoll_create (int size);
執行成功時,
epoll_create1()
會建立一個新的 epoll 實例,並且傳回一個與實例相對應
的檔案描述器。此檔案描述器與真實的檔案沒有關係;它只是一個可供「隨後呼叫」
subsequent calls)使用 epoll 措施(facility)的操作代號(handle)。
flags
參數用於
修改 epoll ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769812