Is reading / writing to a pipe an expensive operation?

As part of my Uni course, we were shown and asked to use channels for communication between processes (using pipe()and fork()) for several small exercises. No problems with his work or with the concept, but outside of these requirements, I wonder how efficiently to write and read using such a channel?

If I have some value that I am packing in a block of 4 bytes, is it better to pack and write 100 values ​​at the same time (400 bytes)?

Or is performance comparable if I make 100 entries each of 4 bytes?

Does it delete 400 bytes at a time so that the receiver does not do anything until the recording is complete. Assuming that the receiver is only trying to read the first 4 bytes, will it be able to do it after they are written, but first of all 400 is completed?

+3
source share
2 answers

(, ). , . ; . , . 4 , . , , .

+4

. - Linux. , , UNIX TCP. , . ( , - .)

+1

Source: https://habr.com/ru/post/1769317/


All Articles