2

When I was studying about linux cache, I found that I've been using the term I/O without knowing its proper definition.

I quote from someone who responded to me about Linux page cache, "Linux kernel populates (and uses) page cache when you are doing i/o, not when you open a file"

Basically, I treated the term I/O as any sys command, but turns out opening a file is not considered I/O.

Furthermore, the definition of I/O is rarely discussed or documented online.

Which leads to my question. What is the definition of I/O (particularly in the context of accessing disks), and what actions can be classified as I/O?

CuriousKimchi
  • 205
  • 2
  • 10

1 Answers1

1

What is the definition of I/O, and what actions are classified as I/O?

This is a question that has no definitive answer. (1) It depends upon the system (aided here by your specification of Linux) and (2) it depends up on the perspective. Is it Input/Output from the perspective of a user? A process? The kernel?

From the perspective of a process one might say I/O in linux is any operation using the read or write system services. In that sense an OPEN is not I/O because it is not reading or writing process data.

Even definition does not account for writing to screen (but you asked to focus on disk).

However, if you change your perspective to that of the kernel the scope of I/O expands. a FILE open request might require reading the contents of one or more directories and reading header file information on the disk. Thus, any movement of data between disk and memory could be considered I/O.

From a user perspective, I/O is anything that moves data in or out of the processor. That's more theoretical. As I mentioned above, a computer can write text to a screen by updating video memory. One might make the distinction here between main memory and video memory but from a logical sense there is no real movement of data.

user3344003
  • 20,574
  • 3
  • 26
  • 62
  • Can write and read a variable to be considered as a kind of "IO" operation? For example, I have 2 threads that each read and write a shared variable. – Rick Nov 15 '18 at 05:02
  • Supposed, for example, that variable is mapped to the screen buffer. In that case it would be I/O. It all depends upon the context. – user3344003 Nov 15 '18 at 12:32