简体   繁体   中英

Find the most expensive operation in terms of disk block transfer in UNIX

I was wondering which operation would be more expensive in terms of disk block transfers from the two operations that I'll present below present below( All this under the assumption that no relevant data exists in the buffer cache ). Is opening a file using the open() syscall more expensive than reading one block using read() syscall? It seems to me more sense that the open() operation would be more expensive because in this case all the blocks of the file from the disk should be loaded directly into the physical memory (assuming the physical memory is not too small for the file size), while on the other hand if I want to read only one block of the file using read() syscall then I'm going to have to load from the disk into the physical memory only one block.
If anyone can make this matter clear to me, I will be more than happy.

You seem to be confused about what these functions do.

The open function does not read in an entire file. It returns a file descriptor that can be used to read the file. The read function then takes this file descriptor as a parameter in order to read particular blocks of data from the file.

So you can't call read unless you've called open first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM