Вот код процесса чтения:
Код: Выделить всё
#include
#include
#include
#include
#include
int main() {
const char* filename = "";
// Open the file for reading
int fd = open(filename, O_DIRECT | O_RDONLY);
if (fd < 0) {
perror("Failed to open file for reading");
return 1;
}
size_t sz = 40000;
char *read_data;
if (posix_memalign((void**)&read_data, 512, sz) != 0) {
perror("Failed to allocate aligned memory");
return 1;
}
bool loop = true;
size_t total_bytes = 0;
while (loop) {
ssize_t bytes_read = read(fd, read_data, sz);
if (bytes_read < 0) {
perror("Failed to read from file");
break;
} else if (bytes_read == 0) {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79217333/read-issues-during-concurrent-fwrite-to-nfs[/url]
Мобильная версия