All Questions
123 questions
2
votes
1
answer
167
views
Direct usage of I/O buffer
Is it safe to use I/O buffer directly?
For example, I have the following C++ code:
if (setvbuf(inFile, data, _IOFBF, std::size(data)))
{
throw std::runtime_error("can't set ...
1
vote
1
answer
143
views
Use mmap for random read from file but the read throuput is not as expected
I write k-v data into file with value size of 100KB and key size of 10Bytes. Only value data is written into file and indices of keys are stored in ram. I write 10M keys and I get a 1TB value file. I ...
0
votes
1
answer
43
views
How to get IO errors in `O_NONBLOCK`ed code?
Once I have enabled O_NONBLOCK, and then call a non-blocking function, and after it returns some I/O error happens, how may I get to know that something bad has happened, and how to handle it?
1
vote
1
answer
195
views
How is a read system call different from the istream::read function?
My Operating Systems professor was talking today about how a read system call is unbuffered while a istream::read function has a buffer. This left me a bit confused as you still make a buffer for the ...
0
votes
0
answers
58
views
fscanf() input formatting (C/C++)
I'm trying to read data from a .txt file with fscanf(), but it won't find values in the file. I want to skip certain values and read some integers as well as floating point numbers, all separated by ...
3
votes
1
answer
193
views
Excessive thread count yields better results with file reading
I have a hundred million files, my program reads all these files at every startup. I have been looking for ways to make this process faster. On the way, I've encountered something strange. My CPU has ...
0
votes
0
answers
300
views
Why does Ubuntu throw an I/O error randomly?
I have got a PC/104 (its OS is Ubuntu 16.04 with kernel 4.19.89 xenomai3) that is connected to two motors via two CAN adapters. Few days back, I wrote some simple code to open my PC/104's CAN ports ...
1
vote
1
answer
2k
views
Converting and printing hex values using sprintf(keeping the leading zeroes)
I have the following C code which takes two long integer values and convert them to two hex strings using the sprintf function:
void reverse_and_encode(FILE *fpt, long *src, long *dst) {
char ...
0
votes
0
answers
128
views
Managing large vectors with MPI I/O in C
I am trying to compute the distance function matrix for a set of spatial coordinates (x and y ) with index array "a". The following is a simplified script wherein I scatter only the index ...
7
votes
5
answers
4k
views
What actually happens in asynchronous IO
I keep reading about why asynchronous IO is better than synchronous IO, which is because in a-sync IO, your program can keep running, while in sync IO you're blocked until operation is finished.
I do ...
1
vote
2
answers
521
views
Error opening a file residing under "/sys/" in C/C++
I cannot read from a file resides under /sys(to be precise /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0/capacity).I've tried both using the C ...
0
votes
0
answers
292
views
Incomprehensible ENOMEM on fopen
A daemon often enough creates files for writing. Sometimes fopen/open/ofstream call fails with
errno == ENOMEM
All memory monitors show memory is enough. No any anothers memory errors. Which memory ...
0
votes
0
answers
54
views
printf printig inconsistent garbage when char array is returned to main [duplicate]
I am capturing the output of a command run through CreateProcess after redirecting the output to a file and then reading the file contents. I store the string read from the file into a char array ...
1
vote
1
answer
883
views
Trying to cancel execution and delete file using ffmpeg C API
The code below is a class that handle the conversion of multiples images, through add_frame() method, into a GIF with encode(). It also use a filter to generate and apply the palette. The usage is ...
0
votes
0
answers
57
views
Write fpos_t to disk
I have the following question: In parts of my software (mostly C++) I rely on reading precalculated binary data from a file to be used in a numerical simulation. This files can be quite big (like 32GB ...