首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    I/O的内核原理与5种I/O模型

    我们都知道unix世界里、一切皆文件、而文件是什么呢?文件就是一串二进制流而已、不管socket、还是FIFO、管道、终端、对我们来说、一切都是文件、一切都是流、在信息交换的过程中、我们都是对这些流进行数据的收发操作、简称为I/O操作(input and output)、往流中读出数据、系统调用read、写入数据、系统调用write、不过话说回来了、计算机里有这么多的流、我怎么知道要操作哪个流呢?做到这个的就是文件描述符、即通常所说的fd(file descriptor)、一个fd就是一个整数、所以对这个整数的操作、就是对这个文件(流)的操作、我们创建一个socket、通过系统调用会返回一个文件描述符、那么剩下对socket的操作就会转化为对这个描述符的操作、不能不说这又是一种分层和抽象的思想、

    05

    fio基础10

    bs_is_seq_randIfthisoptionisset,fiowillusethenormalread,writeblocksizesettingsassequential,randominstead.AnyrandomreadorwritewillusetheWRITEblocksizesettings,andanysequentialreadorwritewillusetheREADblocksizesetting.zero_buffersIfthisoptionisgiven,fiowillinittheIObufferstoallzeroes.Thedefaultistofillthemwithrandomdata.refill_buffersIfthisoptionisgiven,fiowillrefilltheIObuffersoneverysubmit.Thedefaultistoonlyfillitatinittimeandreusethatdata.Onlymakessenseifzero_buffersisn't specified, naturally. If data verification is enabled, refill_buffers is also automatically enabled. scramble_buffers=bool If refill_buffers is too costly and the target is using data deduplication, then setting this option will slightly modify the IO buffer contents to defeat normal de-dupe attempts. This is not enough to defeat more clever block compression attempts, but it will stop naive dedupe of blocks. Default: true. buffer_compress_percentage=int If this is set, then fio will attempt to provide IO buffer content (on WRITEs) that compress to the specified level. Fio does this by providing a mix of random data and a fixed pattern. The fixed pattern is either zeroes, or the pattern specified by buffer_pattern. If the pattern option is used, it might skew the compression ratio slightly. Note that this is per block size unit, for file/disk wide compression level that matches this setting, you'llalsowanttosetrefill_buffers.buffer_compress_chunk=intSeebuffer_compress_percentage.Thissettingallowsfiotomanagehowbigtherangesofrandomdataandzeroeddatais.Withoutthisset,fiowillprovidebuffer_compress_percentageofblocksizerandomdata,followedbytheremainingzeroed.Withthissettosomechunksizesmallerthantheblocksize,fiocanalternaterandomandzeroeddatathroughouttheIObuffer.buffer_pattern=strIfset,fiowillfilltheiobufferswiththispattern.Ifnotset,thecontentsofiobuffersisdefinedbytheotheroptionsrelatedtobuffercontents.Thesettingcanbeanypatternofbytes,andcanbeprefixedwith0xforhexvalues.Itmayalsobeastring,wherethestringmustthenbewrappedwit

    04

    14.块设备驱动

    1、字符设备驱动:   当我们的应用层读写(read()/write())字符设备驱动时,是按字节/字符来读写数据的,期间没有任何缓存区,因为数据量小,不能随机读取数据,例如:按键、LED、鼠标、键盘等 2、块设备:   块设备是i/o设备中的一类, 当我们的应用层对该设备读写时,是按扇区大小来读写数据的,若读写的数据小于扇区的大小,就会需要缓存区, 可以随机读写设备的任意位置处的数据,例如 普通文件(.txt,.c等),硬盘,U盘,SD卡。 3、块设备结构: 段(Segments):由若干个块组成。是Linux内存管理机制中一个内存页或者内存页的一部分。 块 (Blocks): 由Linux制定对内核或文件系统等数据处理的基本单位。通常由1个或多个扇区组成。(对Linux操作系统而言) 扇区(Sectors):块设备的基本单位。通常在512字节到32768字节之间,默认512字节 应用程序进行文件的读写,通过文件系统将文件的读写转换为块设备驱动操作硬件。

    03
    领券