Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
LINUX系統程式設計 第二版
by
Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from
LINUX系統程式設計 第二版
進階檔案
I/O
|
113
假定你想要透過某個檔案描述器讀取資料。若採用準位觸發的
epoll
行為,只要該
檔案描述器已備妥而可供讀取,你就會收到通知。這是信號線到達所指定的準位
所引發的事件。採用邊緣觸發,當資料變為可供讀取,你將會收到通知,但只有
一次:這是信號線經歷所指定的暫態所引發的事件。
把檔案映射至記憶體
標準檔案
I/O
還有另一個選項:核心提供了一個介面,讓應用程式得以把一個檔案映射
至記憶體,這意味著,記憶體上的一個位址與檔案中的一個字組(
word
)之間存在著一
對一的關係。於是程式設計者可以直接透過記憶體來存取檔案,如同把資料存放在記憶
體的任何其他團塊—這甚至可讓對特定記憶體範圍所進行的寫入操作,自動被映射回磁
碟上的檔案。
POSIX.1
定義了—而且
Linux
實作了—
mmap()
系統呼叫,以便把物件映射至記憶體。本
節將探討
mmap()
,因為它與「將檔案映射至記憶體時所進行的
I/O
」有關;第
9
章中,
我們將會看到
mmap()
的其他應用。
mmap()
透過
mmap()
呼叫,可要求核心把檔案描述器
fd
所代表的物件映射至記憶體。參數
len
代表物件中有多少位元組將被映射至記憶體,參數
offset
代表從物件中的何處開始映
射。此外,參數
addr
用於指向記憶體中所欲使用的起始位址。參數
prot
用於指示存取
權限。參數
flags
用於指定額外的行為:
#include <sys/mman.h>
void * mmap (void *addr,
size_t len,
int prot, ...
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科學研究的美學
Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
成為卓越程式設計師的38項必修法則
Pete Goodliffe
深入理解運算原理|從簡單的機器到無所不能的程式
Tom Stuart
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9789862769812