当前位置:网站首页>file IO-buffer
file IO-buffer
2022-08-10 22:30:00 【dry rice white】
How to understand input and output
1. From the perspective of the document
2. From the perspective of memory
When we write programs, we think about problems from the perspective of memory.
If we are manipulating the file, input into the file, the expression obtained from the file is more accurate.
The relationship between standard C library IO and Linux system IO
1. The bottom layer of the C library function actually calls the Linux system function
2.C library IO has buffer, Linux system function has no buffer
Benefits of having a buffer:
Improve efficiency
For example, there are 100 eggs that need to be transported from point A to point B. If there is no buffer, they can only be transported one by one. If there is a buffer, then it is equivalent to having a box, assuming that the box canLoad 20 eggs. When the box is full or flushed or there are no more eggs left in area A, the eggs will be delivered to point B through the box.
Three times to refresh the memory buffer
1. Active refresh fflush
2. The buffer is full
3. Close the file normally close return return exit
File pointer FILE
We know that C language operation files are carried out through FILE, and FILE is a structure.Among them, there are three most important members
1. The corresponding disk file can be indexed through the file descriptor
2. The read and write position in the file can be determined by the file read and write pointer
3. I/O buffer (same as the function mentioned above, reduce the number of disk reads and writes to improve efficiency)
Why is disk read and write slow
In the process of learning, we often encounter reducing disk read and write operations to improve efficiency, because disk operations are relatively slow.This is a hardware defect, Most of the disks are mechanical disks, the read seek time and write seek time are both millisecond level, while memory belongs to electronic equipment, and read and write is nanosecond level.1ms = 10^7ns
边栏推荐
猜你喜欢
【Maui正式版】创建可跨平台的Maui程序,以及有关依赖注入、MVVM双向绑定的实现和演示
配电网络扩展规划:考虑使用概率性能源生产和消费概况的决策(Matlab代码实现)
一篇文章教你Pytest快速入门和基础讲解,一定要看
元宇宙社交应用,靠什么吸引用户「为爱发电」?
What are the concepts, purposes, processes, and testing methods of interface testing?
阿里云架构师金云龙:基于云XR平台的视觉计算应用部署
Use Cloudreve to build a private cloud disk
A shell script the for loop statements, while statement
财务年报怎样翻译,为什么要选择专业翻译公司?
Conditional Statements of Shell Programming (2)
随机推荐
win系统下pytorch深度学习环境安装
自组织是管理者和成员的双向奔赴
Self-organization is a two-way journey between managers and members
12 Recurrent Neural Network RNN2 of Deep Learning
为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?
TCP连接过程中如果拔掉网线会发生什么?
ThreadLocal comprehensive analysis (1)
力扣221题,最大正方形
测试4年感觉和1、2年时没什么不同?这和应届生有什么区别?
unusual understanding
BM13判断一个链表是否为回文结构
HighTec shortcut keys (Keys) setting location
美味的石井饭
谁是边缘计算服务的采购者?是这六个关键角色
Regular expression of shell programming and text processor
MySQL Advanced Commands
shell编程之免交互
【PCBA solution】Electronic grip strength tester solution she'ji
RK3399平台开发系列讲解(内核驱动外设篇)6.35、IAM20680陀螺仪介绍
阿里云贾朝辉:云XR平台支持彼真科技呈现国风科幻虚拟演唱会