当前位置:网站首页>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
边栏推荐
- How to secure users in LDAP directory service?
- 虚拟地址空间
- 3598. 二叉树遍历(华中科技大学考研机试题)
- 2022.8.8 Selected Lectures on Good Topics (Number Theory Field)
- A shell script the for loop statements, while statement
- xshell (sed command)
- port forwarding
- How to translate financial annual report, why choose a professional translation company?
- Black cat takes you to learn Makefile Part 11: When the header file a.h changes, how to recompile all the .c files that depend on the header file a.h
- 学会开会|成为有连接感组织的重要技能
猜你喜欢
威纶通触摸屏如何在报警的同时,显示出异常数据的当前值?
Likou 221 questions, the largest square
接口测试的概念、目的、流程、测试方法有哪些?
LeetCode-402 - Remove K digits
12 Recurrent Neural Network RNN2 of Deep Learning
Regular expression of shell programming and text processor
xshell (sed 命令)
配电网络扩展规划:考虑使用概率性能源生产和消费概况的决策(Matlab代码实现)
H3C S5130 IRF做堆叠
Play RT-THREAD of doxygen
随机推荐
Exploration and practice of the "zero trust" protection and data security governance system of the ransomware virus of Meichuang Technology
2022年8月10日:使用 ASP.NET Core 为初学者构建 Web 应用程序--使用 ASP.NET Core 创建 Web UI(没看懂需要再看一遍)
2022.8.8 Selected Lectures on Good Topics (Number Theory Field)
《DevOps围炉夜话》- Pilot - CNCF开源DevOps项目DevStream简介 - feat. PMC成员胡涛
财务年报怎样翻译,为什么要选择专业翻译公司?
Thread State 详解
Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems
shell编程之正则表达式与文本处理器
What are the concepts, purposes, processes, and testing methods of interface testing?
虚拟地址空间
带着昇腾去旅行:一日看尽金陵城里的AI胜景
【Maui正式版】创建可跨平台的Maui程序,以及有关依赖注入、MVVM双向绑定的实现和演示
shell programming without interaction
Web Reverse Lilac Garden
RK3399平台开发系列讲解(内核驱动外设篇)6.35、IAM20680陀螺仪介绍
FPGA - 7系列 FPGA内部结构之Memory Resources -03- 内置纠错功能
QT笔记——vs + qt 创建一个带界面的 dll 和 调用带界面的dll
电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)(Matlab代码实现)
水果沙拉酱
罗克韦尔AB PLC RSLogix5000中计数器指令使用方法介绍