Input/Output of data to/from a system. This usually implies file storage or network communication, but may also mean interaction with a user through a user interface.
Questions tagged [io]
91 questions
47
votes
5 answers
Critique of the IO monad being viewed as a state monad operating on the world
The IO monad in Haskell is often explained as a state monad where the state is the world. So a value of type IO a monad is viewed as something like worldState -> (a, worldState).
Some time ago I read an article (or a blog/mailing list post) that…

Petr
- 5,507
- 3
- 29
- 46
30
votes
6 answers
Why do we have to wait for I/O?
It's always been known that Disk operations are slow and we know the reasons why they are slow.
So the question here is why do we have to wait for I/O or why is there such a thing as IOWait, etc.?
I mean I've noticed that when you're doing some I/O…

Arturas M
- 551
- 1
- 6
- 10
29
votes
2 answers
Why is universal newlines mode deprecated in Python?
I just noticed that the universal newline feature of file operations seems to be on its way out.
The documentation for Python 3.5 open's mode parameter indicates that it's deprecated:
'U' universal newlines mode (deprecated)
At least as far…

jpmc26
- 5,389
- 4
- 25
- 37
29
votes
5 answers
At what point is asynchronous reading of disk I/O more efficient than synchronous?
Assuming there is some bit of code that reads files for multiple consumers, and the files are of any arbitrary size: At what size does it become more efficient to read the file asynchronously? Or to put it another way, how small must a file be for…

blesh
- 899
- 1
- 9
- 15
23
votes
4 answers
How bad is it calling println() often than concatenating strings together and calling it once?
I know output to the console is a costly operation. In the interest of code readability sometimes it is nice to call a function to output text twice, rather than having a long string of text as an argument.
For example how much less efficient is it…

Celeritas
- 585
- 4
- 9
20
votes
4 answers
Why do we have to mention the data type of the variable in C
Usually in C, we have to tell the computer the type of data in variable declaration. E.g. in the following program, I want to print the sum of two floating point numbers X and Y.
#include
main()
{
float X=5.2;
float Y=5.1;
float Z;
…

user106313
- 638
- 1
- 6
- 21
16
votes
2 answers
How does a DMA controller work?
From Section 5.1.4 Direct Memory Access in Modern Operating Systems by Andrew S. Tanenbaum, Herbert Bos, 2014,
To simplify the explanation, we assume that the CPU accesses all devices and memory via a single system bus that connects the CPU, the…

Tim
- 5,405
- 7
- 48
- 84
14
votes
2 answers
Readiness vs. Completion Async IO Memory usage?
I was watching this talk about implementing Async IO in Rust and Carl mentions two potential models. Readiness and Completion.
Readiness Model:
you tell the kernel you want to read from a socket
do other things for awhile…
the kernel tells you when…

kjs3
- 241
- 1
- 5
13
votes
3 answers
Reading file during write on linux
As I understand, when a file is being written, the process writing to the file obtains an exclusive lock. So other processes cannot access this file for read.
With the above knowledge, I'm unable to understand how I'm able to play a video in media…

Sorter
- 373
- 2
- 4
- 12
12
votes
6 answers
How to Unit-Test a parser of a file?
I'm implementing a metadata parser of image files from all formats. I want to write tests for it. One trivial way to do so is to have test image files of all formats as a resources for the tests, and actually to read them as input. This approach may…

Sanich
- 223
- 2
- 5
12
votes
7 answers
How do I apply TDD to read/write functions?
It seems like a chicken and egg problem.
You can make a write function write to some data store, but never know you saved it properly without a tested read function.
You can make a read function read from a data store, but how do you put stuff…

user2738698
- 957
- 1
- 8
- 20
12
votes
1 answer
Model-View-Controller (MVC) Which component handles save/load operations?
In a traditional MVC application, which component (model, view, or controller) is responsible for reading/writing the model to/from disk?

weberc2
- 258
- 1
- 6
11
votes
1 answer
How does the Base Address Registers (BARs) in a PCI card work?
I am trying to understand how the Base Address Registers (BARs) in a PCI card work, this is how I think they work:
Each function in a PCI card have 6 BAR fields, and each BAR field is
32-bit in size.
The PCI card manufacturer will write in each BAR…

Christopher
- 2,029
- 3
- 13
- 16
10
votes
1 answer
Who is responsible for stream positioning?
The samples in question are c#, but it applies to any language.
If you have a function which reads content from a stream. Who should be responsible for ensuring that the stream position is correct before reading?
The caller, or the function doing…

JamesT
- 428
- 4
- 12
9
votes
2 answers
Separate Thread Pools for I/O and CPU Tasks
I've been puzzling over a good implementation for this for a while. I have a program that does a long-running I/O operation (downloading a file) and a long-running CPU operation (parsing its contents). To improve efficiency, I wanted to have one…

ndm13
- 219
- 2
- 6