阻塞与未阻塞 I/O 缓冲?
Blocked vs unblocked I/O buffering?
我读了一些关于 z/OS 的 blocked IO 的概念。它指出:
Blocked I/O is an extension to the ISO standard. For files opened in block format, z/OS® XL C/C++ reads and writes one block at a time. If you try to write more data to a block than the block can hold, the data is truncated. For blocked I/O, z/OS XL C/C++ allows only the use of fread() and fwrite() to read and write to files.
然后它会说:
The fflush() function has no effect for blocked I/O files.
然而,在another文章中,它说:
For terminals, because I/O is always unblocked, line buffering is
equivalent to full buffering.
For record I/O files, buffering is
meaningful only for blocked files or for record I/O files in z/OS UNIX
file system using full buffering. For unblocked files, the buffer is
full after every write and is therefore written immediately, leaving
nothing to flush. For blocked files or fully-buffered UNIX file system
files, however, the buffer can contain one or more records that have
not been flushed and that require a flush operation for them to go to
the system.
For blocked I/O files, buffering is always meaningless.
我对这一切感到非常困惑。如果 I/O 是畅通的,那么行缓冲如何等同于全缓冲呢?为什么 flush 不会对块 I/O 产生影响?另外blockedI/O导致buffering总是没有意义是什么意思?任何关于阻塞与未阻塞 I/O 以及它如何影响缓冲效果的直觉将不胜感激。
我对您提供的内容的看法是,这指的是 MVS 数据集的 Blocked I/O。这些将不同于存储在 Unix 系统服务 HFS / ZFS 中的文件。与终端 I/O.
不同
I'm extremely confused by all this. If I/O is unblocked, how would
line buffering be equivalent to full buffering?
我认为您指的是对终端 I/O 的引用,它表示一行是一条记录并且与块大小相同,因此每条记录都是一个完整的数据块。也就是说,每个块有一个 LRECL = BLKSIZE == 1 条记录,因此它没有被缓冲,或者,缓冲区就是记录。
Why wouldn't flush make a difference in block I/O?
如果每个块有多个记录,fflush 在块满之前不会写入块。我怀疑这与 z/OS 中的 I/O 实现有关,该实现早于平台上的 C,因此他们做出了设计决定,不会在 I/O 的执行方式上导致不同语言的不同行为。
In addition, what does it mean that blocked I/O cause buffering to be always meaningless?
同样,z/OS 写入除文件中最后一个块以外的完整块,该块可能很短,因为它不包含足够的记录来容纳一个完整块。
在 C 进入平台之前 z/OS 有很多历史,z/OS 竭尽全力提供一致性。
我读了一些关于 z/OS 的 blocked IO 的概念。它指出:
Blocked I/O is an extension to the ISO standard. For files opened in block format, z/OS® XL C/C++ reads and writes one block at a time. If you try to write more data to a block than the block can hold, the data is truncated. For blocked I/O, z/OS XL C/C++ allows only the use of fread() and fwrite() to read and write to files.
然后它会说:
The fflush() function has no effect for blocked I/O files.
然而,在another文章中,它说:
For terminals, because I/O is always unblocked, line buffering is equivalent to full buffering.
For record I/O files, buffering is meaningful only for blocked files or for record I/O files in z/OS UNIX file system using full buffering. For unblocked files, the buffer is full after every write and is therefore written immediately, leaving nothing to flush. For blocked files or fully-buffered UNIX file system files, however, the buffer can contain one or more records that have not been flushed and that require a flush operation for them to go to the system.
For blocked I/O files, buffering is always meaningless.
我对这一切感到非常困惑。如果 I/O 是畅通的,那么行缓冲如何等同于全缓冲呢?为什么 flush 不会对块 I/O 产生影响?另外blockedI/O导致buffering总是没有意义是什么意思?任何关于阻塞与未阻塞 I/O 以及它如何影响缓冲效果的直觉将不胜感激。
我对您提供的内容的看法是,这指的是 MVS 数据集的 Blocked I/O。这些将不同于存储在 Unix 系统服务 HFS / ZFS 中的文件。与终端 I/O.
不同I'm extremely confused by all this. If I/O is unblocked, how would line buffering be equivalent to full buffering?
我认为您指的是对终端 I/O 的引用,它表示一行是一条记录并且与块大小相同,因此每条记录都是一个完整的数据块。也就是说,每个块有一个 LRECL = BLKSIZE == 1 条记录,因此它没有被缓冲,或者,缓冲区就是记录。
Why wouldn't flush make a difference in block I/O?
如果每个块有多个记录,fflush 在块满之前不会写入块。我怀疑这与 z/OS 中的 I/O 实现有关,该实现早于平台上的 C,因此他们做出了设计决定,不会在 I/O 的执行方式上导致不同语言的不同行为。
In addition, what does it mean that blocked I/O cause buffering to be always meaningless?
同样,z/OS 写入除文件中最后一个块以外的完整块,该块可能很短,因为它不包含足够的记录来容纳一个完整块。
在 C 进入平台之前 z/OS 有很多历史,z/OS 竭尽全力提供一致性。