Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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 ...
WelcomeToMyTutorial's user avatar
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 ...
GOGO's user avatar
  • 729
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?
gitman-2021's user avatar
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 ...
DataInTheStone's user avatar
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 ...
pieinthesky's user avatar
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 ...
Rockybilly's user avatar
  • 4,520
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 ...
echo_sg's user avatar
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 ...
Neeraj Rana's user avatar
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 ...
Prateek's user avatar
  • 17
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 ...
hudac's user avatar
  • 2,798
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 ...
Parsa Mousavi's user avatar
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 ...
user694989's user avatar
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 ...
user1720897's user avatar
  • 1,246
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 ...
Vuwox's user avatar
  • 2,359
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 ...
Elias Karabelas's user avatar

15 30 50 per page
1
2 3 4 5
9