Re: Why still seek and read?
Posted: Mon Nov 25, 2013 10:27 am
Or because the OS has only pread, which was the initial question.
If you have both, then you can use this information as a hint indeed. You could as well do that with a flag if you only have a pread()-style function (or a general hint on the file descriptor that says whether the access is mostly sequential) and want to have the hint.
I think having a seek/read pair is convenient anyway, but it's not really necessary for anything.
If you have both, then you can use this information as a hint indeed. You could as well do that with a flag if you only have a pread()-style function (or a general hint on the file descriptor that says whether the access is mostly sequential) and want to have the hint.
Sure, the very next thing will be a read. Still not a good argument for having a separate seek function. It only allows you to start a prefetch before the application issues the second syscall that isn't even necessary if you have a combined pread.mrstobbe wrote:My point is OS's can do that (and quite frankly should if they aren't already). Seeking someplace is an immediate indicator that, as program, you intend to do something there. If the file's been opened as read only, you know exactly what they plan to do there.
I think having a seek/read pair is convenient anyway, but it's not really necessary for anything.