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系統程式設計 第二版
44
|
第二章
本章稍後會在第
2
章〈核心內部〉一節深入探討
Linux
核心的緩衝區寫回子系統
(
buffer writeback subsystem
)。
同步
I/O
儘管
I/O
的同步是一個重要的課題,但也不應該迴避延後寫入的相關問題。寫入操作的
緩衝機制大大提升了系統的效能,因此任何作業系統都應該經由緩衝機制來實作延後寫
入功能。然而,有些時候,應用程式可能會想要控制何時可以把資料寫回磁碟。此狀況
下,
Linux
核心提供了若干選項,讓你得以在效能與同步操作之間做出取捨。
fsync()
與
fdatasync()
確保資料能夠寫回磁碟的最簡單方法,就是經由
POSIX.1b
所定義的
fsync()
系統呼叫:
#include <unistd.h>
int fsync (int fd);
呼叫
fsync()
可確保檔案描述器
fd
所映射之檔案中「遭改變的」所有資料會被寫回磁
碟。檔案描述器
fd
必須開啟以備寫入。此呼叫會寫回資料、中介資料(例如檔案何時
建立的時間戳記)以及
inode
中所包含的其他屬性。此呼叫會一直等到「硬碟回報資料
與中介資料已經寫回磁碟」才會返回。
在硬碟具有寫入快取區(
write cache
)的狀況下,
fsync()
不可能知道資料是否真的已經
位於磁碟上。儘管硬碟回報資料已經寫回,但資料實際上仍擺在硬碟的寫入快取區。所
幸的是,硬碟快取區裡的資料應該會立即交付給磁碟。
Linux
還提供了
fdatasync()
系統呼叫:
#include <unistd.h>
int fdatasync ...
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