Two C programs operate the hard disk at the same time, one reading and the other writing. The result shows that reading is much slower than writing. How to improve the reading speed under this situation (disk is near full load writing).

  linux, question

There are two programs to operate the hard disk, one to read and one to write.
When two programs are not running at the same time, the performance limit of the hard disk can be reached. 180M/s。
However, when the two programs run at the same time, the reading speed drops sharply by only about 60M. The speed of writing is much less affected, averaging 120-160 m/s. What are the ways to balance the difference in reading and writing speeds when two people seize the hard disk at the same time? And the reading speed is improved.

From the perspective of hard disk, read and write access should be mutually exclusive, so it is single process/thread.

There is a task scheduler in the CPU to schedule the read-write program. Microscopically, if the priority and frequency of the two programs are the same, it is possible that the writing speed is about half of the reading speed. Therefore, if the execution sequence of the read-write program in the CPU is arranged according to the time rotation algorithm of write-read-write-read-round-robin, the final writing can take up 2/3 of the CPU/ hard disk time, so the bandwidth is reduced to about 2/3.

Try reading and writing programs to communicate between IPC processes and coordinate their execution through synchronous mutual exclusion?

It depends on the application scenario, whether the read and written data are correlated, the frequency of occurrence and the profile.